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

Github Action to setup AWS profile #274

Merged
merged 2 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions setup-aws-profile/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Setup AWS Profile Action

A GitHub Action to setup an aws profile.

## Usage

```
- uses: ministryofjustice/github-actions/setup-aws-profile@v18.2.1
with:
role-arn: ${{ secrets.MY_AWS_ROLE_ARN }}
profile-name: ${{ secrets.MY_PROFILE }}
```

| Parameter | Description | Required | Default |
| ---------------------------------------------------------------- | ---------------------------------------------------------------- | ---------------------------------------------------------------- | ---------------------------------------------------------------- |
| role-arn | ARN of IAM role to create profile for | true | N/A |
| profile-name | Name of AWS profile | true | N/A |
| aws-region | AWS region | false | eu-west-2 |
31 changes: 31 additions & 0 deletions setup-aws-profile/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: "Setup AWS Profile"
description: "A GitHub Action to setup an aws profile."
inputs:
role-arn:
description: "ARN of IAM role to create profile for"
required: true
profile-name:
description: "Name of AWS profile"
required: true
aws-region:
description: "AWS region"
required: false
default: "eu-west-2"
runs:
using: "composite"
steps:
- name: Configure AWS credentials for profile
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ inputs.role-arn }}
aws-region: ${{ inputs.aws-region }}
role-duration-seconds: 900

- name: Create AWS profile
shell: bash
run: |
aws configure set region ${{ env.AWS_REGION }} --profile ${{ inputs.profile-name }}
aws configure set aws_access_key_id ${{ env.AWS_ACCESS_KEY_ID }} --profile ${{ inputs.profile-name }}
aws configure set aws_secret_access_key ${{ env.AWS_SECRET_ACCESS_KEY }} --profile ${{ inputs.profile-name }}
aws configure set aws_session_token ${{ env.AWS_SESSION_TOKEN }} --profile ${{ inputs.profile-name }}