Example in Yaml for running an aws cli command

Hello all, I’m trying out GitHub Actions in an attempt to get an AWS CLI command working.

I’ve found some information online about using hcl-syntax for setting up an AWS CLI workflow going, but since this syntax will soon be depricated I would like to find a yaml-based example. 

In particular, I’m trying to get a “aws s3 cp” command running on push. This is what I’ve attempted so far, but it fails because I’ve messed up the syntax in some way ( note: that I’ve changed the real url to example.com):

name: DeployToAwsS3

on: push


    runs-on: ubuntu-latest

      - uses: actions/aws/cli@master
      - with:
        - args: s3 cp . s3://www.example.com --recursive --exclude ".git/*" --exlucde ".github/*"
        - secrets:
          - AWS_ACCESS_KEY_ID
        - uses: actions/aws/cli@master

Could someone provide an example in yaml for running an aws cli command on push?

Also, if I need configure multiple AWS access credentials, for example DEV_AWS_KEY_ID for develop branch and PROD_AWS_KEY_ID for master branch, how could I do please? Any examples? 

Also interested in this.

Better later than never

To answer both questions -

I’ve created a GitHub Action that installs the AWS CLI on a Linux runner, according to a given version, so you might find it useful - unfor19/install-aws-cli-action

This is how you use it -

- id: install-aws-cli
  uses: unfor19/install-aws-cli-action@v1
    version: 1

As for what @fen9li mentioned, I implemented this mechanism in [unfor19/terraform-multienv]( 54 lines (50 sloc) 1.88 KB



      - name: Set AWS credentials as env vars
        run: |
      - name: prepare-files-folders
        run: |
      - name: prepare-backend
        run: |
          export AWS_ACCESS_KEY_ID=${{ secrets[env.AWS_ACCESS_KEY_ID_SECRET_NAME] }}
          export AWS_SECRET_ACCESS_KEY=${{ secrets[env.AWS_SECRET_ACCESS_KEY_SECRET_NAME] }}   
1 Like