I believe there was an undocumented, breaking change in the AWS V4 Provider which results in a failure when it looks for a profile that doesn’t exist.
The V3 provider family didn’t fail: it would fall back in the same manner as AWS-CLI, and use the default (which works fine with configure-aws-credentials and other aws tools).
The easiest solution is to create a variable (bool, default false) which indicates whether the operation is being run in a pipeline. In your pipeline, set this variable to true. Then in your terraform provider config, dynamically set the profile using the pipeline variable as a flag.
This will allow you to continue to work locally using profile names, while the empty string will cause TF to grab the default profile (generated by configure-aws-credentials or some similar library).
Thank you! I was tearing my hair out on why my Terraform configuration worked fine locally but plan failed in (Jenkins) pipeline, especially since I don’t have access to the Jenkins instances, making debugging that much more difficult.
Coming to this thread a bit later with the same issue. I was trying to update terraform to version 1.7.3. I did not have the profile set in the provider block, but I did have it in the ‘backend’ block. Removing it from there as well fixed the issue for me.
Interestingly, the backend was set up successfully at the start of terraform init, so this didn’t seem to be the issue. But debugging the output of the init showed that all the modules were successfully set up.