Terraform formatting #3
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| on: | |
| pull_request: | |
| branches: [main] | |
| push: | |
| branches: [main] | |
| jobs: | |
| terraform-validation: | |
| name: Terraform Validation | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - name: Setup Terraform | |
| uses: hashicorp/setup-terraform@v3 | |
| - name: Terraform Format Check | |
| id: fmt | |
| run: terraform fmt -check -recursive operations/deployment/terraform/aws/ | |
| continue-on-error: true | |
| - name: Create mock provider.tf | |
| run: | | |
| cat > operations/deployment/terraform/aws/provider.tf << 'EOF' | |
| terraform { | |
| required_providers { | |
| aws = { | |
| source = "hashicorp/aws" | |
| version = "~> 5.0" | |
| } | |
| random = { | |
| source = "hashicorp/random" | |
| version = ">= 2.2" | |
| } | |
| kubernetes = { | |
| source = "hashicorp/kubernetes" | |
| version = ">= 2.22" | |
| } | |
| } | |
| } | |
| provider "aws" { | |
| region = "us-east-1" | |
| skip_credentials_validation = true | |
| skip_requesting_account_id = true | |
| skip_metadata_api_check = true | |
| } | |
| provider "aws" { alias = "ec2" region = "us-east-1" skip_credentials_validation = true skip_requesting_account_id = true skip_metadata_api_check = true } | |
| provider "aws" { alias = "r53" region = "us-east-1" skip_credentials_validation = true skip_requesting_account_id = true skip_metadata_api_check = true } | |
| provider "aws" { alias = "elb" region = "us-east-1" skip_credentials_validation = true skip_requesting_account_id = true skip_metadata_api_check = true } | |
| provider "aws" { alias = "efs" region = "us-east-1" skip_credentials_validation = true skip_requesting_account_id = true skip_metadata_api_check = true } | |
| provider "aws" { alias = "vpc" region = "us-east-1" skip_credentials_validation = true skip_requesting_account_id = true skip_metadata_api_check = true } | |
| provider "aws" { alias = "rds" region = "us-east-1" skip_credentials_validation = true skip_requesting_account_id = true skip_metadata_api_check = true } | |
| provider "aws" { alias = "aurora" region = "us-east-1" skip_credentials_validation = true skip_requesting_account_id = true skip_metadata_api_check = true } | |
| provider "aws" { alias = "ecs" region = "us-east-1" skip_credentials_validation = true skip_requesting_account_id = true skip_metadata_api_check = true } | |
| provider "aws" { alias = "db_proxy" region = "us-east-1" skip_credentials_validation = true skip_requesting_account_id = true skip_metadata_api_check = true } | |
| provider "aws" { alias = "redis" region = "us-east-1" skip_credentials_validation = true skip_requesting_account_id = true skip_metadata_api_check = true } | |
| provider "aws" { alias = "eks" region = "us-east-1" skip_credentials_validation = true skip_requesting_account_id = true skip_metadata_api_check = true } | |
| provider "aws" { alias = "ecr" region = "us-east-1" skip_credentials_validation = true skip_requesting_account_id = true skip_metadata_api_check = true } | |
| provider "aws" { alias = "waf" region = "us-east-1" skip_credentials_validation = true skip_requesting_account_id = true skip_metadata_api_check = true } | |
| provider "kubernetes" { | |
| alias = "eks" | |
| host = null | |
| cluster_ca_certificate = null | |
| token = null | |
| } | |
| EOF | |
| - name: Create mock terraform.tfvars | |
| run: | | |
| cat > operations/deployment/terraform/aws/terraform.tfvars << 'EOF' | |
| aws_resource_identifier = "test-repo-branch" | |
| aws_resource_identifier_supershort = "test-repo-branch" | |
| app_repo_name = "test-repo" | |
| app_org_name = "test-org" | |
| app_branch_name = "test-branch" | |
| ops_repo_environment = "deployment" | |
| app_install_root = "/home/ubuntu" | |
| EOF | |
| - name: Terraform Init | |
| id: init | |
| run: terraform -chdir=operations/deployment/terraform/aws/ init -backend=false | |
| - name: Terraform Validate | |
| id: validate | |
| run: terraform -chdir=operations/deployment/terraform/aws/ validate | |
| - name: Comment Format Check Result | |
| if: always() && steps.fmt.outcome == 'failure' && github.event_name == 'pull_request' | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| github.rest.issues.createComment({ | |
| issue_number: context.issue.number, | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| body: '⚠️ Terraform formatting issues detected. Run `terraform fmt -recursive operations/deployment/terraform/aws/` to fix.' | |
| }) |