Hi,
“terraform apply” on terraform 0.13.0beta2 always ask yes/no confirmation to read data source. It is by design ?
It’s right to always read data source to allow depends_on extended support, but why asking for confirmation as this does not produce any changes to the infra ?
I think you are talking about the Terraform Registry community providers beta rather than the Terraform CLI v0.13.0 beta. Is that right?
If so, the community providers beta is a separate process than Terraform v0.13.0 beta which is being run by the Terraform Registry team at HashiCorp. I believe they’ve halted new beta applications for the moment because they have enough participants for the first round of feedback. The beta may reopen again in the future if they need some additional feedback, but that’s not being driven by the Terraform Core team (which is the team I work on) and so I can’t say for certain when or if that will happen. There’ll be guidance on the Terraform Registry site as the situation changes, though.
the two processes you speak about (Terraform community providers vs Terraform CLI) refers to providers or to terraform cli itself ?
I can change this behavior setting provider using Explicit Provider Source Locations ? I cannot find aws provider specifications. Reading your “Draft: Upgrading to Terraform v0.13” I thought default was hashicorp… not so clear for me.
As is often the case with prerelease builds, we got lots of good feedback on beta3 about some remaining rough edges and so we’re holding RC1 in order to respond to the subset of that feedback that must be included before v0.13.0 final. We expect to release RC1 once that work is complete.
I was really excited to get my hands on this as I was hoping it would finally resolve one of my issues around for_each and modules. I have a use case where I want to ingest a json template with a series of AWS account IDs, and then invoke a module to create an IAM role in each of the accounts. To do this requires assuming a role in each account, so upon each invocation the module should read the role_arn and then use that to deploy the resources. Unfortunately it appears the release candidate can’t do that:
Error: Module does not support for_each
on main.tf line 4, in module "remote_role":
4: for_each = local.data
Module "remote_role" cannot be used with for_each because it contains a nested
provider configuration for "aws", at modules/iam/provider.tf:1,10-13.
This module can be made compatible with for_each by changing it to receive all
of its provider configurations from the calling module, by using the
"providers" argument in the calling module block.
the current draft upgrade guide to Terraform v0.13 states it is possible to write modules compatible with both v0.12 and v0.13:
Fuller instructions will follow on the main Terraform documentation website
after the v0.13.0 release, including some guidance on how you can write
modules that are compatible with both v0.12 and v0.13 during a transitional
period.
I’m trying to use for_each feature on modules in 0.13.0-RC1 to consume iam roles from another module that provides them as output.
E.g.: 2 types of containers exist “api” and “worker” each assumes its own AWS iam role. I then want to allow each of that role to access SQS via resource policy by passing the output of multiple module call as array to SQS module:
The short answer to your question is that this is a permanent restriction and that modules containing provider configurations are incompatible with module for_each, count, and depends_on. I’ve written some more in the other topic about why that is and how you might adapt modules to follow the guidance about having provider configurations only in the root module.
I’m happy to discuss that more over there, if you like: just want to keep all of that discussion in one place, so it’s easier to refer to.
You can find the current draft of the documentation the upgrade guide is referring to in v0.12-compatible provider requirements, which will be published on terraform.io as part of the final 0.13.0 release.
As you can see there, it won’t be possible to write a cross-compatible module that uses a provider that Terraform 0.12 couldn’t previously install, but for examples like datadog those were not “moved out” of the hashicorp namespace, but were rather not moved into it in the first place: the home of all providers before introduction of the heirarchical addressing scheme was the terraform-providers organization, and so the ones that are not maintained directly by HashiCorp continue to exist there.
You can write a module that depends on the datadog provider by following the guidance in that documentation section, giving something like the following:
The terraform 0.13upgrade command knows how to generate the above automatically, so if you go through the recommended upgrade process for each of your modules then you shouldn’t need to do anything additional.
This works because most of the 0.12.x releases understand that new required_providers syntax but just ignore the source part and use the old technique for finding the source location of the provider. That was done in anticipation of this transition.
The for expression you found is indeed the way to take the role_arn for each of the module instances. You can write that same expression inline rather than creating a local value for it, if you want:
application_iam_roles = [
for module_instance in module.base_remote_state :
module_instance.role_arn
]
Well, I tried adding the source field in required_providersbefore posting here and terraform 0.12.29 rejected it saying it wasn’t supported.
Edit: oops, read that wrong, it was just a warning
Warning: Provider source not supported in Terraform v0.12
on .terraform/modules/signalfx.signalfx-detectors-caas-kubernetes-workloads/versions.tf line 3, in terraform:
3: signalfx = {
4: source = "terraform-providers/signalfx"
5: }
A source was declared for provider signalfx. Terraform v0.12 does not support
the provider source attribute. It will be ignored.