是否可以使用 CloudFormation 模板输出 VPC 对等连接请求 ID?
Is it possible to output a VPC peering connection request id using CloudFormation template?
我写了一个 CloudFormation 模板,其中还创建了一个 VPC 对等连接。
如果您熟悉 VPC 对等连接,那么您就会知道创建后,会创建一个请求并等待批准。
我想将 VPC 对等连接请求 ID 添加到 CloudFormation 模板的输出部分。
这可能吗?我找不到路...
编辑:
这是模板的相关部分:
"Resources" : {
"VPC": {
"Type" : "AWS::EC2::VPC",
"Description" : "Choose which VPC the security groups should be deployed to",
"Properties" : {
"CidrBlock" : "172.51.0.0/16",
"EnableDnsSupport" : "true",
"EnableDnsHostnames" : "true",
"InstanceTenancy" : "default"
}
},
"VPCPeering" : {
"Type" : "AWS::EC2::VPCPeeringConnection",
"Properties" : {
"PeerVpcId" : "vpc-2XXXXXb",
"VpcId" : { "Ref" : "VPC" }
}
},
我将 Jenkins 与 CloudFormation 插件一起使用来创建新堆栈。
我希望新堆栈自动在堆栈创建的 VPC 和现有管理 VPC 之间创建对等。
我的计划是通过模板发布创建,然后一旦创建完成,我打算使用 AWS Cli(来自 Jenkins)接受对等请求,因为这一步需要我知道 vpc 对等请求id,然后我想使用模板的 "Outputs" : {}
部分输出它。
能做到吗?
不,这是不可能的。 CloudFormation 仅支持 VPC 对等互连,其中对等互连会自动获得批准(即在同一帐户内),或者您指定可以承担的角色以自动批准对等节点。
此 AWS article 描述了解决方法
"This article describes a procedure that allows a requester_account to both request and approve the peering connection. To do so, the peer_account must create a cross-account role that the requester_account can use to accept the peering request..."
我写了一个 CloudFormation 模板,其中还创建了一个 VPC 对等连接。
如果您熟悉 VPC 对等连接,那么您就会知道创建后,会创建一个请求并等待批准。
我想将 VPC 对等连接请求 ID 添加到 CloudFormation 模板的输出部分。
这可能吗?我找不到路...
编辑:
这是模板的相关部分:
"Resources" : {
"VPC": {
"Type" : "AWS::EC2::VPC",
"Description" : "Choose which VPC the security groups should be deployed to",
"Properties" : {
"CidrBlock" : "172.51.0.0/16",
"EnableDnsSupport" : "true",
"EnableDnsHostnames" : "true",
"InstanceTenancy" : "default"
}
},
"VPCPeering" : {
"Type" : "AWS::EC2::VPCPeeringConnection",
"Properties" : {
"PeerVpcId" : "vpc-2XXXXXb",
"VpcId" : { "Ref" : "VPC" }
}
},
我将 Jenkins 与 CloudFormation 插件一起使用来创建新堆栈。
我希望新堆栈自动在堆栈创建的 VPC 和现有管理 VPC 之间创建对等。
我的计划是通过模板发布创建,然后一旦创建完成,我打算使用 AWS Cli(来自 Jenkins)接受对等请求,因为这一步需要我知道 vpc 对等请求id,然后我想使用模板的 "Outputs" : {}
部分输出它。
能做到吗?
不,这是不可能的。 CloudFormation 仅支持 VPC 对等互连,其中对等互连会自动获得批准(即在同一帐户内),或者您指定可以承担的角色以自动批准对等节点。
此 AWS article 描述了解决方法
"This article describes a procedure that allows a requester_account to both request and approve the peering connection. To do so, the peer_account must create a cross-account role that the requester_account can use to accept the peering request..."