From 51d7a3c19ec26689a296bab8eaab348b9d789be7 Mon Sep 17 00:00:00 2001 From: levgorbunov1 Date: Wed, 9 Oct 2024 13:19:43 +0100 Subject: [PATCH 1/2] action to setup aws profile --- setup-aws-profile/README.md | 18 ++++++++++++++++++ setup-aws-profile/action.yml | 30 ++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 setup-aws-profile/README.md create mode 100644 setup-aws-profile/action.yml diff --git a/setup-aws-profile/README.md b/setup-aws-profile/README.md new file mode 100644 index 0000000..b89d4b9 --- /dev/null +++ b/setup-aws-profile/README.md @@ -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 | diff --git a/setup-aws-profile/action.yml b/setup-aws-profile/action.yml new file mode 100644 index 0000000..fcbac55 --- /dev/null +++ b/setup-aws-profile/action.yml @@ -0,0 +1,30 @@ +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 + 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 }} + From 2eaa7e56a88306edece8732d69bfd10cad23977c Mon Sep 17 00:00:00 2001 From: levgorbunov1 Date: Wed, 9 Oct 2024 13:28:39 +0100 Subject: [PATCH 2/2] add shell for run commands --- setup-aws-profile/action.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/setup-aws-profile/action.yml b/setup-aws-profile/action.yml index fcbac55..6d04a3f 100644 --- a/setup-aws-profile/action.yml +++ b/setup-aws-profile/action.yml @@ -22,6 +22,7 @@ runs: 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 }}