I just want to ask if there is any way that I can make the aws cloudformation package in python? Here is the code in awscli:
aws cloudformation package \
--region us-east-1 \
--profile $Profile \
--template-file templates/$TEMPLATE.yml \
--s3-bucket $ARTIFACT_BUCKET \
--output-template-file $d-$TEMPLATE-$Profile.packaged.yml
I want this to have in python? Thanks! any help would be appreciated.
There are two way:
import os
import subprocess
subprocess.run(
[
"aws", "cloudformation", "package",
"--region", "us-east-1"
"--profile", os.environ["Profile"], # use os.environ to get the env var value
"--template-file", f'templates/{os.environ["TEMPLATE"]}.yml',
"--s3-bucket", os.environ["ARTIFACT_BUCKET"],
"--output-template-file", f'{os.environ["d"]}-{os.environ["TEMPLATE"]}-{os.environ["Profile"]}.packaged.yml',
],
check=True, # if failed, stop the script immediately, prevent the sub sequence command to run
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With