我目前正在使用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"
取决于您使用的是哪种构造。
对于低级构造,即所谓的CFN资源,可以使用ref
属性。对于高级构造,应检查API的xxx_id属性。在下面的示例中,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,
...
)