New GitHub Actions for Terraform deployment.
New GitHub Actions for Terraform deployment.
Change Summary
This commit introduces a new CI/CD pipeline for deploying and planning infrastructure changes using Terragrunt. Two new GitHub Actions workflows (deploy.yml and plan.yml) have been added, and updates have been made to configuration files to support these workflows. Additionally, a new mise.toml file has been added to manage tool versions.
Technical Details
- deploy.yml:
- Triggers on
workflow_dispatchandpushto themainbranch. - Performs HCL formatting checks using
gruntwork-io/terragrunt-action. - Configures AWS credentials and runs
terragrunt applyin theIaC/production/homelabdirectory.
- Triggers on
- plan.yml:
- Triggers on
workflow_dispatchand variouspull_requestevents on themainbranch. - Performs HCL formatting checks.
- Configures AWS credentials and runs
terragrunt planin theIaC/production/homelabdirectory.
- Triggers on
- kube.hcl:
- Updates the
config_pathfor the Kubernetes provider to usepathexpandfor better compatibility.
- Updates the
- mise.toml:
- Specifies versions for
terragruntandopentofuto ensure consistent tool versions across environments.
- Specifies versions for
Key Learnings & Insights
- Automation of Infrastructure Changes:
- The introduction of GitHub Actions workflows automates the deployment and planning of infrastructure changes, reducing manual effort and potential for human error.
- Consistency and Validation:
- HCL formatting checks ensure that the configuration files are consistently formatted, improving readability and maintainability.
- Tool Version Management:
- Using
mise.tomlto manage tool versions ensures that all developers and CI environments use the same versions, avoiding compatibility issues.
- Using
Impact Assessment
- Efficiency:
- Automated workflows streamline the process of deploying and planning infrastructure changes, saving time and reducing the risk of errors.
- Maintainability:
- Consistent tool versions and formatted configuration files improve the maintainability of the infrastructure code.
- Security:
- Proper configuration of AWS credentials and use of role-based access control enhance the security posture of the infrastructure deployment process.
Developer Notes
- Gotchas:
- Ensure that all required secrets (
TS_AUTH_KEYandKUBE_CONFIG) are correctly set up in the GitHub repository settings.
- Ensure that all required secrets (
- Future Improvements:
- Consider adding additional checks or steps to the workflows, such as linting or security scans, to further enhance the quality and security of the infrastructure code.
- Environment Variables:
- Be mindful of the
working_direnvironment variable, as it dictates where the Terragrunt commands are executed. Any changes to this directory path will require updates to the workflows.
- Be mindful of the
This post is licensed under CC BY 4.0 by the author.