diff --git a/.github/workflows/terraform-lint-format.yml b/.github/workflows/terraform-lint-format.yml new file mode 100644 index 0000000..8ee3814 --- /dev/null +++ b/.github/workflows/terraform-lint-format.yml @@ -0,0 +1,43 @@ +name: Terraform Lint and Format + +on: + push: + paths: + - '**/*.tf' + - '**/*.tfvars' + pull_request: + paths: + - '**/*.tf' + - '**/*.tfvars' + +jobs: + terraform: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Setup Terraform + uses: hashicorp/setup-terraform@v3 + + - name: Terraform Format + run: terraform fmt -check -recursive + + - name: Terraform Init and Validate + run: | + find ./environments -type f \( -name "*.tf" -o -name "*.tfvars" \) -exec dirname {} \; | sort -u | while read dir; do + cd "$dir" + terraform init -backend=false + terraform validate + cd - + done + + - name: Run tflint + uses: terraform-linters/setup-tflint@v4 + + - name: Run tflint + run: | + find ./environments -type f \( -name "*.tf" -o -name "*.tfvars" \) -exec dirname {} \; | sort -u | while read dir; do + cd "$dir" + tflint + cd - + done diff --git a/environments/prod/main.tf b/environments/prod/main.tf index 53a6a61..549b01b 100644 --- a/environments/prod/main.tf +++ b/environments/prod/main.tf @@ -69,7 +69,7 @@ module "route53" { { name = "www" type = "CNAME" - ttl = 300 + ttl = 301 records = ["dpop20p5u4112.cloudfront.net"] } ]