Trying to use configure-aws-credentials in a Github actions template and getting an error:
Error: Credentials could not be loaded, please check your action inputs: Could not load credentials from any providers
This error has been discussed in several different forms.
I have the strange behaviour that this workflow is not working in one repo, but works fine in another. This repos have exactly the same secrets and the workflow code is the same. The only difference is in how I made the two repos: One is a clone of a specific branch, the other is a freshly made example.
I cant exactly post this as a bug as I cant reproduce the failure in repo I can share, but I fail to see how the two repos can be different in ways that impact using configure-aws-credentials?
Key workflow code in summary
name: 1 Initial
permissions:
id-token: write
contents: read
jobs:
create-s3-bucket:
name: Create S3 Bucket
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v3
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}
mask-aws-account-id: "no"
- name: Create S3 Bucket
run: |
aws s3api create-bucket --bucket ${{ env.S3_PATH }} --region ${{ env.AWS_REGION }} --create-bucket-configuration LocationConstraint=${{ env.AWS_REGION }}
I (sort of) fixed it.
I never really found the core reason for this behaviour. However, I think it has something to do with how the Github repos are tied up to its secrets.
FYI my use case is having a template in one repo that I can use to setup new repos with same structure/code.
Reproduce the error by
templatetemplatebranchgit clone -b new-project /path/to/repo /new/repo/pathChange the remote add secrets etc
Using
configure-aws-credentials@will not work in the new repoSolution / Alternative
Instead of basing the new repo on a branch from the template repo, I made the repo a template repo. Creating any new repo from this and
configure-aws-credentials@in any version works fine.