【发布时间】:2018-05-15 11:06:24
【问题描述】:
我正在编写一个 cloudformation 模板,并在“输出”部分输出一些值。我想从 shell 脚本中检索这些值以执行一些其他操作。如果可能的话,有人可以帮我提供一些例子吗?
问候 普雷迪普
【问题讨论】:
标签: shell amazon-web-services amazon-cloudformation
我正在编写一个 cloudformation 模板,并在“输出”部分输出一些值。我想从 shell 脚本中检索这些值以执行一些其他操作。如果可能的话,有人可以帮我提供一些例子吗?
问候 普雷迪普
【问题讨论】:
标签: shell amazon-web-services amazon-cloudformation
正如@PicoutputCIs 所说,您可以使用aws cloudformation describe-stacks。但是您不必自己解析。你可以让aws用--query为你解析。例如:
$ aws cloudformation describe-stacks --query Stacks[].Outputs[*].[OutputKey,OutputValue] --output text
SomeKey SomeValue
SomeOtherKey SomeOtherValue
有关更多选项,请参阅: http://docs.aws.amazon.com/cli/latest/userguide/controlling-output.html
【讨论】:
您应该能够使用aws cloudformation describe-stacks 命令(如AWS CloudFormation documentation 中所述)通过AWS CLI 从shell 脚本的堆栈中获取Outputs,并解析返回的JSON 输出。
【讨论】: