Feature Request: Support `from-module` parameter
First of all, I love the direction of this utility. It's a generalized approach to orchestrated complex, multi-phased applies for terraform. It's a nice alternative to terragrunt that's less opinionated. We use a similar tool designed for helm that's called helmfile.
what
- Support an
init.from-moduledirective for each module.
why
- Terraform
initsupports-from-module=SOURCEwhen initializing a module - Enables ultra DRY innovation of modules (what
terragruntuses) and would make it easier to dropterragruntand useastroinstead - Rapidly define a complex architecture by referring to root module invocations
example
This example would copy the /aws/app module to core/app and then invoke the commands accordingly
modules:
- name: app
init:
from-module: https://github.com/cloudposse/terraform-root-modules//aws/app
path: core/app
deps:
- module: users
- module: vpc
remote:
backend_config:
bucket: acme-terraform-states
key: "{{.aws_region}}/app-{{.environment}}.tfstate"
region: us-east-1
variables:
- name: region
- name: environment
values: [dev, prod]
I am all for this.
I'm even thinking of a generalised approach, i.e.: within each terraform block, have a way to specify arbitrary arguments to each Terraform command:
E.g.:
modules:
- name: app
terraform:
flags:
init:
- from-module=https://github.com/cloudposse/terraform-root-modules//aws/app
path: core/app
deps:
- module: users
- module: vpc
remote:
backend_config:
bucket: acme-terraform-states
key: "{{.aws_region}}/app-{{.environment}}.tfstate"
region: us-east-1
variables:
- name: region
- name: environment
values: [dev, prod]
Then you get access to all the underlying Terraform flags. For example, one could increase parallelism for all apply commands by doing:
terraform:
flags:
apply:
- parallelism=20
modules:
- name: app
terraform:
flags:
init:
- from-module=https://github.com/cloudposse/terraform-root-modules//aws/app
path: core/app
deps:
- module: users
- module: vpc
remote:
backend_config:
bucket: acme-terraform-states
key: "{{.aws_region}}/app-{{.environment}}.tfstate"
region: us-east-1
variables:
- name: region
- name: environment
values: [dev, prod]
Only consideration there is that users could potentially cause an issue by changing something astro doesn't expect under the hood. I can't see any catastrophic cases of that right now but it could become a problem.
This is an important feature for greater levels of composition and versioning of infrastructure. Would love to see this implemented or help in the implementation.
If you could init from a module, would it negate the need for the "path" attribute?
Initially when I looked at the project, I was under the impression that the "path" attribute would act like the -from-import functionality of terraform.