Skip to content

Commit

Permalink
Merge pull request #6 from aws-ia/project_type_sync
Browse files Browse the repository at this point in the history
Syncing project type updates and updating submodule
  • Loading branch information
vsnyc authored Oct 27, 2023
2 parents 10c2f2e + cfd02d9 commit 4c58eae
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 1 deletion.
8 changes: 8 additions & 0 deletions .project_automation/publication/assets/.taskcat_publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ general:
ap-southeast-3: ap-southeast-3-profile
eu-south-1: eu-south-1-profile
me-south-1: me-south-1-profile
cn-north-1: china-profile
cn-northwest-1: china-profile
us-gov-east-1: us-govcloud-profile
us-gov-west-1: us-govcloud-profile
project:
s3_regional_buckets: true
s3_bucket: aws-ia
Expand All @@ -32,5 +36,9 @@ project:
- ca-central-1
- eu-central-1
- eu-north-1
- cn-north-1
- cn-northwest-1
- us-gov-east-1
- us-gov-west-1
tests:
test1: {}
72 changes: 72 additions & 0 deletions .project_automation/publication/assets/cred_helper.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#!/usr/bin/env python3
import boto3
import json
import sys
import argparse

# https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-sourcing-external.html

def _transform_creds(result, ak, sk):
AK = result[ak]
SAK = result[sk]
transformed_creds = {
"Version": 1,
"AccessKeyId": AK,
"SecretAccessKey": SAK
}
return transformed_creds

def fetch_creds(region_name, secret_name, ak, sk, pr):
ssm = boto3.Session(profile_name=pr).client('secretsmanager', region_name=region_name)
value = ssm.get_secret_value(SecretId=secret_name)
value = json.loads(value["SecretString"])
return _transform_creds(value, ak, sk)

if __name__ == "__main__":
parser = argparse.ArgumentParser(
prog="cred_helper.py",
description="Snags creds from Secrets manager for use in an AWS profile. Leveraging botocore builtins.",
)
parser.add_argument(
"--region",
type=str,
help="region name. otherwise use the default.",
required=True
)
parser.add_argument(
"--secret-name",
type=str,
help="secret name to fetch",
required=True
)
parser.add_argument(
"--access-key-index",
type=str,
help="secret name to fetch",
required=True
)
parser.add_argument(
"--secret-access-key-index",
type=str,
help="secret name to fetch",
required=True
)
parser.add_argument(
"--secret-profile",
type=str,
help="profile to use when fetching the secret",
required=False,
default="default"
)
args = parser.parse_args()
try:
parsed_creds = fetch_creds(
args.region,
args.secret_name,
args.access_key_index,
args.secret_access_key_index,
args.secret_profile
)
json.dump(parsed_creds, sys.stdout, indent=2)
except:
raise
1 change: 1 addition & 0 deletions .project_automation/publication/s3_publish.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ cat "${automation_scripts_path}tmp.yml"

aws sts get-caller-identity --debug

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

Expand Down

0 comments on commit 4c58eae

Please sign in to comment.