Skip to content
This repository has been archived by the owner on Oct 2, 2024. It is now read-only.

Commit

Permalink
Initial
Browse files Browse the repository at this point in the history
  • Loading branch information
AutomationD committed May 7, 2020
0 parents commit 6a83244
Show file tree
Hide file tree
Showing 8 changed files with 146 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.terraform
*.tfstate*
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2020-present HazelOps OÜ https://hazelops.com

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
test:
@echo "TBD: Linter"
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# AWS ECS Cloud9 IDE Terraform Module

TBD
62 changes: 62 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
data "aws_region" "current" {}

locals {
secret_names = concat(var.secret_names, [
])

environment = merge(var.environment,
{
PUID: "1000"
PGID: "1000"
TZ: "America/Los_Angeles"
USERNAME: "admin"
PASSWORD: "Vr4KqHBgjLMMk92fsMkLd^ibHCJsy"
// ECS_FARGATE = var.ecs_launch_type == "FARGATE" ? "true" : "false"
}
)

container_definition = {
name = var.name
image = "${var.docker_image_name}:${var.docker_image_tag}",
memoryReservation = 128,
essential = true,

environment = [for k, v in local.environment : {name = k, value = v}]
secrets = module.ssm.secrets

portMappings = [{
containerPort = var.docker_container_port,
// In case of bridge an host use a dynamid port (0)
hostPort = var.ecs_network_mode == "awsvpc" ? var.docker_container_port : 0
}]

volumeMappings = var.ecs_launch_type == "FARGATE" ? [] : [
{
containerVolume = "/var/run/docker.sock",
hostVolume = "/var/run/docker.sock"
}
],



// logConfiguration = var.cloudwatch_log_group == "" ? {
// logDriver = "json-file"
// } : {
// logDriver = "awslogs",
// options = {
// awslogs-group = var.cloudwatch_log_group
// awslogs-region = data.aws_region.current.name
// awslogs-stream-prefix = var.name
// }
// }
}


}

module "ssm" {
source = "../ssm-secrets"
env = var.env
app_name = var.app_name
names = local.secret_names
}
3 changes: 3 additions & 0 deletions output.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
output "container_definition" {
value = local.container_definition
}
50 changes: 50 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
variable "env" {
}

variable "name" {
default = "cloud9"
}

variable "app_name" {
type = string
}


variable "environment" {
type = map(string)
default = {}
}

variable "secret_names" {
type = list(string)
default = []
}

//variable "ecs_cluster" {
// type = string
//}

variable "docker_image_name" {
type = string
default = "linuxserver/cloud9"
}

variable "docker_image_tag" {
type = string
default = "latest"
}

variable "ecs_launch_type" {

}

variable "cloudwatch_log_group" {
default = ""
}

variable "docker_container_port" {
default = 8000
}

variable "ecs_network_mode" {
}
3 changes: 3 additions & 0 deletions versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
terraform {
required_version = "~> 0.12.0"
}

0 comments on commit 6a83244

Please sign in to comment.