1 infrastructure amazon-web-services aws-cloudformation amazon-vpc
好吧,我正在尝试在AWS中找到一个云形态模板.
我需要在哪里创建具有单个子网和实例的三个VPC.你有网关的地方有2个单向从vpc到网关和一个双向连接,如下所示:

您可以利用AWS Quick Start的Amazon VPC Architecture 模板快速开始使用样板VPC架构.此AWS支持的模板创建一个VPC,其中包含每个指定可用区内的公共(双向)和专用(单向,仅出站Internet)子网(您提供2-4个可用区作为参数).我建议从快速入门开始,然后在必要时进行自定义以更好地满足您的特定需求.
对于您的用例,您可以指定2个可用区,然后在每个AZ中使用SubnetA和SubnetB中的私有子网,以及SubnetC的其中一个AZ中的Public Subnet.
(注意:我建议不要为单个应用程序创建3个单独的VPC.不同的子网提供足够的网络隔离,创建3个独立的VPC复制许多不必要的额外资源,如Internet Getways,每个AWS账户每个区域限制为5个VPC. )
这是一个完整的工作示例,它将Quick Start模板直接用作嵌套堆栈:
Description: Create a VPC with 2 private and 1 public subnets, with an EC2 instance in each.
Mappings:
RegionMap:
us-east-1:
# amzn-ami-hvm-2016.09.1.20161221-x86_64-gp2
"opal": "ami-9be6f38c"
"rstudio": "ami-9be6f38c"
Parameters:
InstanceType:
Description: EC2 instance type
Type: String
Default: t2.medium
AllowedValues: [t2.nano, t2.micro, t2.small, t2.medium, t2.large, t2.xlarge, t2.2xlarge,
m4.large, m4.xlarge, m4.2xlarge, m4.4xlarge, m4.10xlarge, m4.16xlarge,
c4.large, c4.xlarge, c4.2xlarge, c4.4xlarge, c4.8xlarge,
r4.large, r4.xlarge, r4.2xlarge, r4.4xlarge, r4.8xlarge, r4.16xlarge]
ConstraintDescription: Please choose a valid instance type.
AvailabilityZones:
Description: List of 2 Availability Zones to use for the subnets in the VPC.
Type: "List<AWS::EC2::AvailabilityZone::Name>"
KeyPairName:
Description: Public/private key pair to provide SSH access to the EC2 instances.
Type: "AWS::EC2::KeyPair::KeyName"
Resources:
VPCStack:
Type: AWS::CloudFormation::Stack
Properties:
TemplateURL: 'https://s3.amazonaws.com/quickstart-reference/aws/vpc/latest/templates/aws-vpc.template'
Parameters:
AvailabilityZones: !Join [',', !Ref AvailabilityZones]
KeyPairName: !Ref KeyPairName
NumberOfAZs: 2
SecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
GroupDescription: VPC Security Group
VpcId: !GetAtt VPCStack.Outputs.VPCID
OpalServer1:
Type: AWS::EC2::Instance
Properties:
ImageId: !FindInMap [ RegionMap, !Ref "AWS::Region", opal]
InstanceType: !Ref InstanceType
SecurityGroupIds: [!Ref SecurityGroup]
SubnetId: !GetAtt VPCStack.Outputs.PrivateSubnet1AID
KeyName: !Ref KeyPairName
OpalServer2:
Type: AWS::EC2::Instance
Properties:
ImageId: !FindInMap [ RegionMap, !Ref "AWS::Region", opal]
InstanceType: !Ref InstanceType
SecurityGroupIds: [!Ref SecurityGroup]
SubnetId: !GetAtt VPCStack.Outputs.PrivateSubnet2AID
KeyName: !Ref KeyPairName
RStudioClient:
Type: AWS::EC2::Instance
Properties:
ImageId: !FindInMap [ RegionMap, !Ref "AWS::Region", rstudio]
InstanceType: !Ref InstanceType
SecurityGroupIds: [!Ref SecurityGroup]
SubnetId: !GetAtt VPCStack.Outputs.PublicSubnet1ID
KeyName: !Ref KeyPairName
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1083 次 |
| 最近记录: |