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

Multiple Terraform States #9

Open
Jamie-BitFlight opened this issue Feb 28, 2018 · 3 comments
Open

Multiple Terraform States #9

Jamie-BitFlight opened this issue Feb 28, 2018 · 3 comments

Comments

@Jamie-BitFlight
Copy link

Hi,
We split out terraform into multiple states.
Can you query multiple terraform s3 states in a single yml deployfish file?

Jamie

@cmalek
Copy link
Collaborator

cmalek commented Feb 28, 2018

We also use many different state files. We usually have at least two that might be needed by deployfish:

  • One that sets up the VPC (for shared resources)
  • One that sets up any remaining resources for the application that have not been defined by the VPC template (for app specific resources)

We import the vpc template into the application template like so:

data "terraform_remote_state" "vpc" {
  backend = "s3"

  config {
    bucket = "terraform-statefiles"
    key    = "vpc-terraform-state"
    region = "us-west-2"
  }
}

Re-output any vpc state that deployfish might need from the application state like so:

output "rds-address-prod" {
  value = "${data.terraform_remote_state.vpc.rds-prod-address}"
}

output "rds-port-prod" {
  value = "${data.terraform_remote_state.vpc.rds-prod-port}"
}

output "elasticache-endpoint-prod" {
  value = "${data.terraform_remote_state.vpc.elasticache-prod-endpoint}"
}

And then have deployfish get all it needs from the application state file.

Would doing something like that solve your needs?

@Jamie-BitFlight
Copy link
Author

Ah yes, that is the workaround I am using currently.

I would love to feature request this though, so that you can repeat the terraform block several times to pull values from multiple terraform states :)

@cmalek
Copy link
Collaborator

cmalek commented Feb 28, 2018

I'm not necessarily opposed to it. We would need to decide a policy on how to resolve what happens if multiple statefiles have outputs with the same name. We will think on it.

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

2 participants