I’m using a module which creates kubernetes and aws resources. There’s a flag skipping the aws resources creation which I’m using. All aws resources have count 0. Thus in a way I don’t need an aws provider. If I remove it terraform complains it’s required. But if I leave the provider then it complains:
│ Please see Terraform Registry
│ 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
I believe this will work as desired as long as a profile is configured (even without valid credentials). For example, either set AWS_PROFILE or use the profile attribute.
% echo $AWS_PROFILE # verify nothing else is set in the environment
% terraform plan
No changes. Your infrastructure matches the configuration.
If necessary you could mock out the config and credentials files instead of relying on these to be present in the standard location the AWS SDK expects (~/.aws):
The same is true for setting dummy access/secret keys in the provider config - though I’m not sure this translates as well to the contexts in which you actually need to use the AWS provider.
In short, the provider expects to have some credential source to try (access key, profile, assume role block, etc.), even if eventually all validation of those credentials are skipped.