gpt4 book ai didi

aws-cloudformation - 通过 cloudformation 在 2 个 AWS 区域 VPC 之间进行 VPC 对等

转载 作者:行者123 更新时间:2023-12-03 07:36:28 26 4
gpt4 key购买 nike

我正在尝试在两个不同区域之间进行 vpc 对等互连。在这里我已经创建了资源,现在我只想将它们的 id 作为参数传递。在同一区域,我可以在两个 VPC 之间进行对等。但我在两个不同的区域收到错误,因为route_id不存在。

Error logs

我的模板如下:

AWSTemplateFormatVersion: '2010-09-09'
Description: ''
Parameters:
PeerVPCAccountId:
Type: String
Description: "Peer VPC Account ID"
Default: (Acc_id)
PeerVPCRegion:
Type: String
Description: "Peer Region"
Default: (region)
VPC1:
Description: VPC Id of DataPipeline
Type: AWS::EC2::VPC::Id
Default: (vpc_id)
VPC1CIDRRange:
Description: The IP address range of DataPipeline VPC.
Type: String
MinLength: '9'
MaxLength: '18'
Default: (vpc_range)
AllowedPattern: "(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})/(\\d{1,2})"
ConstraintDescription: must be a valid IP CIDR range of the form x.x.x.x/x.
VPC1PrivateSubnet1CIDRRange:
Description: The IP address range for Private Subnet 1 in DataPipeline.
Type: String
MinLength: '9'
MaxLength: '18'
Default: (vpc_subnet_range)
AllowedPattern: "(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})/(\\d{1,2})"
ConstraintDescription: must be a valid IP CIDR range of the form x.x.x.x/x.

VPC1Private1Route:
Description: RouteTableId of Private Subnet 1 for DataPipeline
Type: String
Default: (vpc_subnet_route_id)


VPC2:
Description: VPC Id of PII-Isolation Pipeline
Type: String
Default: (vpc_id)
VPC2CIDRRange:
Description: The IP address range of PII Pipeline VPC.
Type: String
MinLength: '9'
MaxLength: '18'
AllowedPattern: "(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})/(\\d{1,2})"
ConstraintDescription: must be a valid IP CIDR range of the form x.x.x.x/x.
Default: (vpc_range)
VPC2PrivateSubnet1CIDRRange:
Description: The IP address range for Private Subnet 1 in PII Pipeline.
Type: String
MinLength: '9'
MaxLength: '18'
AllowedPattern: "(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})/(\\d{1,2})"
ConstraintDescription: must be a valid IP CIDR range of the form x.x.x.x/x.
Default: (vpc_subnet_range)

VPC2Private1Route:
Description: RouteTableId of Private Subnet 1 for PII Pipeline
Type: String
Default: (vpc_subnet_route_id)

Resources:
peerRole:
Type: 'AWS::IAM::Role'
Properties:
AssumeRolePolicyDocument:
Statement:
- Principal:
AWS: !Ref PeerVPCAccountId
Action:
- 'sts:AssumeRole'
Effect: Allow
Path: /
Policies:
- PolicyName: root
PolicyDocument:
Version: 2012-10-17
Statement:
- Effect: Allow
Action: 'ec2:AcceptVpcPeeringConnection'
Resource: '*'

VPC1Private1PeeringRoute1:
Type: AWS::EC2::Route
Properties:
DestinationCidrBlock:
Ref: VPC2PrivateSubnet1CIDRRange
RouteTableId:
Ref: VPC1Private1Route
VpcPeeringConnectionId:
Ref: myVPCPeeringConnection




VPC2Private1PeeringRoute1:
Type: AWS::EC2::Route
Properties:
DestinationCidrBlock:
Ref: VPC1PrivateSubnet1CIDRRange
RouteTableId:
Ref: VPC2Private1Route
VpcPeeringConnectionId:
Ref: myVPCPeeringConnection


myVPCPeeringConnection:
Type: AWS::EC2::VPCPeeringConnection
Properties:
VpcId:
Ref: VPC1
PeerVpcId:
Ref: VPC2
PeerOwnerId:
Ref: PeerVPCAccountId
PeerRegion:
Ref: PeerVPCRegion
PeerRoleArn: !GetAtt
- peerRole
- Arn

我已经给出了模板想要的所有内容,但仍然显示此错误。有人可以帮忙修改一下或者指出错误吗?

最佳答案

Impurshu,我认为在理解 Cloudformation 模板只能应用于单个区域方面肯定存在一些困惑。但是,Cloudformation Stacksets 可以适用于多个区域,我什至找到了一个适用于您的问题的示例 VPC Peering across regions

关于aws-cloudformation - 通过 cloudformation 在 2 个 AWS 区域 VPC 之间进行 VPC 对等,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55254741/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com