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

feat: allow variables to specify values in main.tf #1043

Merged
merged 3 commits into from
Apr 26, 2024

Conversation

jakeyheath
Copy link
Contributor

@jakeyheath jakeyheath commented Apr 25, 2024

Summary

This PR allows users to be able to change the default "locals.*" variable to something that is known ahead of time. This is handy when we want to code generate infra stacks that are very similar and we know most of the values ahead of time. Also, filters out non-existent variables on the module source. Fixes #935

Example:

module_source:  github.com/chanzuckerberg/cztack//aws-aurora-postgres?ref=main
variables: 
  - env=var.tags.env
  - owner=var.tags.owner
  - project
  - blah # will be filtered out

Would generate:

module "aws-aurora-postgres" {
  source                = "github.com/chanzuckerberg/cztack//aws-aurora-postgres?ref=main"
  database_name         = local.database_name
  database_password     = local.database_password
  database_subnet_group = local.database_subnet_group
  database_username     = local.database_username
  env                   = var.tags.env
  owner                 = var.tags.owner
  project               = local.project
  service               = local.service
  vpc_id                = local.vpc_id



}

Test Plan

Say unittests, or list out steps to verify changes.

References

(Optional) Additional links to provide more context.

@jakeyheath jakeyheath requested a review from a team as a code owner April 25, 2024 17:05
@jakeyheath jakeyheath requested review from jjb007, alldoami and hspitzley-czi and removed request for a team April 25, 2024 17:05
@jakeyheath jakeyheath merged commit 4ca082b into main Apr 26, 2024
5 checks passed
@jakeyheath jakeyheath deleted the heathj/prepopulate-vars branch April 26, 2024 21:44
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

Successfully merging this pull request may close these issues.

bug: Invalid variables aren't filtered out
2 participants