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

Use local aws credentials in local act run #409

Closed
aldegoeij opened this issue Nov 6, 2020 · 5 comments
Closed

Use local aws credentials in local act run #409

aldegoeij opened this issue Nov 6, 2020 · 5 comments
Labels

Comments

@aldegoeij
Copy link

Is it somehow possible to read the credentials from my local ~/.aws/ directory and use them in the workflow run?

It is the same logic as used in e.g. docker by adding -v $HOME/.aws:/root/.aws to docker run command. Processes in the docker container now use the local credentials as base credentials for role assume.

This way within the workflow the base credentials are the base credentials of my local aws configuration. Currently I need to copy paste Access Key Id, Secret Access Key and Session Token into a .secrets file for act to pickup?

Is there any way to pass e.g. custom docker commands?

@rahb3rt
Copy link

rahb3rt commented Nov 18, 2020

I am sure you could pass them in via secrets function?

Something like act -s AWS_SECRETE=$(cat ~/.aws/config) and so on would that not work? @aldegoeij

@github-actions
Copy link
Contributor

Issue is stale and will be closed in 14 days unless there is new activity

@vcolanoKH
Copy link

vcolanoKH commented Feb 11, 2022

Finagling @rahb3rt's answer a bit I got this working with

act pull_request \
 --env AWS_ACCESS_KEY_ID=$(aws configure get default.aws_access_key_id) \
 --env AWS_SECRET_ACCESS_KEY=$(aws configure get default.aws_secret_access_key) \
 --env AWS_SESSION_TOKEN=$(aws configure get default.aws_session_token

Sources:

@rdettai
Copy link

rdettai commented Mar 16, 2022

for reference, what i ended up doing:

  • calling command
    act --env CREDS_FILE="$(shell cat ~/.aws/credentials | base64 -w 0)"

  • new step

      - name: "Write AWS credentials file"
        if: ${{ env.ACT }}
        description: "When running locally with `act`, load AWS credentials"
        run: |
          mkdir ~/.aws
          echo $CREDS_FILE | base64 -d > ~/.aws/credentials

As you can see, I am encoding with base64 to avoid all escaping/newline issues.

@furkantektas
Copy link

Alternative to @rdettai's solution, you can pass the credentials via env-file parameter like this:

act pull_request --env-file <(aws configure export-credentials --format env)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants