Convenient way of retrieving aws account id
This action retrieves aws account id based on account tag. The (required) inputs are:
- aws-account-tag: AWS account tag used for retrieving id.
- aws-access-key: AWS access key for accessing organizations.
- aws-secret-key: AWS secret key for accessing organizations.
- aws-role-arn: AWS role arn for accessing organizations.
Outputs:
- aws-account-id: AWS account id.
name: Deploy
on:
workflow_call:
inputs:
stage:
description: 'Stage'
type: string
required: true
default: tst
client:
description: "Name of client"
type: string
required: true
account_prefix:
description: "Prefix of account to deploy to (ohp, dvc)"
type: string
required: false
default: 'dvc'
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: ohpensource/get-aws-account-id-gh-action@0.0.0.1
id: aws_account
name: Get account id
with:
aws-account-tag: "${{ inputs.account_prefix }}-${{ inputs.client }}-${{ inputs.stage }}"
aws-access-key: $COR_AWS_ACCESS_KEY_ID
aws-secret-key: $COR_AWS_SECRET_ACCESS_KEY
aws-role-arn: $AUTOMATION_ROLE_ARN
- name: Preparing deployment parameters
id: deployment_parameters
run: |
TFVARS="deployment-conf/terraform.tfvars.json"
sed -i "s#<account_id>#${{steps.aws_account.outputs.aws-account-id}}#g" $TFVARS
This code is made available under the MIT license. Details here.