[英]AWS cloudformation package in python
I just want to ask if there is any way that I can make the aws cloudformation package in python?我只想问有没有什么方法可以在python中制作aws cloudformation package? Here is the code in awscli:这是 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?我希望这个在 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
)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.