Skip to content

Instantly share code, notes, and snippets.

@sakamaki-kazuyoshi
Created August 13, 2019 09:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sakamaki-kazuyoshi/adfdffed6acfb4d6870ae5ff82baabaf to your computer and use it in GitHub Desktop.
Save sakamaki-kazuyoshi/adfdffed6acfb4d6870ae5ff82baabaf to your computer and use it in GitHub Desktop.
AWSTemplateFormatVersion: '2010-09-09'
Parameters:
ProjectName:
Type: String
Default: 'test'
EC2KeyPair:
Type: AWS::EC2::KeyPair::KeyName
AccessSourceCIDR:
Description: CIDR accessing the Tableau Server
Type: String
Default: '0.0.0.0/0'
Resources:
vpc:
Type: 'AWS::EC2::VPC'
Properties:
CidrBlock: 10.0.0.0/16
EnableDnsSupport: 'true'
EnableDnsHostnames: 'true'
InstanceTenancy: default
Tags:
- Key: Name
Value: !Sub ${ProjectName}-vpc
igw:
Type: 'AWS::EC2::InternetGateway'
Properties:
Tags:
- Key: Name
Value: !Sub ${ProjectName}-igw
attachmentIGW:
Type: 'AWS::EC2::VPCGatewayAttachment'
Properties:
InternetGatewayId: !Ref igw
VpcId: !Ref vpc
rtb:
Type: "AWS::EC2::RouteTable"
Properties:
VpcId: !Ref vpc
Tags:
- Key: Name
Value: !Sub ${ProjectName}-rtb
rtbRoute:
Type: "AWS::EC2::Route"
Properties:
DestinationCidrBlock: 0.0.0.0/0
GatewayId: !Ref igw
RouteTableId: !Ref rtb
subnet1:
Type: 'AWS::EC2::Subnet'
Properties:
VpcId: !Ref vpc
AvailabilityZone: 'ap-northeast-1a'
CidrBlock: 10.0.0.0/24
Tags:
- Key: Name
Value: !Sub ${ProjectName}-public-subnet01
subnet2:
Type: 'AWS::EC2::Subnet'
Properties:
VpcId: !Ref vpc
AvailabilityZone: 'ap-northeast-1c'
CidrBlock: 10.0.1.0/24
Tags:
- Key: Name
Value: !Sub ${ProjectName}-public-subnet02
publicSubnet1:
Type: "AWS::EC2::SubnetRouteTableAssociation"
Properties:
SubnetId: !Ref subnet1
RouteTableId: !Ref rtb
publicSubnet2:
Type: "AWS::EC2::SubnetRouteTableAssociation"
Properties:
SubnetId: !Ref subnet2
RouteTableId: !Ref rtb
ec2Securitygroup:
Type: AWS::EC2::SecurityGroup
Properties:
GroupName: !Sub ${ProjectName}-ec2-sg
GroupDescription: !Sub ${ProjectName}-ec2-sg
VpcId: !Ref vpc
SecurityGroupIngress:
- IpProtocol: tcp
FromPort: '22'
ToPort: '22'
CidrIp : !Ref AccessSourceCIDR
- IpProtocol: tcp
FromPort: '8850'
ToPort: '8850'
CidrIp : !Ref AccessSourceCIDR
- IpProtocol: tcp
FromPort: '80'
ToPort: '80'
CidrIp : !Ref AccessSourceCIDR
Tags:
- Key: Name
Value: !Sub ${ProjectName}-ec2-sg
ec2:
Type: "AWS::EC2::Instance"
Properties:
KeyName: !Ref EC2KeyPair
ImageId: ami-0c3fd0f5d33134a76 # Amazon Linux 2
InstanceType: t3.2xlarge # C5.4xlarge、m5.4xlarge、r5.4xlarge..
BlockDeviceMappings:
- DeviceName: /dev/xvda
Ebs:
VolumeType: gp2
VolumeSize: 30
AvailabilityZone: ap-northeast-1a
NetworkInterfaces:
- AssociatePublicIpAddress: true
DeviceIndex: "0"
GroupSet:
- !Ref ec2Securitygroup
SubnetId: !Ref subnet1
Tags:
- Key: Name
Value: !Sub ${ProjectName}-ec2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment