Amazon web services 不允许为VPC创建EC2实例
是否可以将EC2实例模板的VPCId定义为属性 我想做的是Amazon web services 不允许为VPC创建EC2实例,amazon-web-services,amazon-ec2,aws-sdk,amazon-cloudformation,amazon-vpc,Amazon Web Services,Amazon Ec2,Aws Sdk,Amazon Cloudformation,Amazon Vpc,是否可以将EC2实例模板的VPCId定义为属性 我想做的是 "Resources" : { "Ec2Instance" : { "Type" : "AWS::EC2::Instance", "Properties" : { "SecurityGroups": [ { "Ref": "AWSSecurityGroups" } ], "KeyName" : { "Ref" : "KeyName" }, "InstanceType" : { "Ref" :
"Resources" : {
"Ec2Instance" : {
"Type" : "AWS::EC2::Instance",
"Properties" : {
"SecurityGroups": [ { "Ref": "AWSSecurityGroups" } ],
"KeyName" : { "Ref" : "KeyName" },
"InstanceType" : { "Ref" : "InstanceType" },
"Tags" : [ { "Key" : "Name", "Value" : "Softnas-CF" }],
"ImageId" : { "Fn::FindInMap" : [ "RegionMap", { "Ref" : "AWS::Region" }, "AMI" ]},
"VpcId" : { "Ref" : "VPCId" },
.....some other stuff...
},
在我的参数中,我定义了VPCId
"Parameters" : {
....
"VPCId": {
"Description": "Name of an existing VPC ID",
"Type": "AWS::EC2::VPC::Id",
"ConstraintDescription": "must be the name of an existing VPC Id."
},
...
},
但是当我(通过.NETAPI)创建堆栈时,它会返回错误
遇到不支持的属性VpcId
这是不允许的,我找不到任何文档来执行此操作。做这个实验。如果使用模板创建,是否总是在默认VPC中创建EC2实例
Ec2Instance:Properties
使用子网
"Ec2Instance" : {
"Type" : "AWS::EC2::Instance",
"Properties" : {
"SecurityGroupIds" : [ { "Ref" : "xxxxx" } ],
"Tags" : [ { "Key" : "Name", "Value" : "xxx" } ],
"ImageId" : { "Fn::FindInMap" : [ "RegionMap", { "Ref" : "AWS::Region" }, "AMI" ]},
"SubnetId" : { "Ref" : "VpcSubnet" },
"InstanceType" : { "Ref" : "InstanceType" },
....
"VpcSubnet": {
"Description" : "Enter the VPC subnet",
"Type" : "AWS::EC2::Subnet::Id",
"Default" : ""
},
您不能将VPCId作为参数,而是可以指定一个子网ID(在VPC中,您需要EC2实例)。属性?我已经试过了,并更新了问题。这就是我的答案。