【问题标题】:Equivalent of !Ref in aws cdk相当于 aws cdk 中的 !Ref
【发布时间】:2020-03-18 16:51:36
【问题描述】:

我目前正在使用 aws-cdk 生成一个 cloudformation 模板,并且我想访问一个使用定义的参数

CfnParameter(self, id="Platform", type="String", default="My Platform")

带有参考(如 cloudformation 模板中的 !Ref Platform

你们中的任何人都知道什么是 aws cdk 中的 Ref 等价物。

这是我上面定义的参数的 yaml 等效项

Parameters:
  Platform:
    Type: String
    Default: "My Platform"

【问题讨论】:

    标签: python amazon-web-services amazon-cloudformation aws-cdk


    【解决方案1】:

    这取决于您使用的构造。

    对于低级构造,即所谓的 CFN 资源,您可以使用 ref 属性。 对于高级构造,您应该检查 xxx_id 属性的 API。 在下面的示例中,cfn 资源使用 ref 属性,而高级 VPC 构造使用 vpc_id 属性。

    my_vpc = _ec2.Vpc(
    tgw = _ec2.CfnTransitGateway(...)
    tgw_attachment = _ec2.CfnTransitGatewayAttachment(
                self,
                id="tgw-myvpc",
                transit_gateway_id=tgw.ref,
                vpc_id=my_vpc.vpc_id,
                ...
    )
    

    【讨论】:

      猜你喜欢
      • 2019-04-09
      • 2011-11-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-08-12
      • 1970-01-01
      相关资源
      最近更新 更多