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

Fix literal interpretation and/or accept strings for providers. #30777

Closed
AzySir opened this issue Mar 31, 2022 · 2 comments
Closed

Fix literal interpretation and/or accept strings for providers. #30777

AzySir opened this issue Mar 31, 2022 · 2 comments

Comments

@AzySir
Copy link

AzySir commented Mar 31, 2022

After having an amazing time Googling the absence of dynamic providers and coming through Github issues such as #19932

I was forced to try a magic work around that looked like this -


resource "aws_config_configuration_recorder" "config_recorder" {
  for_each = toset([ for key, value in var.enabled_regions : "aws.${value}"])
  provider = each.value
  name     = "config_recorder"
  role_arn = var.config_recorder_role_arn

  recording_group {
    all_supported                 = true
    include_global_resource_types = true
  }
}

However this does not work because Terraform reads the each.value as a literal provider. So I would've thought adding in "${each.value}"' would work but this also does not allow strings. When I tried to add a provider such as "aws.eu-west-2"` it gives me the below warning -

Warning: Quoted references are deprecated
│
│   on ../main.tf line 3, in resource "aws_config_configuration_recorder" "config_recorder":
│    3:   provider = "aws.eu-west-2"
│
│ In this context, references are expected literally rather than in quotes. Terraform 0.11 and earlier required quotes, but quoted references are
│ now deprecated and will be removed in a future version of Terraform. Remove the quotes surrounding this reference to silence this warning.

Are we able to change this to allow for strings to be passed through?

For my use case is that we need to deploy AWS Config into every single region and unfortunately AWS does not provide anything here to handle this - so I turn to Terraform for assistance and this is also now letting me down unfortunately! If we could rectify this then surely this could be a quick work around for some more clear Terraform code in the "Dynamic Provider" issue

I welcome any assistance thank you!

@AzySir AzySir added enhancement new new issue not yet triaged labels Mar 31, 2022
@jbardin
Copy link
Member

jbardin commented Mar 31, 2022

Hi @AzySir,

Providers currently need to be statically defined so that they can be resolved when decoding the configuration. We are tracking the possibility of allowing more dynamic assignments in the feature request here: #25244

Thanks!

Duplicate of #25244

@jbardin jbardin closed this as completed Mar 31, 2022
@crw crw removed the new new issue not yet triaged label Mar 31, 2022
@github-actions
Copy link
Contributor

github-actions bot commented May 1, 2022

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 1, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants