Advertisement
Guest User

Untitled

a guest
Aug 19th, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.68 KB | None | 0 0
  1. AWSTemplateFormatVersion: '2010-09-09'
  2. Parameters:
  3. projectName:
  4. Type: String
  5. eC2KeyPair:
  6. Type: AWS::EC2::KeyPair::KeyName
  7. Resources:
  8. vpc:
  9. Type: 'AWS::EC2::VPC'
  10. Properties:
  11. CidrBlock: 10.0.0.0/16
  12. EnableDnsSupport: 'true'
  13. EnableDnsHostnames: 'true'
  14. InstanceTenancy: default
  15. Tags:
  16. - Key: Name
  17. Value: !Sub ${projectName}-vpc
  18. igw:
  19. Type: "AWS::EC2::InternetGateway"
  20. Properties:
  21. Tags:
  22. - Key: Name
  23. Value: !Sub ${projectName}-igw
  24. attachmentigw:
  25. Type: "AWS::EC2::VPCGatewayAttachment"
  26. Properties:
  27. VpcId: !Ref vpc
  28. InternetGatewayId: !Ref igw
  29. rtb:
  30. Type: "AWS::EC2::RouteTable"
  31. Properties:
  32. VpcId: !Ref vpc
  33. Tags:
  34. - Key: Name
  35. Value: !Sub ${projectName}-rtb
  36. rtbRoute:
  37. Type: "AWS::EC2::Route"
  38. Properties:
  39. DestinationCidrBlock: 0.0.0.0/0
  40. GatewayId: !Ref igw
  41. RouteTableId: !Ref rtb
  42. subnet1:
  43. Type: 'AWS::EC2::Subnet'
  44. Properties:
  45. VpcId: !Ref vpc
  46. AvailabilityZone: 'ap-northeast-1a'
  47. CidrBlock: 10.0.0.0/24
  48. Tags:
  49. - Key: Name
  50. Value: !Sub ${projectName}-public-subnet01
  51. subnet2:
  52. Type: 'AWS::EC2::Subnet'
  53. Properties:
  54. VpcId: !Ref vpc
  55. AvailabilityZone: 'ap-northeast-1c'
  56. CidrBlock: 10.0.1.0/24
  57. Tags:
  58. - Key: Name
  59. Value: !Sub ${projectName}-public-subnet02
  60. publicSubnet1:
  61. Type: "AWS::EC2::SubnetRouteTableAssociation"
  62. Properties:
  63. SubnetId: !Ref subnet1
  64. RouteTableId: !Ref rtb
  65. publicSubnet2:
  66. Type: "AWS::EC2::SubnetRouteTableAssociation"
  67. Properties:
  68. SubnetId: !Ref subnet2
  69. RouteTableId: !Ref rtb
  70. ec2Securitygroup:
  71. Type: "AWS::EC2::SecurityGroup"
  72. Properties:
  73. VpcId: !Ref vpc
  74. GroupName: !Sub ${projectName}-ec2-sg
  75. GroupDescription: !Sub ${projectName}-ec2-sg
  76. SecurityGroupIngress:
  77. - IpProtocol: tcp
  78. FromPort: '3389'
  79. ToPort: '3389'
  80. CidrIp: 0.0.0.0/0
  81. Tags:
  82. - Key: Name
  83. Value: !Sub ${projectName}-ec2-sg
  84. windowsServer:
  85. Type: "AWS::EC2::Instance"
  86. Properties:
  87. KeyName: !Ref eC2KeyPair
  88. ImageId: ami-0bc8442658e36a4d2 # Windows_Server-2016-Japanese-Full-Base-2019.07.12
  89. InstanceType: t3.small
  90. BlockDeviceMappings:
  91. - DeviceName: /dev/sda1
  92. Ebs:
  93. VolumeType: gp2
  94. VolumeSize: 30
  95. AvailabilityZone: ap-northeast-1a
  96. NetworkInterfaces:
  97. - AssociatePublicIpAddress: true
  98. DeviceIndex: "0"
  99. GroupSet:
  100. - !Ref ec2Securitygroup
  101. SubnetId: !Ref subnet1
  102. Tags:
  103. - Key: Name
  104. Value: !Sub ${projectName}-ec2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement