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..6d04a3f --- /dev/null +++ b/setup-aws-profile/action.yml @@ -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 }} +