AWSTemplateFormatVersion: 2010-09-09 # CloudFormationDesigner図示用設定 Metadata: 'AWS::CloudFormation::Designer': 14efaa40-d75f-40a7-9ad5-93abe77f4357: size: width: 780 height: 420 position: x: 220 'y': 230 z: 0 embeds: - 20ca1d51-5cd4-43c0-a8ed-2ea39b92ce06 - 59d56056-f29e-4617-a591-9691292da3a1 - ea94d936-b782-4f54-b96d-4a02920e4fa6 - f8a81dbb-3f58-4a71-b273-b7e1e1a9022e - 02197462-8977-4b71-989e-fc8d3dd53b18 - 569b84b2-d2b0-46d7-8804-9015d73b6095 - 2bee549a-33db-45cf-8e24-f4f057cb9287 ce6bd251-1ba4-4006-8870-7dd334714700: size: width: 60 height: 60 position: x: 670 'y': 430 z: 2 parent: 569b84b2-d2b0-46d7-8804-9015d73b6095 embeds: [] isassociatedwith: - 59d56056-f29e-4617-a591-9691292da3a1 iscontainedinside: - 569b84b2-d2b0-46d7-8804-9015d73b6095 20ca1d51-5cd4-43c0-a8ed-2ea39b92ce06: size: width: 60 height: 60 position: x: 420 'y': 580 z: 1 parent: 14efaa40-d75f-40a7-9ad5-93abe77f4357 embeds: [] d98bc273-4230-486a-b03c-5f6121adc324: size: width: 60 height: 60 position: x: 420 'y': 430 z: 2 parent: 2bee549a-33db-45cf-8e24-f4f057cb9287 embeds: [] isassociatedwith: - 20ca1d51-5cd4-43c0-a8ed-2ea39b92ce06 - 59d56056-f29e-4617-a591-9691292da3a1 iscontainedinside: - 2bee549a-33db-45cf-8e24-f4f057cb9287 569b84b2-d2b0-46d7-8804-9015d73b6095: size: width: 190 height: 180 position: x: 600 'y': 360 z: 1 parent: 14efaa40-d75f-40a7-9ad5-93abe77f4357 embeds: - ce6bd251-1ba4-4006-8870-7dd334714700 iscontainedinside: - 14efaa40-d75f-40a7-9ad5-93abe77f4357 466837e6-596c-462d-aaa1-a4df51b7162e: size: width: 60 height: 60 position: x: 1020 'y': 260 z: 0 embeds: [] f8a81dbb-3f58-4a71-b273-b7e1e1a9022e: size: width: 140 height: 140 position: x: 830 'y': 380 z: 1 parent: 14efaa40-d75f-40a7-9ad5-93abe77f4357 embeds: - 62f2589c-4cb2-445b-95ac-0c27f17cb3d4 iscontainedinside: - 14efaa40-d75f-40a7-9ad5-93abe77f4357 fdc98222-edff-4d8d-b5c5-1fe6198ef2f2: source: id: f8a81dbb-3f58-4a71-b273-b7e1e1a9022e target: id: 569b84b2-d2b0-46d7-8804-9015d73b6095 z: 1 62f2589c-4cb2-445b-95ac-0c27f17cb3d4: size: width: 60 height: 60 position: x: 870 'y': 420 z: 2 parent: f8a81dbb-3f58-4a71-b273-b7e1e1a9022e embeds: [] isassociatedwith: - 466837e6-596c-462d-aaa1-a4df51b7162e iscontainedinside: - f8a81dbb-3f58-4a71-b273-b7e1e1a9022e 5b91f061-300f-4a95-b5d0-5cdf698270a6: source: id: 14efaa40-d75f-40a7-9ad5-93abe77f4357 target: id: 466837e6-596c-462d-aaa1-a4df51b7162e z: 0 ea94d936-b782-4f54-b96d-4a02920e4fa6: size: width: 60 height: 60 position: x: 670 'y': 270 z: 1 parent: 14efaa40-d75f-40a7-9ad5-93abe77f4357 embeds: [] iscontainedinside: - 14efaa40-d75f-40a7-9ad5-93abe77f4357 59d56056-f29e-4617-a591-9691292da3a1: size: width: 60 height: 60 position: x: 420 'y': 270 z: 1 parent: 14efaa40-d75f-40a7-9ad5-93abe77f4357 embeds: [] iscontainedinside: - 14efaa40-d75f-40a7-9ad5-93abe77f4357 2bee549a-33db-45cf-8e24-f4f057cb9287: size: width: 130 height: 130 position: x: 390 'y': 380 z: 1 parent: 14efaa40-d75f-40a7-9ad5-93abe77f4357 embeds: - d98bc273-4230-486a-b03c-5f6121adc324 iscontainedinside: - 569b84b2-d2b0-46d7-8804-9015d73b6095 - 02197462-8977-4b71-989e-fc8d3dd53b18 02197462-8977-4b71-989e-fc8d3dd53b18: size: width: 100 height: 100 position: x: 240 'y': 400 z: 1 parent: 14efaa40-d75f-40a7-9ad5-93abe77f4357 embeds: [] iscontainedinside: - 14efaa40-d75f-40a7-9ad5-93abe77f4357 # 以下、要素毎の設定 Resources: # ネットワーク設定 TestVPC: Type: 'AWS::EC2::VPC' Properties: CidrBlock: 192.168.0.0/16 Metadata: 'AWS::CloudFormation::Designer': id: 14efaa40-d75f-40a7-9ad5-93abe77f4357 TestInternetGateway: Type: 'AWS::EC2::InternetGateway' Properties: {} Metadata: 'AWS::CloudFormation::Designer': id: 466837e6-596c-462d-aaa1-a4df51b7162e TestVPCGatewayAttachment: Type: 'AWS::EC2::VPCGatewayAttachment' Properties: VpcId: !Ref TestVPC InternetGatewayId: !Ref TestInternetGateway Metadata: 'AWS::CloudFormation::Designer': id: 5b91f061-300f-4a95-b5d0-5cdf698270a6 TestSubnet1: Type: 'AWS::EC2::Subnet' Properties: VpcId: !Ref TestVPC AvailabilityZone: ap-northeast-1a CidrBlock: 192.168.10.0/24 Metadata: 'AWS::CloudFormation::Designer': id: 569b84b2-d2b0-46d7-8804-9015d73b6095 TestSubnet2: Type: 'AWS::EC2::Subnet' Properties: VpcId: !Ref TestVPC AvailabilityZone: ap-northeast-1c CidrBlock: 192.168.20.0/24 Metadata: 'AWS::CloudFormation::Designer': id: 02197462-8977-4b71-989e-fc8d3dd53b18 TestDBSubnetGroup: Type: 'AWS::RDS::DBSubnetGroup' Properties: SubnetIds: - !Ref TestSubnet1 - !Ref TestSubnet2 DBSubnetGroupDescription: testDBSubnetGroup Metadata: 'AWS::CloudFormation::Designer': id: 2bee549a-33db-45cf-8e24-f4f057cb9287 TestRouteTable: Type: 'AWS::EC2::RouteTable' Properties: VpcId: !Ref TestVPC Metadata: 'AWS::CloudFormation::Designer': id: f8a81dbb-3f58-4a71-b273-b7e1e1a9022e TestRoute: Type: 'AWS::EC2::Route' Properties: DestinationCidrBlock: 0.0.0.0/0 RouteTableId: !Ref TestRouteTable GatewayId: !Ref TestInternetGateway Metadata: 'AWS::CloudFormation::Designer': id: 62f2589c-4cb2-445b-95ac-0c27f17cb3d4 TestSubnetRouteTableAssociation: Type: 'AWS::EC2::SubnetRouteTableAssociation' Properties: RouteTableId: !Ref TestRouteTable SubnetId: !Ref TestSubnet1 Metadata: 'AWS::CloudFormation::Designer': id: fdc98222-edff-4d8d-b5c5-1fe6198ef2f2 # WEBサーバー設定 TestSecurityGroup: Type: 'AWS::EC2::SecurityGroup' Properties: VpcId: !Ref TestVPC GroupDescription: ownIpAddressGroup SecurityGroupIngress: - IpProtocol: tcp FromPort: '22' ToPort: '22' CidrIp: 192.168.0.1/32 - IpProtocol: tcp FromPort: '80' ToPort: '80' CidrIp: 192.168.0.1/32 Metadata: 'AWS::CloudFormation::Designer': id: ea94d936-b782-4f54-b96d-4a02920e4fa6 TestWebServer1: Type: 'AWS::EC2::Instance' Properties: InstanceType: t2.micro AvailabilityZone: ap-northeast-1a ImageId: ami-eb50cd8d KeyName: testSampleKey BlockDeviceMappings: - DeviceName: /dev/sda1 Ebs: VolumeSize: 15 NetworkInterfaces: - AssociatePublicIpAddress: true SubnetId: !Ref TestSubnet1 DeleteOnTermination: true PrivateIpAddress: 192.168.10.10 DeviceIndex: '0' GroupSet: - !Ref TestSecurityGroup UserData: !Base64 'Fn::Join': - '' - - | #!/bin/bash - | yum -y remove mariadb-libs - | yum -y update - > rpm -ivh http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm - | yum -y install mysql httpd - > yum -y install http://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/e/epel-release-7-11.noarch.rpm - > yum -y install http://rpms.famillecollet.com/enterprise/remi-release-7.rpm - | yum -y install --enablerepo=remi-php72 php php-mysql - | systemctl enable httpd.service - | systemctl start httpd.service - | echo ' /var/www/html/info.php - | echo 'phpinfo();' >> /var/www/html/info.php - | setsebool -P httpd_can_network_connect_db on Metadata: 'AWS::CloudFormation::Designer': id: ce6bd251-1ba4-4006-8870-7dd334714700 # DBサーバー設定 TestDBParameterGroup: Type: 'AWS::RDS::DBParameterGroup' Properties: Description: mysql57CustomParameter Family: mysql5.7 Metadata: 'AWS::CloudFormation::Designer': id: 20ca1d51-5cd4-43c0-a8ed-2ea39b92ce06 TestRdsSecurityGroups: Type: 'AWS::EC2::SecurityGroup' Properties: GroupDescription: RdsSecurityGroup SecurityGroupIngress: - IpProtocol: tcp CidrIp: 192.168.10.10/32 FromPort: '3306' ToPort: '3306' VpcId: !Ref TestVPC Metadata: 'AWS::CloudFormation::Designer': id: 59d56056-f29e-4617-a591-9691292da3a1 TestDbServer1: Type: 'AWS::RDS::DBInstance' Properties: DBParameterGroupName: !Ref TestDBParameterGroup MultiAZ: false DBInstanceClass: db.t2.micro AllocatedStorage: 20 StorageType: gp2 DBInstanceIdentifier: test-hogehoge MasterUsername: master_hogehoge MasterUserPassword: hogehogepw DBName: hogehoge_db Engine: mysql EngineVersion: 5.7.19 Port: 3306 AvailabilityZone: ap-northeast-1a VPCSecurityGroups: - !Ref TestRdsSecurityGroups DBSubnetGroupName: !Ref TestDBSubnetGroup Metadata: 'AWS::CloudFormation::Designer': id: d98bc273-4230-486a-b03c-5f6121adc324