kops: Terraform output needs an option to exclude the provider block

Since one of the primary purposes of the Terraform output is to fit into an existing TF environment, the provider block is likely to already exist. It would be great if there were a simple flag to --include-provider=[true|false].

It may even make sense to default to false given what I assume to be the more common workflow.

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 1
  • Comments: 18 (10 by maintainers)

Most upvoted comments

Odds are if someone is using TF output from Kops they’re already using TF and have a provider with a region specified. Given that, my thought was that the block itself could be optional because what Kops outputs may not be exactly right for the user (ie. they have access keys being passed to the provider, or an alias).

The block is definitely needed, it’s just a question of where it comes from.

This can be easily done using terrsform itself, not sure putting that logic inside kops will not over complicate things. kops should keep things simple.

Terraform supports overrides nativelly. So you could put an override.tf file in the same directory where kops outputs the terraform confgs. The override.tf file could contain something like:

provider "aws" {
  region = "us-east-1"
  access_key = "XXXXXXXXXXXXXXXXXXXX"
  secret_key = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
}

That’s it, now when you apply the configs, terraform will know to use your provider instead of kops’s one. In my case I do lot’s of overrides without affecting kops generated configs whatsoever. Works for me for long time without issues.

Read more about terraform overrides: https://www.terraform.io/docs/configuration/override.html