Skip to content
This repository was archived by the owner on Dec 9, 2024. It is now read-only.

Commit 4363a4c

Browse files
authored
Merge pull request #91 from aws-ia/remove-aws-quickstart-mentions
Synced publication stage updates from project type
2 parents a2a6f43 + 7bb10b7 commit 4363a4c

File tree

3 files changed

+81
-0
lines changed

3 files changed

+81
-0
lines changed

.project_automation/publication/assets/.taskcat_publish.yml

+8
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ general:
66
ap-southeast-3: ap-southeast-3-profile
77
eu-south-1: eu-south-1-profile
88
me-south-1: me-south-1-profile
9+
cn-north-1: china-profile
10+
cn-northwest-1: china-profile
11+
us-gov-east-1: us-govcloud-profile
12+
us-gov-west-1: us-govcloud-profile
913
project:
1014
s3_regional_buckets: true
1115
s3_bucket: aws-ia
@@ -32,5 +36,9 @@ project:
3236
- ca-central-1
3337
- eu-central-1
3438
- eu-north-1
39+
- cn-north-1
40+
- cn-northwest-1
41+
- us-gov-east-1
42+
- us-gov-west-1
3543
tests:
3644
test1: {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
#!/usr/bin/env python3
2+
import boto3
3+
import json
4+
import sys
5+
import argparse
6+
7+
# https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-sourcing-external.html
8+
9+
def _transform_creds(result, ak, sk):
10+
AK = result[ak]
11+
SAK = result[sk]
12+
transformed_creds = {
13+
"Version": 1,
14+
"AccessKeyId": AK,
15+
"SecretAccessKey": SAK
16+
}
17+
return transformed_creds
18+
19+
def fetch_creds(region_name, secret_name, ak, sk, pr):
20+
ssm = boto3.Session(profile_name=pr).client('secretsmanager', region_name=region_name)
21+
value = ssm.get_secret_value(SecretId=secret_name)
22+
value = json.loads(value["SecretString"])
23+
return _transform_creds(value, ak, sk)
24+
25+
if __name__ == "__main__":
26+
parser = argparse.ArgumentParser(
27+
prog="cred_helper.py",
28+
description="Snags creds from Secrets manager for use in an AWS profile. Leveraging botocore builtins.",
29+
)
30+
parser.add_argument(
31+
"--region",
32+
type=str,
33+
help="region name. otherwise use the default.",
34+
required=True
35+
)
36+
parser.add_argument(
37+
"--secret-name",
38+
type=str,
39+
help="secret name to fetch",
40+
required=True
41+
)
42+
parser.add_argument(
43+
"--access-key-index",
44+
type=str,
45+
help="secret name to fetch",
46+
required=True
47+
)
48+
parser.add_argument(
49+
"--secret-access-key-index",
50+
type=str,
51+
help="secret name to fetch",
52+
required=True
53+
)
54+
parser.add_argument(
55+
"--secret-profile",
56+
type=str,
57+
help="profile to use when fetching the secret",
58+
required=False,
59+
default="default"
60+
)
61+
args = parser.parse_args()
62+
try:
63+
parsed_creds = fetch_creds(
64+
args.region,
65+
args.secret_name,
66+
args.access_key_index,
67+
args.secret_access_key_index,
68+
args.secret_profile
69+
)
70+
json.dump(parsed_creds, sys.stdout, indent=2)
71+
except:
72+
raise

.project_automation/publication/s3_publish.sh

+1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ cat "${automation_scripts_path}tmp.yml"
6262

6363
aws sts get-caller-identity --debug
6464

65+
chmod 755 ${project_root}/.project_automation/publication/assets/cred_helper.py
6566
# push to regional S3 buckets
6667
export TASKCAT_PROJECT_S3_REGIONAL_BUCKETS=true; taskcat -d upload -p ${project_root} -c "${automation_scripts_path}tmp.yml"
6768

0 commit comments

Comments
 (0)