[英]How to assign a specific private ip (pre-determined ip base on my CIDR and subnet) when create ec2 using Cloudformation script
這是我使用的代碼,仍然無法正常工作。 我正在嘗試使用 CloudFormation 模板創建即時,並使用特定的私有 ip 地址啟動。 請幫助我缺少什么:我在哪里會提到私有 ip 我需要將它分配給 CloudFormation 模板中的即時?
"Ec2Instance" : {
"Type" : "AWS::EC2::Instance",
"Properties" : {
"ImageId" : { "Fn::FindInMap" : [ "RegionMap", { "Ref" : "AWS::Region" }, "AMI" ]},
"KeyName" : { "Ref" : "KeyName" },
"NetworkInterfaces": [ {
"DeviceIndex": "0",
"PrivateIpAddress" : String,
} ]
}
}```
PrivateIpAddress
是您指定私有 Ip 的位置。 最好還指定SubnetId
,因為您的 IP 必須與您放置實例的子網的 CIDR 范圍相匹配。
例子:
InstanceWithFixedPirivateIp:
Type: AWS::EC2::Instance
Properties:
ImageId: ami-07ebfd5b3428b6f4d
InstanceType: t2.micro
Monitoring: false
NetworkInterfaces:
- DeviceIndex: 0
PrivateIpAddress: 172.31.80.12
SubnetId: subnet-a9e16487 # CIDR 172.31.80.0/20
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.