"required_providers" mandatory since which version

We still do 'provider "aws" { - since we are on 0.11.x - on which version of Terraform does this break ?

I’m afraid your question doesn’t really make sense… required_providers still isn’t mandatory unless using providers outside of the hashicorp/ namespace (which aws isn’t), and provider "aws" { is still legal syntax in modern Terraform.

However, you urgently need to invest some time in upgrading to modern Terraform versions - 0.11 is before multiple major changes, which happened so long ago that knowledge of how to upgrade is starting to fade from the general population of the Internet, and even the documentation is starting to get harder to find.

From 0.11, you will be stuck having to upgrade in multiple steps:

  • From 0.11 to 0.12 – this is a huge change, and it is mandatory to not skip past 0.12, to upgrade existing state files
  • From 0.12 to 0.13 – this is a smaller change, but it is still mandatory to not skip 0.13 to upgrade existing state files
  • From 0.13 to 0.14 – if you follow the documentation strictly you are supposed to also make an intermediate stop at 0.14, although in my personal experience, this step and this step only isn’t actually mandatory
  • To latest 1.x

You can find the first documentation you need at Upgrading to Terraform 0.12 | Terraform | HashiCorp Developer

So we probably will have the new web app revamp for Terraform 1.3.9 and continue using the current web app at version 0.11.15 - since it would be more challenging to update code that may break in the current web app.

Hi @anjanesh,

The required_providers block was introduced in Terraform v0.12 initially just as an alias for the version argument in a provider block, to create some continuity so that there’d be at least one release where both of them work – at least sufficiently to support official providers.

Terraform v0.13 introduced the idea of providers in multiple namespaces, which is when required_providers became “required” in the sense that it’s the only way to specify providers that aren’t in the hashicorp/ namespace: it’s the way to create the relationships between the global names like hashicorp/aws (which is a shorthand for registry.terraform.io/hashicorp/aws) and a module’s “local name” for that provider, which would conventionally just be aws but isn’t required to be.

@maxb is right that for backward compatibility Terraform v0.13 and later will guess that any provider that isn’t mentioned in required_providers is intended to be one in the hashicorp/ namespace, since that allows many existing modules written for Terraform v0.12 to keep working with later versions of Terraform. However, we do recommend populating required_providers even for those that this backward compatibility rule applies to, because it makes it explicit which provider each local name belongs to.

The terraform 0.13upgrade tool from Terraform v0.13 will automatically generate a required_providers block for you as part of the upgrade process, as long as you are only using providers that the upgrade process knows about. Unfortunately it’s been a long while since that release so I expect there are at least a few providers it doesn’t know about; in that case you might have to manually write some of the required_providers entries. But I think that’s still pretty rare.

1 Like