Skip to content

Commit 9bc0d52

Browse files
authored
Merge pull request #1 from mongodb/develop
Add initial configuration files and tests
2 parents 4b057e2 + c8cc1f6 commit 9bc0d52

File tree

149 files changed

+30907
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

149 files changed

+30907
-0
lines changed

.circleci/config.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
jobs:
2+
build:
3+
docker:
4+
- image: hashicorp/terraform:0.11.11
5+
environment:
6+
TERRAFORM_VERSION: v0.11
7+
steps:
8+
- checkout
9+
- run:
10+
command: terraform init
11+
test:
12+
docker:
13+
- image: hashicorp/terraform:0.11.11
14+
steps:
15+
- checkout
16+
- run:
17+
command: |
18+
terraform fmt -check=true
19+
terraform validate
20+
go test -v ./...
21+
version: 2
22+
workflows:
23+
build-test:
24+
jobs:
25+
- build
26+
- test:
27+
requires:
28+
- build
29+
version: 2

.gitignore

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Local .terraform directories
2+
**/.terraform/*
3+
4+
# .tfstate files
5+
*.tfstate
6+
*.tfstate.*
7+
8+
# Crash log files
9+
crash.log
10+
11+
# Ignore any .tfvars files that are generated automatically for each Terraform run. Most
12+
# .tfvars files are managed as part of configuration and so should be included in
13+
# version control.
14+
#
15+
# example.tfvars
16+
17+
# Ignore override files as they are usually used to override resources locally and so
18+
# are not checked in
19+
override.tf
20+
override.tf.json
21+
*_override.tf
22+
*_override.tf.json
23+
24+
# Include override files you do wish to add to version control using negated pattern
25+
#
26+
# !example_override.tf

Gopkg.lock

Lines changed: 86 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Gopkg.toml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Gopkg.toml example
2+
#
3+
# Refer to https://golang.github.io/dep/docs/Gopkg.toml.html
4+
# for detailed Gopkg.toml documentation.
5+
#
6+
# required = ["github.com/user/thing/cmd/thing"]
7+
# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"]
8+
#
9+
# [[constraint]]
10+
# name = "github.com/user/project"
11+
# version = "1.0.0"
12+
#
13+
# [[constraint]]
14+
# name = "github.com/user/project2"
15+
# branch = "dev"
16+
# source = "github.com/myfork/project2"
17+
#
18+
# [[override]]
19+
# name = "github.com/x/y"
20+
# version = "2.4.0"
21+
#
22+
# [prune]
23+
# non-go = false
24+
# go-tests = true
25+
# unused-packages = true
26+
27+
28+
[[constraint]]
29+
name = "github.com/gruntwork-io/terratest"
30+
version = "0.14.2"
31+
32+
[[constraint]]
33+
name = "github.com/stretchr/testify"
34+
version = "1.3.0"
35+
36+
[prune]
37+
go-tests = true
38+
unused-packages = true

main.tf

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
locals {
2+
command = "${jsonencode(var.command)}"
3+
dnsSearchDomains = "${jsonencode(var.dnsSearchDomains)}"
4+
dnsServers = "${jsonencode(var.dnsServers)}"
5+
dockerLabels = "${jsonencode(var.dockerLabels)}"
6+
dockerSecurityOptions = "${jsonencode(var.dockerSecurityOptions)}"
7+
entryPoint = "${jsonencode(var.entryPoint)}"
8+
environment = "${jsonencode(var.environment)}"
9+
extraHosts = "${jsonencode(var.extraHosts)}"
10+
11+
healthCheck = "${
12+
replace(
13+
jsonencode(var.healthCheck),
14+
local.classes["digit"],
15+
"$1"
16+
)
17+
}"
18+
19+
links = "${jsonencode(var.links)}"
20+
21+
linuxParameters = "${
22+
replace(
23+
replace(
24+
replace(
25+
jsonencode(var.linuxParameters),
26+
"/\"1\"/",
27+
"true"
28+
),
29+
"/\"0\"/",
30+
"false"
31+
),
32+
local.classes["digit"],
33+
"$1"
34+
)
35+
}"
36+
37+
logConfiguration = "${jsonencode(var.logConfiguration)}"
38+
39+
mountPoints = "${
40+
replace(
41+
replace(
42+
jsonencode(var.mountPoints),
43+
"/\"1\"/",
44+
"true"
45+
),
46+
"/\"0\"/",
47+
"false"
48+
)
49+
}"
50+
51+
portMappings = "${
52+
replace(
53+
jsonencode(var.portMappings),
54+
local.classes["digit"],
55+
"$1"
56+
)
57+
}"
58+
59+
repositoryCredentials = "${jsonencode(var.repositoryCredentials)}"
60+
resourceRequirements = "${jsonencode(var.resourceRequirements)}"
61+
secrets = "${jsonencode(var.secrets)}"
62+
systemControls = "${jsonencode(var.systemControls)}"
63+
64+
ulimits = "${
65+
replace(
66+
jsonencode(var.ulimits),
67+
local.classes["digit"],
68+
"$1"
69+
)
70+
}"
71+
72+
volumesFrom = "${
73+
replace(
74+
replace(
75+
jsonencode(var.volumesFrom),
76+
"/\"1\"/",
77+
"true"
78+
),
79+
"/\"0\"/",
80+
"false"
81+
)
82+
}"
83+
84+
# re2 ASCII character classes
85+
# https://github.com/google/re2/wiki/Syntax
86+
classes = {
87+
digit = "/\"([[:digit:]]+)\"/"
88+
}
89+
90+
container_definitions = "${replace(data.template_file.container_definitions.rendered, "/\"(null)\"/", "$1")}"
91+
}
92+
93+
data "template_file" "container_definitions" {
94+
template = "${file("${path.module}/templates/container-definitions.json.tmpl")}"
95+
96+
vars = {
97+
command = "${local.command == "[]" ? "null" : local.command}"
98+
cpu = "${var.cpu == 0 ? "null" : var.cpu}"
99+
disableNetworking = "${var.disableNetworking ? true : false}"
100+
dnsSearchDomains = "${local.dnsSearchDomains == "[]" ? "null" : local.dnsSearchDomains}"
101+
dnsServers = "${local.dnsServers == "[]" ? "null" : local.dnsServers}"
102+
dockerLabels = "${local.dockerLabels == "{}" ? "null" : local.dockerLabels}"
103+
dockerSecurityOptions = "${local.dockerSecurityOptions == "[]" ? "null" : local.dockerSecurityOptions}"
104+
entryPoint = "${local.entryPoint == "[]" ? "null" : local.entryPoint}"
105+
environment = "${local.environment == "[]" ? "null" : local.environment}"
106+
essential = "${var.essential ? true : false}"
107+
extraHosts = "${local.extraHosts == "[]" ? "null" : local.extraHosts}"
108+
healthCheck = "${local.healthCheck == "{}" ? "null" : local.healthCheck}"
109+
hostname = "${var.hostname == "" ? "null" : var.hostname}"
110+
image = "${var.image == "" ? "null" : var.image}"
111+
interactive = "${var.interactive ? true : false}"
112+
links = "${local.links == "[]" ? "null" : local.links}"
113+
linuxParameters = "${local.linuxParameters == "{}" ? "null" : local.linuxParameters}"
114+
logConfiguration = "${local.logConfiguration == "{}" ? "null" : local.logConfiguration}"
115+
memory = "${var.memory == 0 ? "null" : var.memory}"
116+
memoryReservation = "${var.memoryReservation == 0 ? "null" : var.memoryReservation}"
117+
mountPoints = "${local.mountPoints == "[]" ? "null" : local.mountPoints}"
118+
name = "${var.name == "" ? "null" : var.name}"
119+
portMappings = "${local.portMappings == "[]" ? "null" : local.portMappings}"
120+
privileged = "${var.privileged ? true : false}"
121+
pseudoTerminal = "${var.pseudoTerminal ? true : false}"
122+
readonlyRootFilesystem = "${var.readonlyRootFilesystem ? true : false}"
123+
repositoryCredentials = "${local.repositoryCredentials == "{}" ? "null" : local.repositoryCredentials}"
124+
resourceRequirements = "${local.resourceRequirements == "[]" ? "null" : local.resourceRequirements}"
125+
secrets = "${local.secrets == "[]" ? "null" : local.secrets}"
126+
systemControls = "${local.systemControls == "[]" ? "null" : local.systemControls}"
127+
ulimits = "${local.ulimits == "[]" ? "null" : local.ulimits}"
128+
user = "${var.user == "" ? "null" : var.user}"
129+
volumesFrom = "${local.volumesFrom == "[]" ? "null" : local.volumesFrom}"
130+
workingDirectory = "${var.workingDirectory == "" ? "null" : var.workingDirectory}"
131+
}
132+
}
133+
134+
resource "aws_ecs_task_definition" "ecs_task_definition" {
135+
container_definitions = "${local.container_definitions}"
136+
execution_role_arn = "${var.execution_role_arn}"
137+
family = "${var.family}"
138+
ipc_mode = "${var.ipc_mode}"
139+
network_mode = "${var.network_mode}"
140+
pid_mode = "${var.pid_mode}"
141+
placement_constraints = "${var.placement_constraints}"
142+
requires_compatibilities = "${var.requires_compatibilities}"
143+
task_role_arn = "${var.task_role_arn}"
144+
volume = "${var.volumes}"
145+
}

outputs.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
output "container_definitions" {
2+
description = "A list of container definitions in JSON format that describe the different containers that make up your task"
3+
value = "${local.container_definitions}"
4+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
[
2+
{
3+
"command": ${command},
4+
"cpu": ${cpu},
5+
"disableNetworking": ${disableNetworking},
6+
"dnsSearchDomains": ${dnsSearchDomains},
7+
"dnsServers": ${dnsServers},
8+
"dockerLabels": ${dockerLabels},
9+
"dockerSecurityOptions": ${dockerSecurityOptions},
10+
"entryPoint": ${entryPoint},
11+
"environment": ${environment},
12+
"essential": ${essential},
13+
"extraHosts": ${extraHosts},
14+
"healthCheck": ${healthCheck},
15+
"hostname": "${hostname}",
16+
"image": "${image}",
17+
"interactive": ${interactive},
18+
"links": ${links},
19+
"linuxParameters": ${linuxParameters},
20+
"logConfiguration": ${logConfiguration},
21+
"memory": ${memory},
22+
"memoryReservation": ${memoryReservation},
23+
"mountPoints": ${mountPoints},
24+
"name": "${name}",
25+
"portMappings": ${portMappings},
26+
"privileged": ${privileged},
27+
"pseudoTerminal": ${pseudoTerminal},
28+
"readonlyRootFilesystem": ${readonlyRootFilesystem},
29+
"repositoryCredentials": ${repositoryCredentials},
30+
"resourceRequirements": ${resourceRequirements},
31+
"secrets": ${secrets},
32+
"systemControls": ${systemControls},
33+
"ulimits": ${ulimits},
34+
"user": "${user}",
35+
"volumesFrom": ${volumesFrom},
36+
"workingDirectory": "${workingDirectory}"
37+
}
38+
]

0 commit comments

Comments
 (0)