Skip to content

When referencing a module stored locally if it has a provider block, you get credential errors #67

Closed
@togakangaroo

Description

@togakangaroo

I am working on an example for a tf module we're developing at work. So the folder structure is something like

- module-files.tf
 |- examples
    |- async
       |- example.files.tf

In my example files I have

module "lambda" {
  source        = "../../"
  ...
}

This works, I can tflocal apply and everything

now the module itself (in module-files.tf) got added an aws provider block

provider "aws" { }

and suddenly this fails

│   on ../../providers.tf line 11:
│   11: provider "aws" {
│ 
│ Earlier versions of Terraform used empty provider blocks ("proxy provider configurations") for child modules to declare their need to be passed a provider configuration by their callers. That approach was
│ ambiguous and is now deprecated.
│ 
│ If you control this module, you can migrate to the new declaration syntax by removing all of the empty provider "aws" blocks and then adding or updating an entry like the following to the required_providers
│ block of module.lambda:
│     aws = {
│       source = "hashicorp/aws"
│     }
╵
╷
│ Error: No valid credential sources found
│ 
│   with module.lambda.provider["registry.terraform.io/hashicorp/aws"],
│   on ../../providers.tf line 11, in provider "aws":
│   11: provider "aws" {
│ 
│ Please see https://registry.terraform.io/providers/hashicorp/aws
│ for more information about providing credentials.
│ 
│ Error: failed to refresh cached credentials, no EC2 IMDS role found, operation error ec2imds: GetMetadata, access disabled to EC2 IMDS via client option, or "AWS_EC2_METADATA_DISABLED" environment variable

Having inspected how tflocal works, I think I understand why.

I believe that tflocal generates a temporary localstack_providers_override.tf file and then cleans it up, right? Well for the module it has no way of creating one there. If I manually create this file at the module-files.tf level then my tflocal apply works!

So it seems to me that tflocal either needs to walk to included modules, or at least provide a configuration where you can say "ALSO localstack-ify these other directories temporarily"

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions