Created
May 11, 2022 19:09
-
-
Save kmansoft/6b90b33bcf91eb0d493414ed6c3d9754 to your computer and use it in GitHub Desktop.
Creating two network interfaces, one with EIP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AWSTemplateFormatVersion: '2010-09-09' | |
Description: 'Test - simple 2 network interfaces' | |
Parameters: | |
KeyName: | |
Description: 'Key Pair name' | |
Type: 'AWS::EC2::KeyPair::KeyName' | |
Default: kman | |
Resources: | |
VPC: | |
Type: 'AWS::EC2::VPC' | |
Properties: | |
CidrBlock: '30.0.0.0/16' | |
EnableDnsSupport: true | |
EnableDnsHostnames: true | |
Tags: | |
- Key: Name | |
Value: 'simple' | |
SubnetPublic: | |
Type: 'AWS::EC2::Subnet' | |
Properties: | |
AvailabilityZone: !Select [0, !GetAZs ''] | |
CidrBlock: '30.0.1.0/24' | |
VpcId: !Ref VPC | |
Tags: | |
- Key: Name | |
Value: 'simple - public' | |
SubnetPrivate: | |
Type: 'AWS::EC2::Subnet' | |
Properties: | |
AvailabilityZone: !Select [0, !GetAZs ''] | |
CidrBlock: '30.0.2.0/24' | |
VpcId: !Ref VPC | |
Tags: | |
- Key: Name | |
Value: 'simple - private' | |
InternetGateway: | |
Type: 'AWS::EC2::InternetGateway' | |
Properties: | |
Tags: | |
- Key: Name | |
Value: 'simple' | |
VPCGatewayAttachment: | |
Type: 'AWS::EC2::VPCGatewayAttachment' | |
Properties: | |
VpcId: !Ref VPC | |
InternetGatewayId: !Ref InternetGateway | |
RouteTablePublic: | |
Type: 'AWS::EC2::RouteTable' | |
Properties: | |
VpcId: !Ref VPC | |
Tags: | |
- Key: Name | |
Value: 'simple' | |
RouteTableAssociation: | |
Type: 'AWS::EC2::SubnetRouteTableAssociation' | |
Properties: | |
SubnetId: !Ref SubnetPublic | |
RouteTableId: !Ref RouteTablePublic | |
RouteToInternet: | |
Type: 'AWS::EC2::Route' | |
Properties: | |
RouteTableId: !Ref RouteTablePublic | |
DestinationCidrBlock: '0.0.0.0/0' | |
GatewayId: !Ref InternetGateway | |
DependsOn: VPCGatewayAttachment | |
SecurityGroup: | |
Type: 'AWS::EC2::SecurityGroup' | |
Properties: | |
GroupDescription: 'Allow SSH and ping' | |
VpcId: !Ref VPC | |
SecurityGroupIngress: | |
- IpProtocol: tcp | |
FromPort: 22 | |
ToPort: 22 | |
CidrIp: '0.0.0.0/0' | |
- IpProtocol: icmp | |
FromPort: -1 | |
ToPort: -1 | |
CidrIp: '0.0.0.0/0' | |
Tags: | |
- Key: Name | |
Value: 'simple' | |
Host1: | |
Type: 'AWS::EC2::Instance' | |
Properties: | |
ImageId: 'ami-02541b8af977f6cdd' # Amazon Linux x86 | |
InstanceType: 't2.micro' | |
AvailabilityZone: !Select [0, !GetAZs ''] | |
KeyName: !Ref KeyName | |
NetworkInterfaces: | |
- SubnetId: !Ref SubnetPrivate | |
DeleteOnTermination: true | |
DeviceIndex: '0' | |
GroupSet: | |
- !Ref SecurityGroup | |
Tags: | |
- Key: Name | |
Value: 'simple - host1' | |
Host1Eth1: | |
Type: 'AWS::EC2::NetworkInterface' | |
Properties: | |
SubnetId: !Ref SubnetPublic | |
GroupSet: | |
- !Ref SecurityGroup | |
Tags: | |
- Key: Name | |
Value: 'simple - host1 eth1' | |
Host1Eth1Attachment: | |
Type: 'AWS::EC2::NetworkInterfaceAttachment' | |
Properties: | |
DeleteOnTermination: true | |
DeviceIndex: 1 | |
NetworkInterfaceId: !Ref Host1Eth1 | |
InstanceId: !Ref Host1 | |
ElasticIP: | |
Type: 'AWS::EC2::EIP' | |
Properties: | |
Domain: vpc | |
DependsOn: VPCGatewayAttachment | |
ElasticIPAssociation: | |
Type: 'AWS::EC2::EIPAssociation' | |
Properties: | |
EIP: !Ref ElasticIP | |
InstanceId: !Ref Host1 | |
NetworkInterfaceId: !Ref Host1Eth1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment