File tree Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Original file line number Diff line number Diff line change 1+ name : AWS Auth
2+
3+ description : |
4+ This is an opinionated action to authenticate with AWS.
5+ It will generate a role ARN based on the repository name and the AWS account ID.
6+
7+ inputs :
8+ aws_account_id :
9+ description : ' The AWS account ID to generate the role ARN for'
10+ required : true
11+ default : ' 197730964718' # elastic-web
12+ aws_region :
13+ description : ' The AWS region to use'
14+ required : false
15+ default : ' us-east-1'
16+ aws_role_name_prefix :
17+ description : ' The prefix for the role name'
18+ required : false
19+ default : ' elastic-docs-v3-preview-'
20+
21+ runs :
22+ using : composite
23+ steps :
24+ - name : Generate AWS Role ARN
25+ id : role_arn
26+ shell : python
27+ env :
28+ AWS_ACCOUNT_ID : ${{ inputs.aws_account_id }}
29+ ROLE_NAME_PREFIX : ${{ inputs.aws_role_name_prefix }}
30+ run : |
31+ import hashlib
32+ import os
33+ prefix = os.environ["ROLE_NAME_PREFIX"]
34+ m = hashlib.sha256()
35+ m.update(os.environ["GITHUB_REPOSITORY"].encode('utf-8'))
36+ hash = m.hexdigest()[:64-len(prefix)]
37+ with open(os.environ["GITHUB_OUTPUT"], "a") as f:
38+ f.write(f"result=arn:aws:iam::{os.environ["AWS_ACCOUNT_ID"]}:role/{prefix}{hash}")
39+ - name : Configure AWS Credentials
40+ uses : aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 # v4.0.2
41+ with :
42+ role-to-assume : ${{ steps.role_arn.outputs.result }}
43+ aws-region : ${{ inputs.aws_region }}
You can’t perform that action at this time.
0 commit comments