{"id":26160824,"url":"https://github.com/felipe-loka/terraform-ci-cd","last_synced_at":"2026-05-28T11:31:07.731Z","repository":{"id":281188631,"uuid":"944493663","full_name":"felipe-loka/terraform-ci-cd","owner":"felipe-loka","description":null,"archived":false,"fork":false,"pushed_at":"2025-04-15T14:25:37.000Z","size":61,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-25T23:27:13.300Z","etag":null,"topics":["cicd","github-ac","terraform"],"latest_commit_sha":null,"homepage":"","language":"HCL","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/felipe-loka.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-03-07T12:51:06.000Z","updated_at":"2025-04-15T14:25:41.000Z","dependencies_parsed_at":"2025-03-10T15:23:37.240Z","dependency_job_id":null,"html_url":"https://github.com/felipe-loka/terraform-ci-cd","commit_stats":null,"previous_names":["felipe-loka/terraform-terragrunt-ci-cd","felipe-loka/terraform-ci-cd"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/felipe-loka/terraform-ci-cd","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/felipe-loka%2Fterraform-ci-cd","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/felipe-loka%2Fterraform-ci-cd/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/felipe-loka%2Fterraform-ci-cd/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/felipe-loka%2Fterraform-ci-cd/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/felipe-loka","download_url":"https://codeload.github.com/felipe-loka/terraform-ci-cd/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/felipe-loka%2Fterraform-ci-cd/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33607334,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-05-28T02:00:06.440Z","response_time":99,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cicd","github-ac","terraform"],"created_at":"2025-03-11T12:21:07.773Z","updated_at":"2026-05-28T11:31:07.704Z","avatar_url":"https://github.com/felipe-loka.png","language":"HCL","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Terraform CI-CD\nThis is a demo repository to showcase a possible Terraform CI/CD.\n\nIt follows the principle that CI/CD should not commit changes in your branch and you should be aware of errors before merging your Terraform code (CI checks) and fixing yourself.\n\n## Dependencies\nThe CI/CD uses several tools to validate your Terraform code. It's expected that you have them installed locally.\n\n- [Terraform](https://www.terraform.io/): Terraform is used to run common terraform commands, such as `terraform init`, `terraform plan`, `terraform apply`, `terraform providers lock`, `terraform validate`.\n- [Tflint](https://github.com/terraform-linters/tflint): Tflint check possible errors and misconfigurations (e.g. EC2 instance types that do not exist), enforce best practices and naimng conventions. It uses the [tflint-ruleset-aws](https://github.com/terraform-linters/tflint-ruleset-aws) to enforce AWS best practices. It's configured via the `.tflint.hcl` file.\n- [Terraform-docs](https://github.com/terraform-docs/terraform-docs/): Creates automatic markdown documentation for the terraform code and Terraform modules. It's being configured via the `.terraform-docs.yaml` file.\n- [Trivy](https://github.com/aquasecurity/trivy): Finds vulnerabilities, misconfigurations and securities issues in the Terraform code. It's being configured via the `trivy.yaml` file.\n\nThis repository uses [Devbox](https://www.jetify.com/devbox) to manage the Development environment so you can install all needed tools just running `devbox shell`.\n\n## Directory Structure\n\n```\n├── backend.tf    # Defines S3-based backend to store Terraform States\n├── config        # Account-Region based backend configuration (S3 bucket + DynamoDB table)\n├── modules       # Custom Terraform modules that will be used by the root Terraform project\n├── vars          # Account-Region based files to declaratively define variables values\n```\n\nThis project follows an Account-Region based deployment, i.e. an environment is treated as the combination of AWS Accont and AWS Region (e.g. us-east-1 resources in account 111111111111 is treated as a single environment).\n\n\nPS: If you DO NOT intend to use terraform modules, you should set `recursive.enabled` value on file `.terraform-docs.yml` to `false`, otherwise the following error will be seen:\n\n```\n::debug working_dir=.\n::debug config_file=.terraform-docs.yml\n::debug output_mode=inject\n::debug output_file=README.md\n::debug terraform-docs markdown table --config .terraform-docs.yml --output-mode inject --output-file README.md --output-template \u003c!-- BEGIN_TF_DOCS --\u003e\n{{ .Content }}\n\u003c!-- END_TF_DOCS --\u003e .\nError: stat modules: no such file or directory\n```\n\n## How does this CI/CD work?\nThere is a custom GitHub Actions (`./github/actions/terraform/action.yaml` file) action that is used to run terraform plan and apply commands in a given environment, please check the `./github/workflows/main.yaml` file to understand how this is being used. A `ci` Job was also created to validate formating, linting and security issues.\n\nThe best way to fully understand the CI/CD is to check its executions. Check the:\n- [PR to create simple SQS queue](https://github.com/felipe-loka/terraform-ci-cd/pull/6) to see the CI in action.\n- [PR to create an EC2 module](https://github.com/felipe-loka/terraform-ci-cd/pull/8) to see the CI in action.\n\n## How to fix problems that appear during CI?\n\n|        CI failures       |                                                      Command                                                     |\n|:------------------------:|:----------------------------------------------------------------------------------------------------------------:|\n|       terraform fmt      | `terraform fmt -recursive`                                                                                       |\n| Trivy scan               | ` trivy config . --severity CRITICAL,HIGH --quiet \u0026\u0026 cat trivy-result.txt`                                         |\n| terraform-docs           | `terraform-docs .`                                                                                               |\n| terraform providers lock | `terraform providers lock -platform=linux_amd64 -platform=darwin_amd64 -platform=darwin_arm64` |\n| tflint                   | `tflint --init \u0026\u0026 tflint --recursive`                                                                            |\n|                          |                                                                                                                  |\n|                          |                                                                                                                  |\n\n## Pipeline\nThe deployment pipeline uses [GitHub Actions Environment](https://docs.github.com/en/actions/managing-workflow-runs-and-deployments/managing-deployments/managing-environments-for-deployment) to control deployment to environment (notice that `apply` jobs uses GitHub Actions Environment). We can also set up rules to deploy only to production after a manual approval.\n\n![Pipeline](./docs/pipeline.png)\n\n\u003c!-- BEGIN_TF_DOCS --\u003e\n## Requirements\n\n| Name | Version |\n|------|---------|\n| \u003ca name=\"requirement_terraform\"\u003e\u003c/a\u003e [terraform](#requirement\\_terraform) | ~\u003e 1.11.0 |\n| \u003ca name=\"requirement_aws\"\u003e\u003c/a\u003e [aws](#requirement\\_aws) | ~\u003e 5.90 |\n\n## Providers\n\n| Name | Version |\n|------|---------|\n| \u003ca name=\"provider_aws\"\u003e\u003c/a\u003e [aws](#provider\\_aws) | 5.90.0 |\n\n## Modules\n\nNo modules.\n\n## Resources\n\n| Name | Type |\n|------|------|\n| [aws_sqs_queue.terraform_queue](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/sqs_queue) | resource |\n\n## Inputs\n\n| Name | Description | Type | Default | Required |\n|------|-------------|------|---------|:--------:|\n| \u003ca name=\"input_aws_region\"\u003e\u003c/a\u003e [aws\\_region](#input\\_aws\\_region) | Region to deploy the resources | `string` | n/a | yes |\n| \u003ca name=\"input_queue_name\"\u003e\u003c/a\u003e [queue\\_name](#input\\_queue\\_name) | Queue name to be created | `string` | n/a | yes |\n\n## Outputs\n\nNo outputs.\n\u003c!-- END_TF_DOCS --\u003e","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffelipe-loka%2Fterraform-ci-cd","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffelipe-loka%2Fterraform-ci-cd","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffelipe-loka%2Fterraform-ci-cd/lists"}