Update GitHub workflows for Terraform actions.
Update GitHub workflows for Terraform actions.
Change Summary
This update modifies the GitHub Actions workflows for deploying and planning infrastructure changes. Specifically, it refines the triggering conditions and adjusts the steps within these workflows to enhance the deployment process.
Technical Details
- deploy.yml
- Triggers: The workflow now triggers on pushes to the
mainbranch specifically when files in theIaC/directory or thedeploy.ymlitself are modified. - Steps:
- Renamed the step from
Install Terragrunt and OpenTofutoTerragrunt Apply. - The action
gruntwork-io/terragrunt-actionis used with the specific commit95fc057922e3c3d4cc021a81a213f088f333ddefto ensure consistency. - The
tg_diris set to the environment variableworking_dir.
- Renamed the step from
- Triggers: The workflow now triggers on pushes to the
- plan.yml
- Triggers: Similar to
deploy.yml, this workflow now triggers on pull requests targeting themainbranch and when files in theIaC/directory or theplan.ymlitself are modified. - Steps:
- Renamed the step from
Install Terragrunt and OpenTofutoTerragrunt Plan. - Uses the same
gruntwork-io/terragrunt-actionwith the commit95fc057922e3c3d4cc021a81a213f088f333ddef. - The
tg_diris set to the environment variableworking_dir.
- Renamed the step from
- Triggers: Similar to
Key Learnings & Insights
- Granular Triggers: By specifying paths in the trigger conditions, the workflows become more efficient, running only when relevant files are changed. This reduces unnecessary executions and saves resources.
- Step Clarity: Renaming steps to
Terragrunt ApplyandTerragrunt Planprovides clearer intent and improves readability for other developers. - Version Pinning: Using a specific commit for the
gruntwork-io/terragrunt-actionensures that the action version remains consistent across different workflow executions, reducing the risk of unexpected behavior due to updates in the action.
Impact Assessment
- Efficiency: The workflows will now run less frequently, only when necessary, leading to reduced execution times and resource usage.
- Clarity: The renamed steps make the workflows more understandable, aiding in maintenance and future updates.
- Consistency: Pinning the action version mitigates the risk of breaking changes introduced by future updates to the action.
Developer Notes
- Gotchas: Ensure that the
working_direnvironment variable is correctly set in your GitHub Actions environment to avoid errors during execution. - Edge Cases: Consider handling scenarios where the
IaC/directory might not contain any changes but other critical files do. Ensure that the workflow logic accounts for such cases if needed. - Future Improvements: Explore the possibility of further optimizing the workflows by incorporating caching mechanisms for dependencies or intermediate results to speed up execution times.
This post is licensed under CC BY 4.0 by the author.