Skip to content

Commit

Permalink
feat(security-keys): Add localstack to github action for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
renemontilva committed Oct 1, 2024
1 parent 27b6185 commit d38817f
Show file tree
Hide file tree
Showing 4 changed files with 262 additions and 176 deletions.
353 changes: 188 additions & 165 deletions .github/workflows/security-keys.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,192 +14,215 @@ on:
- security/us-east-1/security-keys/**
- shared/us-east-1/security-keys/**
- shared/us-east-2/security-keys/**

jobs:
apps-devstg:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: hashicorp/setup-terraform@v3
with:
terraform_version: 1.7.0
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
us-east-1:
- 'apps-devstg/us-east-1/security-keys/**'
us-east-2:
- 'apps-devstg/us-east-2/security-keys/**'
- name: Terraform Init on us-east-1
if: steps.filter.outputs.us-east-1 == 'true'
working-directory: apps-devstg/us-east-1/security-keys
run: terraform init
- name: Run Unit Test on us-east-1
if: steps.filter.outputs.us-east-1 == 'true'
working-directory: apps-devstg/us-east-1/security-keys
run: |
terraform test
- name: Terraform Init on us-east-2
if: steps.filter.outputs.us-east-2 == 'true'
working-directory: apps-devstg/us-east-2/security-keys
run: terraform init
- name: Run Unit Test on us-east-2
if: steps.filter.outputs.us-east-2 == 'true'
working-directory: apps-devstg/us-east-2/security-keys
run: |
terraform test
apps-prd:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: hashicorp/setup-terraform@v3
with:
terraform_version: 1.7.0
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
us-east-1:
- 'apps-prd/us-east-1/security-keys/**'
- name: Terraform Init on us-east-1
if: steps.filter.outputs.us-east-1 == 'true'
working-directory: apps-prd/us-east-1/security-keys
run: terraform init
- name: Run Unit Test on us-east-1
if: steps.filter.outputs.us-east-1 == 'true'
working-directory: apps-prd/us-east-1/security-keys
run: |
terraform test
data-science:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: hashicorp/setup-terraform@v3
- uses: LocalStack/[email protected]
with:
terraform_version: 1.7.0
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
us-east-1:
- 'data-science/us-east-1/security-keys/**'
- name: Terraform Init on us-east-1
if: steps.filter.outputs.us-east-1 == 'true'
working-directory: data-science/us-east-1/security-keys
run: terraform init
- name: Run Unit Test on us-east-1
if: steps.filter.outputs.us-east-1 == 'true'
working-directory: data-science/us-east-1/security-keys
image-tag: "3.7.2"
install-awslocal: true
- name: Configure AWS Credentials
run: |
terraform test
management:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: hashicorp/setup-terraform@v3
with:
terraform_version: 1.7.0
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
us-east-1:
- 'management/us-east-1/security-keys/**'
- name: Terraform Init on us-east-1
if: steps.filter.outputs.us-east-1 == 'true'
working-directory: management/us-east-1/security-keys
run: terraform init
- name: Run Unit Test on us-east-1
if: steps.filter.outputs.us-east-1 == 'true'
working-directory: management/us-east-1/security-keys
awslocal configure set aws_access_key_id fake --profile bb-security-devops
awslocal configure set aws_secret_access_key fake --profile bb-security-devops
awslocal configure set region us-east-1 --profile bb-security-devops
awslocal configure set endpoint_url http://localhost:4566 --profile bb-security-devops
- name: Create S3 Buckets
run: |
terraform test
network:
runs-on: ubuntu-latest
steps:
awslocal s3 mb s3://security --region us-east-1
- uses: actions/checkout@v4
- uses: hashicorp/setup-terraform@v3
with:
terraform_version: 1.7.0
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
us-east-1:
- 'network/us-east-1/security-keys/**'
us-east-2:
- 'network/us-east-2/security-keys/**'
- name: Terraform Init on us-east-1
if: steps.filter.outputs.us-east-1 == 'true'
working-directory: network/us-east-1/security-keys
run: terraform init
- name: Run Unit Test on us-east-1
if: steps.filter.outputs.us-east-1 == 'true'
working-directory: network/us-east-1/security-keys
- name: Copy Terraform State File for testing to S3 Bucket
run: |
terraform test
- name: Terraform Init on us-east-2
if: steps.filter.outputs.us-east-2 == 'true'
working-directory: network/us-east-2/security-keys
run: terraform init
- name: Run Unit Test on us-east-2
if: steps.filter.outputs.us-east-2 == 'true'
working-directory: network/us-east-2/security-keys
run: |
terraform test
security:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
awslocal s3 cp apps-devstg/us-east-1/security-keys/tests/terraform.tfstate-test s3://security/identities/terraform.tfstate
- uses: hashicorp/setup-terraform@v3
with:
terraform_version: 1.7.0
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
us-east-1:
- 'security/us-east-1/security-keys/**'
- name: Terraform Init on us-east-1
if: steps.filter.outputs.us-east-1 == 'true'
working-directory: security/us-east-1/security-keys
run: terraform init
- name: Run Unit Test on us-east-1
if: steps.filter.outputs.us-east-1 == 'true'
working-directory: security/us-east-1/security-keys
- name: Install tflocal
run: |
terraform test
shared:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: hashicorp/setup-terraform@v3
with:
terraform_version: 1.7.0
pip install terraform-local
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
us-east-1:
- 'shared/us-east-1/security-keys/**'
- 'apps-devstg/us-east-1/security-keys/**'
us-east-2:
- 'shared/us-east-2/security-keys/**'
- 'apps-devstg/us-east-2/security-keys/**'
- name: Terraform Init on us-east-1
if: steps.filter.outputs.us-east-1 == 'true'
working-directory: shared/us-east-1/security-keys
run: terraform init
working-directory: apps-devstg/us-east-1/security-keys
run: tflocal init
- name: Run Unit Test on us-east-1
if: steps.filter.outputs.us-east-1 == 'true'
working-directory: shared/us-east-1/security-keys
run: |
terraform test
- name: Terraform Init on us-east-2
if: steps.filter.outputs.us-east-2 == 'true'
working-directory: shared/us-east-2/security-keys
run: terraform init
- name: Run Unit Test on us-east-2
if: steps.filter.outputs.us-east-2 == 'true'
working-directory: shared/us-east-2/security-keys
working-directory: apps-devstg/us-east-1/security-keys
env:
AWS_DEFAULT_REGION: us-east-1
AWS_ACCESS_KEY_ID: fake
AWS_SECRET_ACCESS_KEY: fake
run: |
terraform test
cp ../../../config/common.tfvars.example ../../../config/common.tfvars
tflocal test -var-file=../../../config/common.tfvars -var-file=../../config/account.tfvars -var-file=../../config/backend.tfvars
#- name: Terraform Init on us-east-2
# if: steps.filter.outputs.us-east-2 == 'true'
# working-directory: apps-devstg/us-east-2/security-keys
# run: terraform init
#- name: Run Unit Test on us-east-2
# if: steps.filter.outputs.us-east-2 == 'true'
# working-directory: apps-devstg/us-east-2/security-keys
# run: |
# terraform test
# apps-prd:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# - uses: hashicorp/setup-terraform@v3
# with:
# terraform_version: 1.7.0
# - uses: dorny/paths-filter@v3
# id: filter
# with:
# filters: |
# us-east-1:
# - 'apps-prd/us-east-1/security-keys/**'
# - name: Terraform Init on us-east-1
# if: steps.filter.outputs.us-east-1 == 'true'
# working-directory: apps-prd/us-east-1/security-keys
# run: terraform init
# - name: Run Unit Test on us-east-1
# if: steps.filter.outputs.us-east-1 == 'true'
# working-directory: apps-prd/us-east-1/security-keys
# run: |
# terraform test
# data-science:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# - uses: hashicorp/setup-terraform@v3
# with:
# terraform_version: 1.7.0
# - uses: dorny/paths-filter@v3
# id: filter
# with:
# filters: |
# us-east-1:
# - 'data-science/us-east-1/security-keys/**'
# - name: Terraform Init on us-east-1
# if: steps.filter.outputs.us-east-1 == 'true'
# working-directory: data-science/us-east-1/security-keys
# run: terraform init
# - name: Run Unit Test on us-east-1
# if: steps.filter.outputs.us-east-1 == 'true'
# working-directory: data-science/us-east-1/security-keys
# run: |
# terraform test
# management:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# - uses: hashicorp/setup-terraform@v3
# with:
# terraform_version: 1.7.0
# - uses: dorny/paths-filter@v3
# id: filter
# with:
# filters: |
# us-east-1:
# - 'management/us-east-1/security-keys/**'
# - name: Terraform Init on us-east-1
# if: steps.filter.outputs.us-east-1 == 'true'
# working-directory: management/us-east-1/security-keys
# run: terraform init
# - name: Run Unit Test on us-east-1
# if: steps.filter.outputs.us-east-1 == 'true'
# working-directory: management/us-east-1/security-keys
# run: |
# terraform test
# network:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# - uses: hashicorp/setup-terraform@v3
# with:
# terraform_version: 1.7.0
# - uses: dorny/paths-filter@v3
# id: filter
# with:
# filters: |
# us-east-1:
# - 'network/us-east-1/security-keys/**'
# us-east-2:
# - 'network/us-east-2/security-keys/**'
# - name: Terraform Init on us-east-1
# if: steps.filter.outputs.us-east-1 == 'true'
# working-directory: network/us-east-1/security-keys
# run: terraform init
# - name: Run Unit Test on us-east-1
# if: steps.filter.outputs.us-east-1 == 'true'
# working-directory: network/us-east-1/security-keys
# run: |
# terraform test
# - name: Terraform Init on us-east-2
# if: steps.filter.outputs.us-east-2 == 'true'
# working-directory: network/us-east-2/security-keys
# run: terraform init
# - name: Run Unit Test on us-east-2
# if: steps.filter.outputs.us-east-2 == 'true'
# working-directory: network/us-east-2/security-keys
# run: |
# terraform test
# security:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# - uses: hashicorp/setup-terraform@v3
# with:
# terraform_version: 1.7.0
# - uses: dorny/paths-filter@v3
# id: filter
# with:
# filters: |
# us-east-1:
# - 'security/us-east-1/security-keys/**'
# - name: Terraform Init on us-east-1
# if: steps.filter.outputs.us-east-1 == 'true'
# working-directory: security/us-east-1/security-keys
# run: terraform init
# - name: Run Unit Test on us-east-1
# if: steps.filter.outputs.us-east-1 == 'true'
# working-directory: security/us-east-1/security-keys
# run: |
# terraform test
# shared:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# - uses: hashicorp/setup-terraform@v3
# with:
# terraform_version: 1.7.0
# - uses: dorny/paths-filter@v3
# id: filter
# with:
# filters: |
# us-east-1:
# - 'shared/us-east-1/security-keys/**'
# us-east-2:
# - 'shared/us-east-2/security-keys/**'
# - name: Terraform Init on us-east-1
# if: steps.filter.outputs.us-east-1 == 'true'
# working-directory: shared/us-east-1/security-keys
# run: terraform init
# - name: Run Unit Test on us-east-1
# if: steps.filter.outputs.us-east-1 == 'true'
# working-directory: shared/us-east-1/security-keys
# run: |
# terraform test
# - name: Terraform Init on us-east-2
# if: steps.filter.outputs.us-east-2 == 'true'
# working-directory: shared/us-east-2/security-keys
# run: terraform init
# - name: Run Unit Test on us-east-2
# if: steps.filter.outputs.us-east-2 == 'true'
# working-directory: shared/us-east-2/security-keys
# run: |
# terraform test
2 changes: 1 addition & 1 deletion apps-devstg/us-east-1/security-keys/config.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ provider "aws" {
# Backend Config (partial) #
#=============================#
terraform {
required_version = "~> 1.2.7"
required_version = ">= 1.2.7"

required_providers {
aws = "~> 4.10"
Expand Down
Loading

0 comments on commit d38817f

Please sign in to comment.