Skip to content

Commit

Permalink
Merge pull request #43 from hazelops/core-448
Browse files Browse the repository at this point in the history
ecs-app Terraform Module e2e tests
  • Loading branch information
igorkotof authored Nov 20, 2022
2 parents 9dd5cd0 + 1de48f0 commit e76e47f
Show file tree
Hide file tree
Showing 22 changed files with 960 additions and 61 deletions.
273 changes: 273 additions & 0 deletions .github/workflows/run.tf-examples-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,273 @@
name: "Tests: TF Examples"
defaults:
run:
shell: bash

env:
AWS_REGION: us-west-2
AWS_PROFILE: default
NAMESPACE: tftest
IZE_LOG_LEVEL: debug
IZE_PREFER_RUNTIME: native
IZE_PLAIN_TEXT: true
IZE_VERSION: 1.1.9

on:
workflow_dispatch:
pull_request:

jobs:
complete-worker:
runs-on: ubuntu-latest
timeout-minutes: 60
env:
ENV: examples1

steps:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.18.x

- name: Checkout Code
uses: actions/checkout@v2

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID_SA }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_SA }}
aws-region: ${{ env.AWS_REGION }}

- name: Generate Test SSH Key
run: ssh-keygen -q -f ~/.ssh/id_rsa

- name: IZE setup
uses: hazelops/[email protected]
with:
version: ${{ env.IZE_VERSION }}

- name: IZE init
run: ize init

- name: IZE create AWS Profile
run: ize gen aws-profile

- name: IZE gen tfenv
run: ize gen tfenv

- name: Copy generated files
run: |
cp -R .ize/env/${{ env.ENV }}/*.* examples/${{ github.job }}/
- name: Go TF Test
run: |
cd test/src
go mod tidy
go test -v -timeout 60m -run TestExamplesCompleteWorker
worker-scheduled:
runs-on: ubuntu-latest
timeout-minutes: 60
env:
ENV: examples2
needs:
- complete-worker
- web-nginx-proxy

steps:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.18.x

- name: Checkout Code
uses: actions/checkout@v2

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID_SA }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_SA }}
aws-region: ${{ env.AWS_REGION }}

- name: Generate Test SSH Key
run: ssh-keygen -q -f ~/.ssh/id_rsa

- name: IZE setup
uses: hazelops/[email protected]
with:
version: ${{ env.IZE_VERSION }}

- name: IZE init
run: ize init

- name: IZE create AWS Profile
run: ize gen aws-profile

- name: IZE gen tfenv
run: ize gen tfenv

- name: Copy generated files
run: |
cp -R .ize/env/${{ env.ENV }}/*.* examples/${{ github.job }}/
- name: Go TF Test
run: |
cd test/src
go mod tidy
go test -v -timeout 60m -run TestExamplesWorkerSchedule
complete-web:
runs-on: ubuntu-latest
timeout-minutes: 60
env:
ENV: examples3
needs:
- complete-worker
- web-nginx-proxy

steps:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.18.x

- name: Checkout Code
uses: actions/checkout@v2

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID_SA }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_SA }}
aws-region: ${{ env.AWS_REGION }}

- name: Generate Test SSH Key
run: ssh-keygen -q -f ~/.ssh/id_rsa

- name: IZE setup
uses: hazelops/[email protected]
with:
version: ${{ env.IZE_VERSION }}

- name: IZE init
run: ize init

- name: IZE create AWS Profile
run: ize gen aws-profile

- name: IZE gen tfenv
run: ize gen tfenv

- name: Copy generated files
run: |
cp -R .ize/env/${{ env.ENV }}/*.* examples/${{ github.job }}/
- name: Go TF Test
run: |
cd test/src
go mod tidy
go test -v -timeout 60m -run TestExamplesCompleteWeb
web-nginx-proxy:
runs-on: ubuntu-latest
env:
ENV: examples5
timeout-minutes: 60

steps:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.18.x

- name: Checkout Code
uses: actions/checkout@v2

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID_SA }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_SA }}
aws-region: ${{ env.AWS_REGION }}

- name: Generate Test SSH Key
run: ssh-keygen -q -f ~/.ssh/id_rsa

- name: IZE setup
uses: hazelops/[email protected]
with:
version: ${{ env.IZE_VERSION }}

- name: IZE init
run: ize init

- name: IZE create AWS Profile
run: ize gen aws-profile

- name: IZE gen tfenv
run: ize gen tfenv

- name: Copy generated files
run: |
cp -R .ize/env/${{ env.ENV }}/*.* examples/${{ github.job }}/
- name: Go TF Test
run: |
cd test/src
go mod tidy
go test -v -timeout 60m -run TestExamplesWebProxy
worker-scheduled-autoscale:
runs-on: ubuntu-latest
timeout-minutes: 60
env:
ENV: examples4
needs:
- worker-scheduled

steps:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.18.x

- name: Checkout Code
uses: actions/checkout@v2

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID_SA }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_SA }}
aws-region: ${{ env.AWS_REGION }}

- name: Generate Test SSH Key
run: ssh-keygen -q -f ~/.ssh/id_rsa

- name: IZE setup
uses: hazelops/[email protected]
with:
version: ${{ env.IZE_VERSION }}

- name: IZE init
run: ize init

- name: IZE create AWS Profile
run: ize gen aws-profile

- name: IZE gen tfenv
run: ize gen tfenv

- name: Copy generated files
run: |
cp -R .ize/env/${{ env.ENV }}/*.* examples/${{ github.job }}/
- name: Go TF Test
run: |
cd test/src
go mod tidy
go test -v -timeout 60m -run TestExamplesWorkerAutoScheduled
8 changes: 6 additions & 2 deletions examples/complete-tcp-app/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ variable "env" {}
variable "namespace" {}
variable "aws_profile" {}
variable "aws_region" {}
variable "docker_registry" {}
variable "docker_image_tag" {}
variable "docker_registry" {
default = "docker.io"
}
variable "docker_image_tag" {
default = "latest"
}
variable "root_domain_name" {}
8 changes: 6 additions & 2 deletions examples/complete-web-windows/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ variable "env" {}
variable "namespace" {}
variable "aws_profile" {}
variable "aws_region" {}
variable "docker_registry" {}
variable "docker_image_tag" {}
variable "docker_registry" {
default = "docker.io"
}
variable "docker_image_tag" {
default = "latest"
}
variable "root_domain_name" {}
10 changes: 5 additions & 5 deletions examples/complete-web/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,19 @@ module "vpc" {
version = "~> 3.0"

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

azs = [
"${var.aws_region}a",
"${var.aws_region}b"
]
public_subnets = [
"10.0.10.0/23",
"10.0.12.0/23"
"10.1.10.0/23",
"10.1.12.0/23"
]

private_subnets = [
"10.0.20.0/23"
"10.1.20.0/23"
]
manage_default_network_acl = true
default_network_acl_name = "${var.env}-${var.namespace}"
Expand Down Expand Up @@ -93,7 +93,7 @@ module "env_acm" {
module "ecs" {
source = "registry.terraform.io/terraform-aws-modules/ecs/aws"
version = "~> 4.0"
cluster_name = "${var.env}-${var.namespace}"
cluster_name = "${var.env}-${var.namespace}-app"
}

module "web_complete" {
Expand Down
4 changes: 3 additions & 1 deletion examples/complete-web/output.tf
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,6 @@ output "cloudwatch_log_group" {
output "ecs_cluster_name" {
value = module.ecs.cluster_name
}

output "r53_lb_dns_name" {
value = module.web_complete.r53_lb_dns_name
}
12 changes: 9 additions & 3 deletions examples/complete-web/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ variable "env" {}
variable "namespace" {}
variable "aws_profile" {}
variable "aws_region" {}
variable "docker_registry" {}
variable "docker_image_tag" {}
variable "root_domain_name" {}
variable "docker_registry" {
default = "docker.io"
}
variable "docker_image_tag" {
default = "latest"
}
variable "root_domain_name" {
default = "nutcorp.net"
}
8 changes: 6 additions & 2 deletions examples/complete-worker-ec2/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ variable "env" {}
variable "namespace" {}
variable "aws_profile" {}
variable "aws_region" {}
variable "docker_registry" {}
variable "docker_image_tag" {}
variable "docker_registry" {
default = "docker.io"
}
variable "docker_image_tag" {
default = "latest"
}
variable "ec2_key_pair_name" {}
variable "ssh_public_key" {}
2 changes: 1 addition & 1 deletion examples/complete-worker/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ resource "aws_security_group" "default_permissive" {
module "ecs" {
source = "registry.terraform.io/terraform-aws-modules/ecs/aws"
version = "~> 4.0"
cluster_name = "${var.env}-${var.namespace}"
cluster_name = "${var.env}-${var.namespace}-worker"
}

module "worker_complete" {
Expand Down
1 change: 0 additions & 1 deletion examples/complete-worker/output.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,3 @@ output "cloudwatch_event_rule_id" {
output "ecs_cluster_name" {
value = module.ecs.cluster_name
}

8 changes: 6 additions & 2 deletions examples/complete-worker/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,9 @@ variable "env" {}
variable "namespace" {}
variable "aws_profile" {}
variable "aws_region" {}
variable "docker_registry" {}
variable "docker_image_tag" {}
variable "docker_registry" {
default = "docker.io"
}
variable "docker_image_tag" {
default = "latest"
}
Loading

0 comments on commit e76e47f

Please sign in to comment.