AWS CloudFormation : Usefull custom resources
You will create 2 custom resources for your CloudFormation templates :
- A resource to retrieve credentials in Secrets Manager.
- A resource str-utils to make operations on strings, that's not natively included in CF for now.
aws secretsmanager create-secret --name "test/creds" --secret-string file://creds.json
# You can retrieve them in the cli like this :
aws secretsmanager get-secret-value --secret-id "test/creds"
cp cfn/params.json.dist cfn/params.json
# then edit cfn/params.json
# and set a unique name for your S3 bucket (the names are shared between AWS accounts)
aws cloudformation create-stack --stack-name cfn-exercise-s3 --template-body file://./cfn/create-s3.yml --parameters file://./cfn/params.json
./deploy-lambda.sh <my-bucket>
aws cloudformation create-stack --stack-name cfn-exercise-lambda-functions --template-body file://./cfn/create-lambda-functions.yml --parameters file://./cfn/params.json --capabilities CAPABILITY_NAMED_IAM
aws cloudformation create-stack --stack-name cfn-exercise-custom-resources-usage --template-body file://./cfn/custom-resources-usage.yml --timeout-in-minutes 5
Now you should see your outputs processed by the custom ressources !
aws cloudformation delete-stack --stack-name cfn-exercise-custom-resources-usage
aws cloudformation delete-stack --stack-name cfn-exercise-lambda-functions
aws cloudformation delete-stack --stack-name cfn-exercise-s3
The cfn_resource.py function is based on the cfn-wrapper-python repository by ryansb.