Instantiating Multiple Providers with a loop
### Current Terraform Version <!--- Run `terraform -v` to show the version, and paste the result between the ``` marks below. This will record which version was current at the time of your feature request, to help manage the request backlog. If you're not using the latest version, please check to see if something related to your request has already been implemented in a later version. --> ``` Terraform v0.11.11 ``` ### Use-cases In my current situation, I am using the AWS provider so I will scope this feature request to that specific provider, although this may extend to other providers as well. I am attempting to create resources in multiple AWS accounts. The number of the accounts ranges from 0....x and will be dynamic. I would like to be able to instantiate multiple providers which can assume a role in each account, and in turn, create resources with the associated provider without hard-coding providers for each subsequent account. For example, something like this: ``` variable "accounts" { type = "list" default = ["123456789012", "210987654321"] } variable "names" { type = "map" default = { "123456789012" = "foo" "210987654321" = "bar" } } provider "aws" { count = "${length(var.accounts)}" alias = "${lookup(var.names, element(var.accounts, count.index))}" assume_role { role_arn = "arn:aws:iam::${element(var.accounts, count.index)}:role/ASSUMEDROLE" } resource "aws_instance" "web" { count = "${length(var.accounts)
Posted by JakeNeyer on Jan 7, 2019, 9:16 PM
Tags
Related issues
- struct's lifetime requirements can be bypassed via covariant field assignment
- Proposal to Reorganize the Moderation Team and Review Moderation Policies
- Progressive FPS degradation appears to be related to dota2.com — blocking the domain prevents the performance loss
- proposal: container/...: generic collection types
- Better Custom Endpoint BYOK
- A concrete policy for backward compatibility until Godot 5.0
Raise real-world problems, find people facing the same issue, and discuss solutions.4,000 issues0 comments
github (Other)
struct's lifetime requirements can be bypassed via covariant field assignment
Proposal to Reorganize the Moderation Team and Review Moderation Policies
Progressive FPS degradation appears to be related to dota2.com — blocking the domain prevents the performance loss
proposal: container/...: generic collection types
Better Custom Endpoint BYOK
A concrete policy for backward compatibility until Godot 5.0
New MTP models not supported
Tracking: 429 / Capacity Issues
Instantiating Multiple Providers with a loop
### Current Terraform Version <!--- Run `terraform -v` to show the version, and paste the result between the ``` marks below. This will record which version was current at the time of your feature request, to help manage the request backlog. If you're not using the latest version, please check to see if something related to your request has already been implemented in a later version. --> ``` Terraform v0.11.11 ``` ### Use-cases In my current situation, I am using the AWS provider so I will scope this feature request to that specific provider, although this may extend to other providers as well. I am attempting to create resources in multiple AWS accounts. The number of the accounts ranges from 0....x and will be dynamic. I would like to be able to instantiate multiple providers which can assume a role in each account, and in turn, create resources with the associated provider without hard-coding providers for each subsequent account. For example, something like this: ``` variable "accounts" { type = "list" default = ["123456789012", "210987654321"] } variable "names" { type = "map" default = { "123456789012" = "foo" "210987654321" = "bar" } } provider "aws" { count = "${length(var.accounts)}" alias = "${lookup(var.names, element(var.accounts, count.index))}" assume_role { role_arn = "arn:aws:iam::${element(var.accounts, count.index)}:role/ASSUMEDROLE" } resource "aws_instance" "web" { count = "${length(var.accounts)
Comments (0)
No comments yet. Start the discussion.