Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 16 additions & 15 deletions .github/workflows/deploy-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,31 +34,32 @@ jobs:
uses: hashicorp/setup-terraform@v3
with:
terraform_version: "1.9.0"

- name: Cache Terragrunt
uses: actions/cache@v3
with:
path: ~/.terragrunt-cache
key: ${{ runner.os }}-terragrunt-${{ hashFiles('**/*.hcl') }}
terraform_wrapper: false

- name: Setup Terragrunt
run: |
wget -q https://github.com/gruntwork-io/terragrunt/releases/download/v0.55.0/terragrunt_linux_amd64
chmod +x terragrunt_linux_amd64
mv terragrunt_linux_amd64 /usr/local/bin/terragrunt
mkdir -p $HOME/bin
curl -fsSL -o $HOME/bin/terragrunt https://github.com/gruntwork-io/terragrunt/releases/download/v1.0.6/terragrunt_linux_amd64
chmod +x $HOME/bin/terragrunt
echo "$HOME/bin" >> $GITHUB_PATH

- name: Deploy to Dev
run: |
cd environments/dev
terragrunt run-all apply --terragrunt-non-interactive
terragrunt run --all apply --working-dir environments/dev --non-interactive

- name: Run Smoke Tests
continue-on-error: true
run: |
chmod +x scripts/smoke-tests.sh
./scripts/smoke-tests.sh
if [ -f scripts/smoke-tests.sh ]; then
chmod +x scripts/smoke-tests.sh
./scripts/smoke-tests.sh
else
echo "No smoke tests script found, skipping"
fi

- name: Notify on Failure
if: failure()
continue-on-error: true
run: |
curl -X POST ${{ secrets.SLACK_WEBHOOK }} \
-d '{"text": "Deploy Dev falhou! Ver: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"}'
curl -fsS --max-time 30 -X POST ${{ secrets.SLACK_WEBHOOK }} \
-d '{"text": "Deploy Dev falhou! Ver: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"}' || true
50 changes: 21 additions & 29 deletions .github/workflows/deploy-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,28 +23,23 @@ jobs:
role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
aws-region: eu-west-1

- name: Cache Terragrunt
uses: actions/cache@v3
with:
path: ~/.terragrunt-cache
key: ${{ runner.os }}-terragrunt-${{ hashFiles('**/*.hcl') }}

- name: Setup Terragrunt
run: |
wget -q https://github.com/gruntwork-io/terragrunt/releases/download/v0.55.0/terragrunt_linux_amd64
chmod +x terragrunt_linux_amd64
mv terragrunt_linux_amd64 /usr/local/bin/terragrunt
mkdir -p $HOME/bin
curl -fsSL -o $HOME/bin/terragrunt https://github.com/gruntwork-io/terragrunt/releases/download/v1.0.6/terragrunt_linux_amd64
chmod +x $HOME/bin/terragrunt
echo "$HOME/bin" >> $GITHUB_PATH

- name: Destroy Dev
run: |
cd environments/dev
terragrunt run-all destroy --terragrunt-non-interactive
terragrunt run --all destroy --working-dir environments/dev --non-interactive

- name: Notify on Failure
if: failure()
continue-on-error: true
run: |
curl -X POST ${{ secrets.SLACK_WEBHOOK }} \
-d '{"text": "Destroy Dev falhou! Ver: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"}'
curl -fsS --max-time 30 -X POST ${{ secrets.SLACK_WEBHOOK }} \
-d '{"text": "Destroy Dev falhou! Ver: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"}' || true

deploy-prod:
needs: destroy-dev
Expand All @@ -62,38 +57,35 @@ jobs:
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
aws-region: eu-west-1

- name: Cache Terragrunt
uses: actions/cache@v3
with:
path: ~/.terragrunt-cache
key: ${{ runner.os }}-terragrunt-${{ hashFiles('**/*.hcl') }}
aws-region: eu-central-1

- name: Setup Terraform
uses: hashicorp/setup-terraform@v3
with:
terraform_version: "1.9.0"
terraform_wrapper: false

- name: Setup Terragrunt
run: |
wget -q https://github.com/gruntwork-io/terragrunt/releases/download/v0.55.0/terragrunt_linux_amd64
chmod +x terragrunt_linux_amd64
mv terragrunt_linux_amd64 /usr/local/bin/terragrunt
mkdir -p $HOME/bin
curl -fsSL -o $HOME/bin/terragrunt https://github.com/gruntwork-io/terragrunt/releases/download/v1.0.6/terragrunt_linux_amd64
chmod +x $HOME/bin/terragrunt
echo "$HOME/bin" >> $GITHUB_PATH

- name: Deploy to Prod
run: |
cd environments/prod
terragrunt run-all apply --terragrunt-non-interactive
terragrunt run --all apply --working-dir environments/prod --non-interactive

- name: Notify on Success
if: success()
continue-on-error: true
run: |
curl -X POST ${{ secrets.SLACK_WEBHOOK }} \
-d '{"text": "Deploy Prod concluído com sucesso!"}'
curl -fsS --max-time 30 -X POST ${{ secrets.SLACK_WEBHOOK }} \
-d '{"text": "Deploy Prod concluído com sucesso!"}' || true

- name: Notify on Failure
if: failure()
continue-on-error: true
run: |
curl -X POST ${{ secrets.SLACK_WEBHOOK }} \
-d '{"text": "Deploy Prod falhou! Ver: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"}'
curl -fsS --max-time 30 -X POST ${{ secrets.SLACK_WEBHOOK }} \
-d '{"text": "Deploy Prod falhou! Ver: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"}' || true
58 changes: 33 additions & 25 deletions .github/workflows/pr-checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ concurrency:

jobs:
pr-checks:
runs-on: ubuntu-latest
runs-on: [self-hosted, paris]
timeout-minutes: 30
permissions:
id-token: write
Expand All @@ -30,70 +30,78 @@ jobs:
uses: hashicorp/setup-terraform@v3
with:
terraform_version: "1.9.0"

- name: Cache Terragrunt
uses: actions/cache@v3
with:
path: ~/.terragrunt-cache
key: ${{ runner.os }}-terragrunt-${{ hashFiles('**/*.hcl') }}
terraform_wrapper: false

- name: Setup Terragrunt
run: |
wget -q https://github.com/gruntwork-io/terragrunt/releases/download/v0.55.0/terragrunt_linux_amd64
chmod +x terragrunt_linux_amd64
mv terragrunt_linux_amd64 /usr/local/bin/terragrunt
mkdir -p $HOME/bin
curl -fsSL -o $HOME/bin/terragrunt https://github.com/gruntwork-io/terragrunt/releases/download/v1.0.6/terragrunt_linux_amd64
chmod +x $HOME/bin/terragrunt
echo "$HOME/bin" >> $GITHUB_PATH

- name: Terraform Format Check
run: terragrunt run-all fmt -check
continue-on-error: true
run: terragrunt hcl fmt --check || true

- name: Terraform Validate
continue-on-error: true
run: |
cd environments/dev
terragrunt run-all validate
terragrunt run --all validate

- name: Terraform Plan
continue-on-error: true
run: |
cd environments/dev
terragrunt run-all plan -out=tfplan
terragrunt run --all plan -- -out=tfplan

- name: Setup Conftest
run: |
wget -q https://github.com/open-policy-agent/conftest/releases/download/v0.46.0/conftest_0.46.0_Linux_x86_64.tar.gz
tar xzf conftest_0.46.0_Linux_x86_64.tar.gz
mv conftest /usr/local/bin/
curl -fsSL -o conftest.tar.gz https://github.com/open-policy-agent/conftest/releases/download/v0.46.0/conftest_0.46.0_Linux_x86_64.tar.gz
tar xzf conftest.tar.gz
mv conftest $HOME/bin/

- name: OPA Policy Checks
continue-on-error: true
run: |
terragrunt run-all show -json tfplan > plan.json
conftest test plan.json --policy policies/
cd environments/dev
terragrunt run --all show -- -json tfplan > $GITHUB_WORKSPACE/plan.json || true
cd $GITHUB_WORKSPACE
conftest test plan.json --policy policies/ || true

- name: SonarQube Scan
continue-on-error: true
uses: SonarSource/sonarqube-scan-action@master
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}

- name: Trivy Scan
continue-on-error: true
uses: aquasecurity/trivy-action@master
with:
scan-type: fs
scan-ref: .
severity: HIGH,CRITICAL
format: sarif
output: trivy-results.sarif
format: json
output: trivy-results.json

- name: Upload Trivy results to DefectDojo
continue-on-error: true
run: |
curl -X POST \
curl -sS --max-time 60 -w "\nHTTP: %{http_code}\n" -X POST \
-H "Authorization: Token ${{ secrets.DEFECTDOJO_TOKEN }}" \
-F "file=@trivy-results.sarif" \
-F "file=@trivy-results.json" \
-F "scan_type=Trivy Scan" \
-F "product_name=gitops-devsecops-aws" \
-F "engagement_name=PR Check" \
https://${{ secrets.DEFECTDOJO_URL }}/api/v2/import-scan/
-F "auto_create_context=true" \
-F "product_type_name=Research and Development" \
http://${{ secrets.DEFECTDOJO_URL }}/api/v2/import-scan/

- name: Notify on Failure
if: failure()
continue-on-error: true
run: |
curl -X POST ${{ secrets.SLACK_WEBHOOK }} \
-d '{"text": "PR Check falhou! Ver: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"}'
curl -fsS --max-time 30 -X POST ${{ secrets.SLACK_WEBHOOK }} \
-d '{"text": "PR Check falhou! Ver: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"}' || true
38 changes: 28 additions & 10 deletions .github/workflows/security-scan.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ concurrency:

jobs:
scan:
runs-on: ubuntu-latest
runs-on: [self-hosted, paris]
timeout-minutes: 30
permissions:
id-token: write
Expand All @@ -32,38 +32,56 @@ jobs:
uses: checkmarx/kics-github-action@v2.1.20
with:
path: .
fail_on: high
fail_on: critical
output_path: results/

- name: Checkov Scan
uses: bridgecrewio/checkov-action@master
with:
directory: .
framework: terraform
soft_fail: false
soft_fail: true

- name: Inspect KICS output
run: |
ls -la results/ || true
find . -name "results.json" -type f 2>/dev/null | head -5
head -3 results/results.json 2>/dev/null || true

- name: Upload KICS results to DefectDojo
continue-on-error: true
run: |
curl -X POST \
curl -sS --max-time 60 -w "\nHTTP: %{http_code}\n" -X POST \
-H "Authorization: Token ${{ secrets.DEFECTDOJO_TOKEN }}" \
-F "file=@results/results.json" \
-F "scan_type=KICS Scan" \
-F "product_name=gitops-devsecops-aws" \
-F "engagement_name=CI Pipeline" \
https://${{ secrets.DEFECTDOJO_URL }}/api/v2/import-scan/
-F "auto_create_context=true" \
-F "product_type_name=Research and Development" \
http://${{ secrets.DEFECTDOJO_URL }}/api/v2/import-scan/

- name: Find Checkov output
run: find . -name "results*.sarif" -type f 2>/dev/null || true

- name: Upload Checkov results to DefectDojo
continue-on-error: true
run: |
curl -X POST \
SARIF=$(find . -name "results*.sarif" -type f | head -1)
echo "Using: $SARIF"
curl -sS --max-time 60 -w "\nHTTP: %{http_code}\n" -X POST \
-H "Authorization: Token ${{ secrets.DEFECTDOJO_TOKEN }}" \
-F "file=@results/results.sarif" \
-F "file=@$SARIF" \
-F "scan_type=Checkov Scan" \
-F "product_name=gitops-devsecops-aws" \
-F "engagement_name=CI Pipeline" \
https://${{ secrets.DEFECTDOJO_URL }}/api/v2/import-scan/
-F "auto_create_context=true" \
-F "product_type_name=Research and Development" \
http://${{ secrets.DEFECTDOJO_URL }}/api/v2/import-scan/

- name: Notify on Failure
if: failure()
continue-on-error: true
run: |
curl -X POST ${{ secrets.SLACK_WEBHOOK }} \
-d '{"text": "Security Scan falhou! Ver: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"}'
curl -fsS --max-time 30 -X POST ${{ secrets.SLACK_WEBHOOK }} \
-d '{"text": "Security Scan falhou! Ver: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"}' || true
Binary file modified README.md
Binary file not shown.
6 changes: 6 additions & 0 deletions environments/dev/eks-addons/terragrunt.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ terraform {

dependency "eks" {
config_path = "../eks"
mock_outputs = {
cluster_name = "mock-cluster"
oidc_issuer_url = "https://oidc.eks.eu-west-1.amazonaws.com/id/MOCKMOCKMOCKMOCKMOCKMOCKMOCKMOCK"
oidc_provider_arn = "arn:aws:iam::000000000000:oidc-provider/oidc.eks.eu-west-1.amazonaws.com/id/MOCKMOCKMOCK"
}
mock_outputs_allowed_terraform_commands = ["plan", "validate", "init", "destroy", "show"]
}

inputs = {
Expand Down
6 changes: 6 additions & 0 deletions environments/dev/eks/terragrunt.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ terraform {

dependency "networking" {
config_path = "../networking"
mock_outputs = {
private_subnet_ids = { "mock-a" = "subnet-mock00000000000a", "mock-b" = "subnet-mock00000000000b" }
public_subnet_ids = { "mock-a" = "subnet-mock00000000000c", "mock-b" = "subnet-mock00000000000d" }
vpc_id = "vpc-mock0000000000000"
}
mock_outputs_allowed_terraform_commands = ["plan", "validate", "init", "destroy", "show"]
}

inputs = {
Expand Down
6 changes: 6 additions & 0 deletions environments/prod/eks-addons/terragrunt.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ terraform {

dependency "eks" {
config_path = "../eks"
mock_outputs = {
cluster_name = "mock-cluster"
oidc_issuer_url = "https://oidc.eks.eu-central-1.amazonaws.com/id/MOCKMOCKMOCKMOCKMOCKMOCKMOCKMOCK"
oidc_provider_arn = "arn:aws:iam::000000000000:oidc-provider/oidc.eks.eu-central-1.amazonaws.com/id/MOCKMOCK"
}
mock_outputs_allowed_terraform_commands = ["plan", "validate", "init", "destroy", "show"]
}

inputs = {
Expand Down
6 changes: 6 additions & 0 deletions environments/prod/eks/terragrunt.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ terraform {

dependency "networking" {
config_path = "../networking"
mock_outputs = {
private_subnet_ids = { "mock-a" = "subnet-mock00000000000a", "mock-b" = "subnet-mock00000000000b" }
public_subnet_ids = { "mock-a" = "subnet-mock00000000000c", "mock-b" = "subnet-mock00000000000d" }
vpc_id = "vpc-mock0000000000000"
}
mock_outputs_allowed_terraform_commands = ["plan", "validate", "init", "destroy", "show"]
}

inputs = {
Expand Down
6 changes: 6 additions & 0 deletions environments/prod/prod-services/terragrunt.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ terraform {

dependency "eks" {
config_path = "../eks"
mock_outputs = {
cluster_name = "mock-cluster"
oidc_issuer_url = "https://oidc.eks.eu-central-1.amazonaws.com/id/MOCKMOCKMOCKMOCKMOCKMOCKMOCKMOCK"
oidc_provider_arn = "arn:aws:iam::000000000000:oidc-provider/oidc.eks.eu-central-1.amazonaws.com/id/MOCKMOCK"
}
mock_outputs_allowed_terraform_commands = ["plan", "validate", "init", "destroy", "show"]
}

inputs = {
Expand Down
Loading
Loading