gpt4 book ai didi

amazon-web-services - 子网 ID '10.0.4.0/24' 格式错误(服务 : AmazonEC2; Status Code: 400)

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

我在 AWS 上启动堆栈并收到错误时遇到错误:

The subnet ID '10.0.4.0/24' is malformed (Service: AmazonEC2; Status Code: 400)

CloudFormation Error

这是我的堆栈:

    Parameters:
KeyName:
Description: Nom de la paire de cle pour l'acces aux instances EC2 via SSH
Type: 'AWS::EC2::KeyPair::KeyName'
Default: 'CLEAWS'
LanIPPub:
Description: Adresse IP publique de l'entreprise
Type: String
Default: '82.64.110.122'
LanNetwork:
Description: Adresse du reseau local de l'entreprise a joindre via le VPN (CIDR Block)
Type: String
Default: '192.168.0.0/24'
VPCAddress:
Description: Adresse du VPC a creer (CIDR Block)
Type: String
Default: '10.0.0.0/16'
PrivateNetwork:
Description: Adresse du sous-reseau prive a creer (CIDR Block)
Type: String
Default: '10.0.1.0/24'
PublicNetwork:
Description: Adresse du sous-reseau public a creer (CIDR Block)
Type: String
Default: '10.0.4.0/24'

AMIID:
Description: ID de l'instance EC2 (AMI) a creer pour l'intranet
Type: String
Default: 'ami-0c6ebbd55ab05f070'
IPIntranet:
Description: IP a definir pour l'instance intranet situee dans le subnet prive
Type: String
Default: '172.32.1.80'

Resources:
VPC:
Type: 'AWS::EC2::VPC'
Properties:
CidrBlock: !Ref VPCAddress
EnableDnsHostnames: true
EnableDnsSupport: true
Tags:
- Key: Name
Value: 'vpc-infra'
PrivateSubnet:
Type: 'AWS::EC2::Subnet'
Properties:
VpcId:
Ref: VPC
AvailabilityZone: eu-west-3c
CidrBlock: !Ref PrivateNetwork
Tags:
- Key: Name
Value: 'sub-priv-infra'
InternetGateway:
Type: AWS::EC2::InternetGateway
Properties:
Tags:
- Key: Name
Value: 'infra-igw'
AttachInternetGateway:
Type: 'AWS::EC2::VPCGatewayAttachment'
Properties:
VpcId: !Ref VPC
InternetGatewayId: !Ref InternetGateway
NatEip:
Type: AWS::EC2::EIP
Properties:
Domain: vpc
NatGateway:
DependsOn: AttachInternetGateway
Type: AWS::EC2::NatGateway
Properties:
AllocationId: !GetAtt NatEip.AllocationId
SubnetId: !Ref PublicNetwork
Tags:
- Key: Name
Value: 'infra-gwnat'
RouteTablePrivateSubnet:
Type: 'AWS::EC2::RouteTable'
Properties:
VpcId: !Ref VPC
Tags:
- Key: Name
Value: 'infra-route-pv-sub'
RoutePrivateSubnetVPNAccess:
Type: AWS::EC2::Route
Properties:
RouteTableId: !Ref RouteTablePrivateSubnet
DestinationCidrBlock: !Ref LanNetwork
GatewayId: !Ref VPNGateway
DependsOn: AttachVpnGateway
RoutePrivateSubnetWanAccess:
Type: AWS::EC2::Route
Properties:
RouteTableId: !Ref RouteTablePrivateSubnet
DestinationCidrBlock: 0.0.0.0/0
NatGatewayId: !Ref NatGateway
DependsOn: NatEip
PrivateSubnetRouteTableAssociation:
Type: AWS::EC2::SubnetRouteTableAssociation
Properties:
SubnetId: !Ref PrivateSubnet
RouteTableId: !Ref RouteTablePrivateSubnet
DependsOn:
- PrivateSubnet
- RouteTablePrivateSubnet
SecGrpPriv:
Type: AWS::EC2::SecurityGroup
Properties:
GroupDescription: HTTP and SSH
SecurityGroupIngress:
- IpProtocol: icmp
FromPort: -1
ToPort: -1
CidrIp: !Ref LanNetwork
- IpProtocol: tcp
FromPort: 22
ToPort: 22
CidrIp: !Ref LanNetwork
- IpProtocol: tcp
FromPort: 80
ToPort: 80
CidrIp: !Ref LanNetwork
VpcId: !Ref VPC
Tags:
- Key: Name
Value: infra-grp-sec-priv
CustomerGateway:
Type: AWS::EC2::CustomerGateway
Properties:
Type: ipsec.1
BgpAsn: 65000
IpAddress: !Ref LanIPPub
Tags:
- Key: Name
Value: lan-gw
VPNGateway:
Type: AWS::EC2::VPNGateway
Properties:
Type: ipsec.1
Tags:
- Key: Name
Value: vpn-gw
AttachVpnGateway:
Type: AWS::EC2::VPCGatewayAttachment
Properties:
VpcId: !Ref VPC
VpnGatewayId: !Ref VPNGateway
VPNConnection:
Type: AWS::EC2::VPNConnection
Properties:
Type: ipsec.1
StaticRoutesOnly: true
CustomerGatewayId: !Ref CustomerGateway
VpnGatewayId: !Ref VPNGateway
Tags:
- Key: Name
Value: vpn-aws-to-lan
ConnectionRoute:
Type: AWS::EC2::VPNConnectionRoute
Properties:
DestinationCidrBlock: !Ref LanNetwork
VpnConnectionId: !Ref VPNConnection
IntranetEC2:
Type: AWS::EC2::Instance
DependsOn: ConnectionRoute
Properties:
ImageId: !Ref AMIID
InstanceType: t2.micro
PrivateIpAddress: !Ref IPIntranet
KeyName: !Ref KeyName
SubnetId: !Ref PrivateSubnet
SecurityGroupIds:
- !Ref SecGrpPriv
UserData:
Fn::Base64:
!Sub |
#!/bin/bash
sudo su apt-get update && apt-get upgrade -y

<!-- end snippet -->

AMIID:
Description: ID de l'instance EC2 (AMI) a creer pour l'intranet
Type: String
Default: 'ami-0c6ebbd55ab05f070'
IPIntranet:
Description: IP a definir pour l'instance intranet situee dans le subnet prive
Type: String
Default: '172.32.1.80'

Resources:
VPC:
Type: 'AWS::EC2::VPC'
Properties:
CidrBlock: !Ref VPCAddress
EnableDnsHostnames: true
EnableDnsSupport: true
Tags:
- Key: Name
Value: 'vpc-infra'
PrivateSubnet:
Type: 'AWS::EC2::Subnet'
Properties:
VpcId:
Ref: VPC
AvailabilityZone: eu-west-3c
CidrBlock: !Ref PrivateNetwork
Tags:
- Key: Name
Value: 'sub-priv-infra'
InternetGateway:
Type: AWS::EC2::InternetGateway
Properties:
Tags:
- Key: Name
Value: 'infra-igw'
AttachInternetGateway:
Type: 'AWS::EC2::VPCGatewayAttachment'
Properties:
VpcId: !Ref VPC
InternetGatewayId: !Ref InternetGateway
NatEip:
Type: AWS::EC2::EIP
Properties:
Domain: vpc
NatGateway:
DependsOn: AttachInternetGateway
Type: AWS::EC2::NatGateway
Properties:
AllocationId: !GetAtt NatEip.AllocationId
SubnetId: !Ref PublicNetwork
Tags:
- Key: Name
Value: 'infra-gwnat'
RouteTablePrivateSubnet:
Type: 'AWS::EC2::RouteTable'
Properties:
VpcId: !Ref VPC
Tags:
- Key: Name
Value: 'infra-route-pv-sub'
RoutePrivateSubnetVPNAccess:
Type: AWS::EC2::Route
Properties:
RouteTableId: !Ref RouteTablePrivateSubnet
DestinationCidrBlock: !Ref LanNetwork
GatewayId: !Ref VPNGateway
DependsOn: AttachVpnGateway
RoutePrivateSubnetWanAccess:
Type: AWS::EC2::Route
Properties:
RouteTableId: !Ref RouteTablePrivateSubnet
DestinationCidrBlock: 0.0.0.0/0
NatGatewayId: !Ref NatGateway
DependsOn: NatEip
PrivateSubnetRouteTableAssociation:
Type: AWS::EC2::SubnetRouteTableAssociation
Properties:
SubnetId: !Ref PrivateSubnet
RouteTableId: !Ref RouteTablePrivateSubnet
DependsOn:
- PrivateSubnet
- RouteTablePrivateSubnet
SecGrpPriv:
Type: AWS::EC2::SecurityGroup
Properties:
GroupDescription: HTTP and SSH
SecurityGroupIngress:
- IpProtocol: icmp
FromPort: -1
ToPort: -1
CidrIp: !Ref LanNetwork
- IpProtocol: tcp
FromPort: 22
ToPort: 22
CidrIp: !Ref LanNetwork
- IpProtocol: tcp
FromPort: 80
ToPort: 80
CidrIp: !Ref LanNetwork
VpcId: !Ref VPC
Tags:
- Key: Name
Value: infra-grp-sec-priv
CustomerGateway:
Type: AWS::EC2::CustomerGateway
Properties:
Type: ipsec.1
BgpAsn: 65000
IpAddress: !Ref LanIPPub
Tags:
- Key: Name
Value: lan-gw
VPNGateway:
Type: AWS::EC2::VPNGateway
Properties:
Type: ipsec.1
Tags:
- Key: Name
Value: vpn-gw
AttachVpnGateway:
Type: AWS::EC2::VPCGatewayAttachment
Properties:
VpcId: !Ref VPC
VpnGatewayId: !Ref VPNGateway
VPNConnection:
Type: AWS::EC2::VPNConnection
Properties:
Type: ipsec.1
StaticRoutesOnly: true
CustomerGatewayId: !Ref CustomerGateway
VpnGatewayId: !Ref VPNGateway
Tags:
- Key: Name
Value: vpn-aws-to-lan
ConnectionRoute:
Type: AWS::EC2::VPNConnectionRoute
Properties:
DestinationCidrBlock: !Ref LanNetwork
VpnConnectionId: !Ref VPNConnection
IntranetEC2:
Type: AWS::EC2::Instance
DependsOn: ConnectionRoute
Properties:
ImageId: !Ref AMIID
InstanceType: t2.micro
PrivateIpAddress: !Ref IPIntranet
KeyName: !Ref KeyName
SubnetId: !Ref PrivateSubnet
SecurityGroupIds:
- !Ref SecGrpPriv
UserData:
Fn::Base64:
!Sub |
#!/bin/bash
sudo su apt-get update && apt-get upgrade -y

你能帮我一下吗?谢谢

最佳答案

这不是子网 ID,而是子网的 CIDR block 。您应该使用对 PublicSubnet 的引用,而不是 PublicNetwork

关于amazon-web-services - 子网 ID '10.0.4.0/24' 格式错误(服务 : AmazonEC2; Status Code: 400),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71227352/

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