Skip to content

Commit

Permalink
Merge pull request #274 from ministryofjustice/setup-aws-profile
Browse files Browse the repository at this point in the history
Github Action to setup AWS profile
  • Loading branch information
levgorbunov1 authored Oct 9, 2024
2 parents 63d84d4 + 2eaa7e5 commit 5d0f32b
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
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 }}

0 comments on commit 5d0f32b

Please sign in to comment.