【问题标题】:Read CloudFormation stack API Gateway output in AWS CDK app在 AWS CDK 应用程序中读取 CloudFormation 堆栈 API 网关输出
【发布时间】:2020-03-09 12:41:49
【问题描述】:

可以通过 CLI 读取 CloudFormation 堆栈输出,如下所示:

aws cloudformation describe-stacks --stack-name TestStack --query "Stacks[0].Outputs[?OutputKey=='TestAPIGatewayEndpoint'].OutputValue" --output text

如何使用 Constructs Library 在 CDK 应用程序中执行此操作?具体来说,我正在尝试从已部署的堆栈中获取 API Gateway 端点并将其传递给另一个堆栈中的 Web 应用程序。

【问题讨论】:

    标签: aws-cdk


    【解决方案1】:

    最好使用 SSM 来存储和更新端点,在您的 CF 模板中创建一个 SSM,其值为 Api Gateway 端点,并在其他堆栈中使用该 SSM

    喜欢你的资源

    ApiEndPointConfig:
          Type: AWS::SSM::Parameter
          Properties:
            Name: /serverless/api-endpoint-config
            Type: String
            Value: !Sub "https://${apiGateway}.execute-api.${AWS::Region}.amazonaws.com/${apiGatewayStageName}"
    

    或者你可以使用输出参数来提取api网关url,比如

    Outputs:
      ApiEndPoint:
        Description: "API endpoint"
        Value: !Sub "https://${apiGateway}.execute-api.${AWS::Region}.amazonaws.com/${apiGatewayStageName}"
    

    我认为你不能直接从 CF 堆栈中提取,你必须使用输出参数或 SSM

    【讨论】:

    • SSM 将是共享端点的好解决方案。但我想了解的是如何通过 CDK Construct Library 从部署的 CF 堆栈中提取 API GW 端点值。
    猜你喜欢
    • 1970-01-01
    • 2019-11-29
    • 2020-06-04
    • 1970-01-01
    • 2013-04-16
    • 2021-02-18
    • 2021-06-04
    • 2020-09-29
    • 2020-10-31
    相关资源
    最近更新 更多