Skip to content

Commit e76e47f

Browse files
authored
Merge pull request #43 from hazelops/core-448
ecs-app Terraform Module e2e tests
2 parents 9dd5cd0 + 1de48f0 commit e76e47f

File tree

22 files changed

+960
-61
lines changed

22 files changed

+960
-61
lines changed
Lines changed: 273 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,273 @@
1+
name: "Tests: TF Examples"
2+
defaults:
3+
run:
4+
shell: bash
5+
6+
env:
7+
AWS_REGION: us-west-2
8+
AWS_PROFILE: default
9+
NAMESPACE: tftest
10+
IZE_LOG_LEVEL: debug
11+
IZE_PREFER_RUNTIME: native
12+
IZE_PLAIN_TEXT: true
13+
IZE_VERSION: 1.1.9
14+
15+
on:
16+
workflow_dispatch:
17+
pull_request:
18+
19+
jobs:
20+
complete-worker:
21+
runs-on: ubuntu-latest
22+
timeout-minutes: 60
23+
env:
24+
ENV: examples1
25+
26+
steps:
27+
- name: Install Go
28+
uses: actions/setup-go@v2
29+
with:
30+
go-version: 1.18.x
31+
32+
- name: Checkout Code
33+
uses: actions/checkout@v2
34+
35+
- name: Configure AWS Credentials
36+
uses: aws-actions/configure-aws-credentials@v1
37+
with:
38+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID_SA }}
39+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_SA }}
40+
aws-region: ${{ env.AWS_REGION }}
41+
42+
- name: Generate Test SSH Key
43+
run: ssh-keygen -q -f ~/.ssh/id_rsa
44+
45+
- name: IZE setup
46+
uses: hazelops/[email protected]
47+
with:
48+
version: ${{ env.IZE_VERSION }}
49+
50+
- name: IZE init
51+
run: ize init
52+
53+
- name: IZE create AWS Profile
54+
run: ize gen aws-profile
55+
56+
- name: IZE gen tfenv
57+
run: ize gen tfenv
58+
59+
- name: Copy generated files
60+
run: |
61+
cp -R .ize/env/${{ env.ENV }}/*.* examples/${{ github.job }}/
62+
63+
- name: Go TF Test
64+
run: |
65+
cd test/src
66+
go mod tidy
67+
go test -v -timeout 60m -run TestExamplesCompleteWorker
68+
69+
worker-scheduled:
70+
runs-on: ubuntu-latest
71+
timeout-minutes: 60
72+
env:
73+
ENV: examples2
74+
needs:
75+
- complete-worker
76+
- web-nginx-proxy
77+
78+
steps:
79+
- name: Install Go
80+
uses: actions/setup-go@v2
81+
with:
82+
go-version: 1.18.x
83+
84+
- name: Checkout Code
85+
uses: actions/checkout@v2
86+
87+
- name: Configure AWS Credentials
88+
uses: aws-actions/configure-aws-credentials@v1
89+
with:
90+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID_SA }}
91+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_SA }}
92+
aws-region: ${{ env.AWS_REGION }}
93+
94+
- name: Generate Test SSH Key
95+
run: ssh-keygen -q -f ~/.ssh/id_rsa
96+
97+
- name: IZE setup
98+
uses: hazelops/[email protected]
99+
with:
100+
version: ${{ env.IZE_VERSION }}
101+
102+
- name: IZE init
103+
run: ize init
104+
105+
- name: IZE create AWS Profile
106+
run: ize gen aws-profile
107+
108+
- name: IZE gen tfenv
109+
run: ize gen tfenv
110+
111+
- name: Copy generated files
112+
run: |
113+
cp -R .ize/env/${{ env.ENV }}/*.* examples/${{ github.job }}/
114+
115+
- name: Go TF Test
116+
run: |
117+
cd test/src
118+
go mod tidy
119+
go test -v -timeout 60m -run TestExamplesWorkerSchedule
120+
121+
122+
complete-web:
123+
runs-on: ubuntu-latest
124+
timeout-minutes: 60
125+
env:
126+
ENV: examples3
127+
needs:
128+
- complete-worker
129+
- web-nginx-proxy
130+
131+
steps:
132+
- name: Install Go
133+
uses: actions/setup-go@v2
134+
with:
135+
go-version: 1.18.x
136+
137+
- name: Checkout Code
138+
uses: actions/checkout@v2
139+
140+
- name: Configure AWS Credentials
141+
uses: aws-actions/configure-aws-credentials@v1
142+
with:
143+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID_SA }}
144+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_SA }}
145+
aws-region: ${{ env.AWS_REGION }}
146+
147+
- name: Generate Test SSH Key
148+
run: ssh-keygen -q -f ~/.ssh/id_rsa
149+
150+
- name: IZE setup
151+
uses: hazelops/[email protected]
152+
with:
153+
version: ${{ env.IZE_VERSION }}
154+
155+
- name: IZE init
156+
run: ize init
157+
158+
- name: IZE create AWS Profile
159+
run: ize gen aws-profile
160+
161+
- name: IZE gen tfenv
162+
run: ize gen tfenv
163+
164+
- name: Copy generated files
165+
run: |
166+
cp -R .ize/env/${{ env.ENV }}/*.* examples/${{ github.job }}/
167+
168+
- name: Go TF Test
169+
run: |
170+
cd test/src
171+
go mod tidy
172+
go test -v -timeout 60m -run TestExamplesCompleteWeb
173+
174+
175+
web-nginx-proxy:
176+
runs-on: ubuntu-latest
177+
env:
178+
ENV: examples5
179+
timeout-minutes: 60
180+
181+
steps:
182+
- name: Install Go
183+
uses: actions/setup-go@v2
184+
with:
185+
go-version: 1.18.x
186+
187+
- name: Checkout Code
188+
uses: actions/checkout@v2
189+
190+
- name: Configure AWS Credentials
191+
uses: aws-actions/configure-aws-credentials@v1
192+
with:
193+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID_SA }}
194+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_SA }}
195+
aws-region: ${{ env.AWS_REGION }}
196+
197+
- name: Generate Test SSH Key
198+
run: ssh-keygen -q -f ~/.ssh/id_rsa
199+
200+
- name: IZE setup
201+
uses: hazelops/[email protected]
202+
with:
203+
version: ${{ env.IZE_VERSION }}
204+
205+
- name: IZE init
206+
run: ize init
207+
208+
- name: IZE create AWS Profile
209+
run: ize gen aws-profile
210+
211+
- name: IZE gen tfenv
212+
run: ize gen tfenv
213+
214+
- name: Copy generated files
215+
run: |
216+
cp -R .ize/env/${{ env.ENV }}/*.* examples/${{ github.job }}/
217+
218+
- name: Go TF Test
219+
run: |
220+
cd test/src
221+
go mod tidy
222+
go test -v -timeout 60m -run TestExamplesWebProxy
223+
224+
worker-scheduled-autoscale:
225+
runs-on: ubuntu-latest
226+
timeout-minutes: 60
227+
env:
228+
ENV: examples4
229+
needs:
230+
- worker-scheduled
231+
232+
steps:
233+
- name: Install Go
234+
uses: actions/setup-go@v2
235+
with:
236+
go-version: 1.18.x
237+
238+
- name: Checkout Code
239+
uses: actions/checkout@v2
240+
241+
- name: Configure AWS Credentials
242+
uses: aws-actions/configure-aws-credentials@v1
243+
with:
244+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID_SA }}
245+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_SA }}
246+
aws-region: ${{ env.AWS_REGION }}
247+
248+
- name: Generate Test SSH Key
249+
run: ssh-keygen -q -f ~/.ssh/id_rsa
250+
251+
- name: IZE setup
252+
uses: hazelops/[email protected]
253+
with:
254+
version: ${{ env.IZE_VERSION }}
255+
256+
- name: IZE init
257+
run: ize init
258+
259+
- name: IZE create AWS Profile
260+
run: ize gen aws-profile
261+
262+
- name: IZE gen tfenv
263+
run: ize gen tfenv
264+
265+
- name: Copy generated files
266+
run: |
267+
cp -R .ize/env/${{ env.ENV }}/*.* examples/${{ github.job }}/
268+
269+
- name: Go TF Test
270+
run: |
271+
cd test/src
272+
go mod tidy
273+
go test -v -timeout 60m -run TestExamplesWorkerAutoScheduled

examples/complete-tcp-app/variables.tf

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ variable "env" {}
66
variable "namespace" {}
77
variable "aws_profile" {}
88
variable "aws_region" {}
9-
variable "docker_registry" {}
10-
variable "docker_image_tag" {}
9+
variable "docker_registry" {
10+
default = "docker.io"
11+
}
12+
variable "docker_image_tag" {
13+
default = "latest"
14+
}
1115
variable "root_domain_name" {}

examples/complete-web-windows/variables.tf

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ variable "env" {}
22
variable "namespace" {}
33
variable "aws_profile" {}
44
variable "aws_region" {}
5-
variable "docker_registry" {}
6-
variable "docker_image_tag" {}
5+
variable "docker_registry" {
6+
default = "docker.io"
7+
}
8+
variable "docker_image_tag" {
9+
default = "latest"
10+
}
711
variable "root_domain_name" {}

examples/complete-web/main.tf

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,19 @@ module "vpc" {
2020
version = "~> 3.0"
2121

2222
name = "${var.env}-vpc"
23-
cidr = "10.0.0.0/16"
23+
cidr = "10.1.0.0/16"
2424

2525
azs = [
2626
"${var.aws_region}a",
2727
"${var.aws_region}b"
2828
]
2929
public_subnets = [
30-
"10.0.10.0/23",
31-
"10.0.12.0/23"
30+
"10.1.10.0/23",
31+
"10.1.12.0/23"
3232
]
3333

3434
private_subnets = [
35-
"10.0.20.0/23"
35+
"10.1.20.0/23"
3636
]
3737
manage_default_network_acl = true
3838
default_network_acl_name = "${var.env}-${var.namespace}"
@@ -93,7 +93,7 @@ module "env_acm" {
9393
module "ecs" {
9494
source = "registry.terraform.io/terraform-aws-modules/ecs/aws"
9595
version = "~> 4.0"
96-
cluster_name = "${var.env}-${var.namespace}"
96+
cluster_name = "${var.env}-${var.namespace}-app"
9797
}
9898

9999
module "web_complete" {

examples/complete-web/output.tf

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,6 @@ output "cloudwatch_log_group" {
1313
output "ecs_cluster_name" {
1414
value = module.ecs.cluster_name
1515
}
16-
16+
output "r53_lb_dns_name" {
17+
value = module.web_complete.r53_lb_dns_name
18+
}

examples/complete-web/variables.tf

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ variable "env" {}
66
variable "namespace" {}
77
variable "aws_profile" {}
88
variable "aws_region" {}
9-
variable "docker_registry" {}
10-
variable "docker_image_tag" {}
11-
variable "root_domain_name" {}
9+
variable "docker_registry" {
10+
default = "docker.io"
11+
}
12+
variable "docker_image_tag" {
13+
default = "latest"
14+
}
15+
variable "root_domain_name" {
16+
default = "nutcorp.net"
17+
}

examples/complete-worker-ec2/variables.tf

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@ variable "env" {}
22
variable "namespace" {}
33
variable "aws_profile" {}
44
variable "aws_region" {}
5-
variable "docker_registry" {}
6-
variable "docker_image_tag" {}
5+
variable "docker_registry" {
6+
default = "docker.io"
7+
}
8+
variable "docker_image_tag" {
9+
default = "latest"
10+
}
711
variable "ec2_key_pair_name" {}
812
variable "ssh_public_key" {}

examples/complete-worker/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ resource "aws_security_group" "default_permissive" {
5858
module "ecs" {
5959
source = "registry.terraform.io/terraform-aws-modules/ecs/aws"
6060
version = "~> 4.0"
61-
cluster_name = "${var.env}-${var.namespace}"
61+
cluster_name = "${var.env}-${var.namespace}-worker"
6262
}
6363

6464
module "worker_complete" {

examples/complete-worker/output.tf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,3 @@ output "cloudwatch_event_rule_id" {
1717
output "ecs_cluster_name" {
1818
value = module.ecs.cluster_name
1919
}
20-

examples/complete-worker/variables.tf

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,9 @@ variable "env" {}
22
variable "namespace" {}
33
variable "aws_profile" {}
44
variable "aws_region" {}
5-
variable "docker_registry" {}
6-
variable "docker_image_tag" {}
5+
variable "docker_registry" {
6+
default = "docker.io"
7+
}
8+
variable "docker_image_tag" {
9+
default = "latest"
10+
}

0 commit comments

Comments
 (0)