diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index a638289..e03a59a 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -1,5 +1,23 @@ = Changelog +== 1.6.0 + + * fix: pass the default AWS provider explicitly from tfctl generated configuration. + This fixes provider inheritance issues when using multiple providers which + was introduced in 1.3.0. You may need to add a terraform block with + `required_provides` to your profiles if you don't have it defined already. + Terraform will warn about this during `init`. Here's an example block: + +---- +terraform { + required_providers { + aws = { + source = "hashicorp/aws" + } + } +} +---- + == 1.5.0 * feat: support for setting default tags at AWS provider level. (Thanks @patrickli) diff --git a/examples/control_tower/modules/s3-bucket/main.tf b/examples/control_tower/modules/s3-bucket/main.tf index 1770111..81c7211 100644 --- a/examples/control_tower/modules/s3-bucket/main.tf +++ b/examples/control_tower/modules/s3-bucket/main.tf @@ -2,3 +2,7 @@ resource aws_s3_bucket bucket { bucket = var.name acl = "private" } + +output "arn" { + value = aws_s3_bucket.bucket.arn +} diff --git a/examples/control_tower/profiles/example-profile/main.tf b/examples/control_tower/profiles/example-profile/main.tf index 26a3b61..d081e62 100644 --- a/examples/control_tower/profiles/example-profile/main.tf +++ b/examples/control_tower/profiles/example-profile/main.tf @@ -1,4 +1,11 @@ +resource "random_pet" "bucket_prefix" { +} + module "bucket" { source = "../../modules/s3-bucket" - name = "${local.account_id}-${local.account["data"]["example_bucket_name"]}" + name = "${random_pet.bucket_prefix.id}-${local.account["data"]["example_bucket_name"]}" +} + +output "bucket_arn" { + value = module.bucket.arn } diff --git a/examples/control_tower/profiles/example-profile/terraform.tf b/examples/control_tower/profiles/example-profile/terraform.tf new file mode 100644 index 0000000..f2702bf --- /dev/null +++ b/examples/control_tower/profiles/example-profile/terraform.tf @@ -0,0 +1,7 @@ +terraform { + required_providers { + aws = { + source = "hashicorp/aws" + } + } +} diff --git a/examples/control_tower/profiles/example-profile/variables.tf b/examples/control_tower/profiles/example-profile/variables.tf index 8b8261b..87b2caa 100644 --- a/examples/control_tower/profiles/example-profile/variables.tf +++ b/examples/control_tower/profiles/example-profile/variables.tf @@ -6,7 +6,7 @@ variable "config" { locals { config = jsondecode(var.config) - account_id = "${data.aws_caller_identity.current.account_id}" + account_id = data.aws_caller_identity.current.account_id # get account configuration from tfctl config - account = [ for account in local.config["accounts"]: account if account["id"] == local.account_id ][0] + account = [for account in local.config["accounts"] : account if account["id"] == local.account_id][0] } diff --git a/lib/tfctl/generator.rb b/lib/tfctl/generator.rb index 39827e0..b78dbc9 100644 --- a/lib/tfctl/generator.rb +++ b/lib/tfctl/generator.rb @@ -80,8 +80,11 @@ def make(account:, config:) profile_block = { 'module' => { profile => { - 'source' => "../../../profiles/#{profile}", - 'config' => '${var.config}', + 'source' => "../../../profiles/#{profile}", + 'config' => '${var.config}', + 'providers' => { + 'aws' => 'aws', + }, }, }, } diff --git a/lib/tfctl/version.rb b/lib/tfctl/version.rb index 74b3ae7..dd08f18 100644 --- a/lib/tfctl/version.rb +++ b/lib/tfctl/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module Tfctl - VERSION = '1.5.0' + VERSION = '1.6.0' end