93 lines
2.4 KiB
YAML
93 lines
2.4 KiB
YAML
AWSTemplateFormatVersion: "2010-09-09"
|
|
Description: Create a simple vpc to be used with masTKO
|
|
Parameters:
|
|
vpcName:
|
|
Type: String
|
|
Default: mastko-vpc
|
|
Description: Unique name given to vpc components
|
|
IPV4CIDR:
|
|
Type: String
|
|
Default: "10.0.0.0/22"
|
|
Description: IPV4 CIDR block to be used for VPC.
|
|
Resources:
|
|
VPC:
|
|
Type: AWS::EC2::VPC
|
|
Properties:
|
|
CidrBlock: !Ref IPV4CIDR
|
|
InstanceTenancy: "default"
|
|
EnableDnsHostnames: "true"
|
|
EnableDnsSupport: "true"
|
|
Tags:
|
|
- Key: Name
|
|
Value: !Ref vpcName
|
|
IGW:
|
|
Type: AWS::EC2::InternetGateway
|
|
Properties:
|
|
Tags:
|
|
- Key: Name
|
|
Value: !Sub "${vpcName}-igw"
|
|
VpcIgwAttachment:
|
|
Type: AWS::EC2::VPCGatewayAttachment
|
|
Properties:
|
|
VpcId: !Ref VPC
|
|
InternetGatewayId: !Ref IGW
|
|
PublicSubnet:
|
|
Type: AWS::EC2::Subnet
|
|
Properties:
|
|
VpcId: !Ref VPC
|
|
CidrBlock: !Ref IPV4CIDR
|
|
Tags:
|
|
- Key: Name
|
|
Value: !Sub ${vpcName}-public-subnet
|
|
PublicRouteTable:
|
|
DependsOn:
|
|
- IGW
|
|
- VpcIgwAttachment
|
|
Type: AWS::EC2::RouteTable
|
|
Properties:
|
|
VpcId: !Ref VPC
|
|
Tags:
|
|
- Key: Name
|
|
Value: !Sub ${vpcName}-rtb
|
|
PublicRoute:
|
|
Type: AWS::EC2::Route
|
|
Properties:
|
|
DestinationCidrBlock: "0.0.0.0/0"
|
|
GatewayId: !Ref IGW
|
|
RouteTableId: !Ref PublicRouteTable
|
|
SubnetRouteTableAssociation:
|
|
Type: AWS::EC2::SubnetRouteTableAssociation
|
|
Properties:
|
|
RouteTableId: !Ref PublicRouteTable
|
|
SubnetId: !Ref PublicSubnet
|
|
# required to setup the Ec2 access through systems manager
|
|
SsmVpcEndpoint:
|
|
Type: AWS::EC2::VPCEndpoint
|
|
Properties:
|
|
ServiceName: !Sub "com.amazonaws.${AWS::Region}.ssm"
|
|
VpcId: !Ref VPC
|
|
VpcEndpointType: Interface
|
|
SubnetIds:
|
|
- !Ref PublicSubnet
|
|
SsmMessagesVpcEndpoint:
|
|
Type: AWS::EC2::VPCEndpoint
|
|
Properties:
|
|
ServiceName: !Sub "com.amazonaws.${AWS::Region}.ssmmessages"
|
|
VpcId: !Ref VPC
|
|
VpcEndpointType: Interface
|
|
SubnetIds:
|
|
- !Ref PublicSubnet
|
|
Ec2MessagesEndpoint:
|
|
Type: AWS::EC2::VPCEndpoint
|
|
Properties:
|
|
ServiceName: !Sub "com.amazonaws.${AWS::Region}.ec2messages"
|
|
VpcId: !Ref VPC
|
|
VpcEndpointType: Interface
|
|
SubnetIds:
|
|
- !Ref PublicSubnet
|
|
Outputs:
|
|
VpcId:
|
|
Value: !Ref VPC
|
|
SubnetId:
|
|
Value: !Ref PublicSubnet
|