Skip to content

Instantly share code, notes, and snippets.

@baxtor6
Created June 14, 2023 19:23
Show Gist options
  • Save baxtor6/42438c01abbd0e0a4674e50934b6dd5c to your computer and use it in GitHub Desktop.
Save baxtor6/42438c01abbd0e0a4674e50934b6dd5c to your computer and use it in GitHub Desktop.
Sample workflow to access AWS resources when the workflow is tied to the branch
# Sample workflow to access AWS resources when the workflow is tied to the branch
# The workflow Creates a static website using aws s3
name: AWS example workflow
on:
push
env:
BUCKET_NAME : "<example-bucket-name>"
AWS_REGION : "<example-aws-region>"
# permission can be added at the job level or workflow level
permissions:
id-token: write # This is required for requesting the JWT
contents: read # This is required for actions/checkout
jobs:
S3PackageUpload:
runs-on: ubuntu-latest
steps:
- name: Git clone the repository
uses: actions/checkout@v3
- name: configure aws credentials
uses: aws-actions/configure-aws-credentials@v2
with:
role-to-assume: arn:aws:iam::1234567890:role/example-role
role-session-name: samplerolesession
aws-region: ${{ env.AWS_REGION }}
# Upload a file to AWS s3
- name: Copy index.html to s3
run: |
aws s3 cp ./index.html s3://${{ env.BUCKET_NAME }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment