Multiple AWS Providers in Terraform Cloud?

I have a TF Cloud question I’m hoping to get some help with.

I have multiple AWS providers, so locally I can just use alias along with profile and it works fine.

However, when using Terraform Cloud I need to provide the additional AWS credentials as Environment Variables, but it isn’t working.

I’ve defined TF_VAR_alias_access_key and TF_VAR_alias_secret_key under Terraform Cloud Environment Variables but when the plan runs, it says it those vars are required, but not found.

I don’t think I’m quite following what the problem is here. Can you share what your provider configuration looks like, and maybe a screenshot of your Terraform Cloud workspace variables page? Make sure to obscure any AWS keys, of course! :sweat_smile:

Hi @alisdair!

I ended up getting some help from the #terraform channel on hangOps.

It turns out I was not following best practice in regards to multiple providers. I had a provider defined in a child module instead of the root module.

I was pointed to this documentation:

That doc was extremely helpful. I modified my code to have all of the providers in the root/main.tf and passed the necessary providers into the module.

All is working now.

Cheers!
Jake

1 Like