【问题标题】:Output AWS CLI YAML output to console将 AWS CLI YAML 输出输出到控制台
【发布时间】:2021-10-08 14:38:48
【问题描述】:

我正在使用 AWS CLI 和 CloudFormation 创建一个新的 S3 存储桶。 这是我的 yaml 文件:

AWSTemplateFormatVersion: '2010-09-09'
Description: Creates an S3 bucket
Parameters:
  BucketName:
    Description: Name of the Bucket
    Type: String

Resources:
  ArtifactBucket:
    Type: AWS::S3::Bucket
    DeletionPolicy: Retain

Outputs:
  ArtifactBucket:
    Value: !Sub ${BucketName}
  BucketArn:  
    Value: !GetAtt ArtifactBucket.Arn
    Description: Arn of the new bucket

我在终端窗口中使用以下 cli 命令运行它:

aws cloudformation deploy --stack-name brendan-s3 \
--template-file ComposeEveryApp/create-s3-bucket.yaml \
--profile compose-staging \
--parameter-overrides BucketName=brendan

一切正常。这是 AWS 控制台中显示的新存储桶: 我想在终端窗口中显示新存储桶的 Arn(如上所示)。我该怎么做?

【问题讨论】:

    标签: amazon-web-services yaml command-line-interface amazon-cloudformation


    【解决方案1】:

    您可以使用describe-stacks 命令。它的返回值之一将是您的堆栈的输出。

    【讨论】:

      【解决方案2】:

      aws cloudformation deploy 命令只是指示 CloudFormation 服务开始部署,而不是真正等待部署完成。因此,Outputs 部分与您在 CLI 上执行的命令的返回值之间没有链接。

      如果您想要 cloudformation 堆栈的 Outputs,则必须使用 describe-stacks 命令,如果您只想输出,则需要使用 --query 将其与客户端过滤器结合使用那个特定的值。

      您可以在this SO question找到更多信息。

      【讨论】:

        猜你喜欢
        • 2012-04-20
        • 2020-06-03
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-03-18
        • 2011-05-22
        • 1970-01-01
        相关资源
        最近更新 更多