What it’s the best design pattern to use Terrafile in Multi Environment?
For exemple, for dev environment (dev branch) i want my terrafile pointing to modules develop branch, but in production branch i want terrafile pointing to master branch in modules.
Interesting. That’s a cleaner approach when using the Terrafile.
So the Terrafile is a DSL, but at the end of the day it’s actually just ruby. Which means you have access to the full power of ruby in it. For example:
Terrafile
if Terraspace.env == "dev"
mod "sg", source: "terraform-aws-modules/security-group/aws", version: "4.4.0"
else # IE: prod
mod "sg", source: "terraform-aws-modules/security-group/aws", version: "4.3.0"
end
It would be also cool if there was a group syntax similar to bundler like so though:
group :dev do
mod "sg", source: "terraform-aws-modules/security-group/aws", version: "4.4.0"
end
group :prod do
mod "sg", source: "terraform-aws-modules/security-group/aws", version: "4.3.0"
end
Will consider PRs. No sweat either way, of course.