Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Credentials could not be loaded, please check your action inputs: Could not load credentials from any providers #990

Closed
gulskr opened this issue Jan 25, 2024 · 6 comments
Assignees
Labels
bug Something isn't working needs-reproduction This issue needs reproduction. p2

Comments

@gulskr
Copy link
Contributor

gulskr commented Jan 25, 2024

Describe the bug

Okay, so I have created a reusable workflow for all my business jobs and and I am calling the reusable workflow in other repo within a private repo. When I try to run this workflow on github action, it throws a very strange error, credentials could not be loaded, but when I run the workflow without calling reusable it fetch the credential and works fine, Can anyone help me with this issue. @aws-dash @aws-sdk-osds @kanchana-aws @smithy

Expected Behavior

I expect to run this workflow and able to fetch the credentials.

Current Behavior

aws cred error

Reproduction Steps

Okay so i will provide you code and everything,
jobs:
start_ec2:
runs-on: ubuntu-latest
steps:

  • name: Check User
    run: |
    echo "GitHub Actor: $GITHUB_ACTOR"

    • name: Debug AWS Credentials
      run: |
      echo "AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}"
      echo "AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}"

    • name: Checkout Repository
      uses: actions/checkout@v4
      with:
      ref: ${{ github.event.inputs.branch }}

    • uses: actions/setup-python@v5
      with:
      python-version: '3.10'

    • name: Configure AWS credentials
      uses: aws-actions/configure-aws-credentials@v4
      with:
      aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
      aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
      aws-region: ap-south-1

    • name: Generate Date and Time - build
      id: date-time-ecr
      run: |
      echo "output=$(date +'%d-%m-%y-%H-%M-%S')" >> $GITHUB_OUTPUT

    • name: install boto3
      run: |
      pip install boto3

    • name: run
      run: |
      python automation-scripts/aws/start_resources_ec2_rds.py

This is the workflwo where i am calling this reusable workflow:
name: Start AWS EC2 & RDS - Reusable
run-name: Build initiated by ${{ github.actor }} for branch ${{inputs.branch}}

on:
workflow_dispatch:
inputs:
branch:
description: 'Select Branch'
required: true
default: 'main'
type: choice
options:

  • main

allow use id-token - also i have tried with this and without works same
permissions:
id-token: write # required!
contents: read

jobs:
call-workflow-passing-data:
uses: user-name/repo-name/.github/workflows/reusable_workflow.yml@main

Possible Solution

I think maybe it has something to do with the aws credentials but i don't have much idea.

Additional Information/Context

No response

@gulskr gulskr added bug Something isn't working needs-triage This issue still needs to be triaged labels Jan 25, 2024
@tim-finnigan
Copy link
Contributor

tim-finnigan commented Jan 25, 2024

Hi @gulskr thanks for reaching out. Can you provide your full code in YAML format, for us to make sure we try to reproduce this with the identical steps you've taken?

To further expand on the reason why I'm requesting a full code in YAML format - the indentation matters in YAML and I cannot tell the correct levels of indentation based on the unformatted text you provided, therefore making this difficult to reproduce.

I'll also note that the AssumeRoleWithWebIdentity approach documented here recommended: https://github.com/aws-actions/configure-aws-credentials/blob/main/README.md#assumerolewithwebidentity-recommended.

And for future reference we ask that you do not tag various users to look at an issue. As long as the needs-triage label is applied (which is the default for new issues) then the issue will go through our standard intake process.

@tim-finnigan tim-finnigan self-assigned this Jan 25, 2024
@tim-finnigan tim-finnigan added response-requested Waiting on additional info and feedback. Will move to 'closing-soon' in 5 days. p2 needs-reproduction This issue needs reproduction. and removed needs-triage This issue still needs to be triaged labels Jan 25, 2024
@gulskr
Copy link
Contributor Author

gulskr commented Jan 26, 2024

This is the reuisable workflow YAML code and one more when i tried to run the workflow without reusable workflow it work fine
`name: Reusable workflow

on:
workflow_call:

env:

AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}

AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}

jobs:
start_ec2:
runs-on: ubuntu-latest
steps:
- name: Check User
run: |
echo "GitHub Actor: $GITHUB_ACTOR"

  - name: Debug AWS Credentials
    run: |
      echo "AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}"
      echo "AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}"


  - name: Checkout Repository
    uses: actions/checkout@v4
    with:
      ref: ${{ github.event.inputs.branch }}  
  
  - uses: actions/setup-python@v5
    with:
      python-version: '3.10'
  
  - name: Configure AWS credentials
    uses: aws-actions/configure-aws-credentials@v4
    with:
      aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
      aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
      aws-region: ap-south-1
  
  - name: Generate Date and Time - build
    id: date-time-ecr
    run: |
      echo "output=$(date +'%d-%m-%y-%H-%M-%S')" >> $GITHUB_OUTPUT

  - name: install boto3
    run: |
      pip install boto3 

  - name: run
    run: |
      python automation-scripts/aws/start_resources_ec2_rds.py`

This is the yaml file where i am calling that reusable workflow
`name: Start AWS EC2 & RDS - Reusable
run-name: Build initiated by ${{ github.actor }} for branch ${{inputs.branch}}

on:
workflow_dispatch:
inputs:
branch:
description: 'Select Branch'
required: true
default: 'main'
type: choice
options:
- main

allow use id-token

permissions:
id-token: write # required!
contents: read

jobs:
call-workflow-passing-data:
uses: gulskr/Python-boto/.github/workflows/reusable_workflow.yml@main
`

@github-actions github-actions bot removed the response-requested Waiting on additional info and feedback. Will move to 'closing-soon' in 5 days. label Jan 26, 2024
@tim-finnigan
Copy link
Contributor

Thanks @gulskr for following up. I'm still having trouble reproducing this issue. Here is an example from the README:

 - name: Configure AWS Credentials
      uses: aws-actions/configure-aws-credentials@v4
      with:
        aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
        aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
        aws-region: us-east-2
        role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
        role-external-id: ${{ secrets.AWS_ROLE_EXTERNAL_ID }}
        role-duration-seconds: 1200
        role-session-name: MySessionName

Here is a screenshot of what the code snippet markdown format looks like this, surrounded by backticks:

image

If you can encapsulate your code snippets in that format, that will greatly help with investigating the issue.


Could you also expand on this point for clarification?

This is the reuisable workflow YAML code and one more when i tried to run the workflow without reusable workflow it work fine

If you can point out specifically what is working and not working from your examples, that can help us narrow down the issue here.

Thanks,
Tim

@tim-finnigan tim-finnigan added the response-requested Waiting on additional info and feedback. Will move to 'closing-soon' in 5 days. label Jan 26, 2024
@gulskr
Copy link
Contributor Author

gulskr commented Jan 27, 2024

Okay, thanks for replying, Now I will elaborate everything what I am trying to achieve.
I am trying to make a reusable workflow and trying to call this reusable workflow in the another workflow , So in this example I have created A yaml file named reusable_workflow.yml which basically is reusable workflow, I am putting the reusable workflow code down under 3 backticks

name: Reusable workflow

on:
  workflow_call:

jobs:
  start_ec2:
    runs-on: ubuntu-latest
    steps:
      - name: Check User
        run: |
          echo "GitHub Actor: $GITHUB_ACTOR"

      - name: Debug AWS Credentials
        run: |
          echo "AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}"
          echo "AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}"
  

      - name: Checkout Repository
        uses: actions/checkout@v4
        with:
          ref: ${{ github.event.inputs.branch }}  
      
      - uses: actions/setup-python@v5
        with:
          python-version: '3.10'
      
      - name: Configure AWS credentials
        uses: aws-actions/configure-aws-credentials@v4
        with:
          aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
          aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
          aws-region: ap-south-1
      
      - name: Generate Date and Time - build
        id: date-time-ecr
        run: |
          echo "output=$(date +'%d-%m-%y-%H-%M-%S')" >> $GITHUB_OUTPUT

      - name: install boto3
        run: |
          pip install boto3 

      - name: run
        run: |
          python automation-scripts/aws/start_resources_ec2_rds.py

=================================================================================
Now, This workflow Start_testing_reusable.yml is calling the above reusable workflow, I am putting the code below

name: Start AWS EC2 & RDS - Reusable
run-name: Build initiated by ${{ github.actor }} for branch ${{inputs.branch}}

on:
  workflow_dispatch:
    inputs:
      branch:
        description: 'Select Branch'
        required: true
        default: 'main'
        type: choice
        options:
          - main

# allow use id-token
permissions:
    id-token: write # required!
    contents: read
    
jobs:
  call-workflow-passing-data:
    uses: gulskr/Python-boto/.github/workflows/reusable_workflow.yml@main

=> I don't know why this is a very strange problem I am facing, because When i try to run the workflow without using reusable workflow then it is working fine, like this in the code below

name: Start AWS EC2 & RDS - NON prod
run-name: Build initiated by ${{ github.actor }} for branch ${{inputs.branch}}

on:
  workflow_dispatch:
    inputs:
      branch:
        description: 'Select Branch'
        required: true
        default: 'main'
        type: choice
        options:
          - main

jobs:
  stop_ec2:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout Repository
        uses: actions/checkout@v4
        with:
          ref: ${{ github.event.inputs.branch }}  
      
      - uses: actions/setup-python@v5
        with:
          python-version: '3.10'

      - name: Configure AWS credentials
        uses: aws-actions/configure-aws-credentials@v4
        with:
          aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
          aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
          aws-region: ap-south-1
      
      - name: Generate Date and Time - build
        id: date-time-ecr
        run: |
          echo "output=$(date +'%d-%m-%y-%H-%M-%S')" >> $GITHUB_OUTPUT

      - name: install boto3
        run: |
          pip install boto3 

      - name: run
        run: |
          python Start-Instances/start_resources_ec2_rds.py

@github-actions github-actions bot removed the response-requested Waiting on additional info and feedback. Will move to 'closing-soon' in 5 days. label Jan 27, 2024
@gulskr
Copy link
Contributor Author

gulskr commented Jan 29, 2024

A update on this issue while calling the reusable workflow, you just have to add secrets: inherit in the workflow then it will fetch the credentials, see in the below code and match it from the above where the changes been made, thanks @tim-finnigan for your help.

name: Start AWS EC2 & RDS - Reusable
run-name: Build initiated by ${{ github.actor }} for branch ${{inputs.branch}}

on:
  workflow_dispatch:
    inputs:
      branch:
        description: 'Select Branch'
        required: true
        default: 'main'
        type: choice
        options:
          - main

# allow use id-token
permissions:
    id-token: write # required!
    contents: read
    
jobs:
  call-workflow-passing-data:
    uses: gulskr/Python-boto/.github/workflows/reusable_workflow.yml@main
    secrets: inherit

@gulskr gulskr closed this as completed Jan 29, 2024
Copy link

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs-reproduction This issue needs reproduction. p2
Projects
None yet
Development

No branches or pull requests

2 participants