Created
January 23, 2023 20:49
-
-
Save TWinsnes/b4a79583e02c56f7dc5fe06eed2a0346 to your computer and use it in GitHub Desktop.
Adding multiple accounts to have using terraform and for_each
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# more info about for_each here: https://developer.hashicorp.com/terraform/language/meta-arguments/for_each | |
provider "hava" { | |
# alternatively use the HAVA_TOKEN environment variable | |
api_token = "xxx" | |
} | |
local ( | |
accounts = toset([] | |
{ | |
name = "Account 1" | |
role_arn = "arn:aws:iam::12341234:role/HavaRO" | |
}, | |
{ | |
name = "Account 2" | |
role_arn = "arn:aws:iam::12345123:role/HavaRO" | |
} | |
]) | |
) | |
resource "hava_source_aws_car_resource" "example" { | |
for_each = local.accounts | |
name = each.value.name | |
role_arn = each.value.role_arn | |
external_id = "0934086b5ab9970205878266249aebd9" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment