Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Support from-module parameter #8

Open
osterman opened this issue Nov 22, 2018 · 2 comments
Open

Feature Request: Support from-module parameter #8

osterman opened this issue Nov 22, 2018 · 2 comments

Comments

@osterman
Copy link

osterman commented Nov 22, 2018

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-module directive for each module.

why

  • Terraform init supports -from-module=SOURCE when initializing a module
  • Enables ultra DRY innovation of modules (what terragrunt uses) and would make it easier to drop terragrunt and use astro instead
  • 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]
@dansimau
Copy link
Contributor

dansimau commented Dec 6, 2018

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.

@gerardaus
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants