gpt4 book ai didi

aws-cloudformation - 云信息 : VPC security groups may not be used for a non-VPC launch

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

以下是我的模板,包含 vpc、子网、安全组、启动配置和自动缩放。我能够创建 lauch 配置和自动缩放组,但我的自动缩放组无法启动实例。我遇到VPC安全组可能无法用于非VPC启动错误。

   {
"myvpc": {
"Type": "AWS: : EC2: : VPC",
"Properties": {
"CidrBlock": "10.0.0.0/16",
"EnableDnsSupport": "true",
"EnableDnsHostnames": "true",
"InstanceTenancy": "default"
}
},
"mySubnet": {
"Type": "AWS::EC2::Subnet",
"Properties": {
"VpcId": {
"Ref": "myvpc"
},
"CidrBlock": "10.0.1.0/24",
"AvailabilityZone": "us-east-1a",
"Tags": [
{
"Key": "mysubnet",
"Value": "mysubnet"
}
]
}
},
"ec2Security": {
"Type": "AWS::EC2::SecurityGroup",
"Properties": {
"GroupDescription": "my CloudFormation security group",
"VpcId": {
"Ref": "myvpc"
},
"SecurityGroupIngress": [
{
"IpProtocol": "-1",
"FromPort": "-1",
"ToPort": "-1",
"CidrIp": "0.0.0.0/0"
}
],
"SecurityGroupEgress": [
{
"IpProtocol": "-1",
"FromPort": "-1",
"ToPort": "-1",
"CidrIp": "0.0.0.0/0"
}
]
}
},
"WebServerGroup": {
"Type": "AWS::AutoScaling::AutoScalingGroup",
"Properties": {
"AvailabilityZones": [
{
"Fn::GetAtt": [
"mySubnet",
"AvailabilityZone"
]
}
],
"LaunchConfigurationName": {
"Ref": "WebServerLaunchConfig"
},
"MinSize": "1",
"MaxSize": "10",
"DesiredCapacity": {
"Ref": "DesiredInstances"
}
}
},
"WebServerLaunchConfig": {
"Type": "AWS::AutoScaling::LaunchConfiguration",
"Properties": {
"ImageId": "ami-xxxxx",
"InstanceType": {
"Ref": "InstanceType"
},
"KeyName": "xxxxxxxx",
"SecurityGroups": [
{
"Ref": "ec2Security"
}
]
}
}
}

我想使用 Cloudformation 在 VPC 中的不同可用区启动多个实例。

我在这里做错了什么。

谢谢。

最佳答案

此模板中缺少 VPC 本身:

"VpcId" : {"Ref" : "myvpc"},

此代码意味着您应该在此模板中创建名为“myvpc”的 vpc。就像“ec2Security”或“mySubnet”一样。如果您不想创建新的 VPC,请指定您的实际 VpcId 而不是引用。

例如:

"VpcId" : "vpc-a6a673c1"

有关如何正确指定 VpcId 的更多详细信息,请参见此处: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-security-group.html#cfn-ec2-securitygroup-vpcid

关于aws-cloudformation - 云信息 : VPC security groups may not be used for a non-VPC launch,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38474247/

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