Created
October 4, 2020 16:35
-
-
Save MR-DS-20/0467ee1d66d34191b58a61e6447efa34 to your computer and use it in GitHub Desktop.
CloudFormation template to be used as an example of how to implement some common resources
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
Metadata: | |
'AWS::CloudFormation::Designer': | |
5600da21-5209-4f61-a2e3-5c063bc28ab3: | |
size: | |
width: 330 | |
height: 180 | |
position: | |
x: 250 | |
'y': 10 | |
z: 0 | |
embeds: | |
- 484ae63a-392e-4d0b-a5ba-06a36f8b2ea2 | |
- 9ae5b196-da6c-44c4-b3c7-6c5b4a247dd2 | |
- f1bd8aaa-8753-4d4d-ae6f-db653ff35142 | |
9ae5b196-da6c-44c4-b3c7-6c5b4a247dd2: | |
size: | |
width: 120 | |
height: 110 | |
position: | |
x: 260 | |
'y': 60 | |
z: 1 | |
parent: 5600da21-5209-4f61-a2e3-5c063bc28ab3 | |
embeds: | |
- d4b0d252-7abd-4d34-a12c-e90e078bffc0 | |
iscontainedinside: | |
- 5600da21-5209-4f61-a2e3-5c063bc28ab3 | |
- 5600da21-5209-4f61-a2e3-5c063bc28ab3 | |
- 5600da21-5209-4f61-a2e3-5c063bc28ab3 | |
- 5600da21-5209-4f61-a2e3-5c063bc28ab3 | |
- 5600da21-5209-4f61-a2e3-5c063bc28ab3 | |
- 5600da21-5209-4f61-a2e3-5c063bc28ab3 | |
- 5600da21-5209-4f61-a2e3-5c063bc28ab3 | |
- 5600da21-5209-4f61-a2e3-5c063bc28ab3 | |
- 5600da21-5209-4f61-a2e3-5c063bc28ab3 | |
- 5600da21-5209-4f61-a2e3-5c063bc28ab3 | |
- 5600da21-5209-4f61-a2e3-5c063bc28ab3 | |
- 5600da21-5209-4f61-a2e3-5c063bc28ab3 | |
- 5600da21-5209-4f61-a2e3-5c063bc28ab3 | |
- 5600da21-5209-4f61-a2e3-5c063bc28ab3 | |
- 5600da21-5209-4f61-a2e3-5c063bc28ab3 | |
- 5600da21-5209-4f61-a2e3-5c063bc28ab3 | |
- 5600da21-5209-4f61-a2e3-5c063bc28ab3 | |
- 5600da21-5209-4f61-a2e3-5c063bc28ab3 | |
- 5600da21-5209-4f61-a2e3-5c063bc28ab3 | |
- 5600da21-5209-4f61-a2e3-5c063bc28ab3 | |
- 5600da21-5209-4f61-a2e3-5c063bc28ab3 | |
- 5600da21-5209-4f61-a2e3-5c063bc28ab3 | |
- 5600da21-5209-4f61-a2e3-5c063bc28ab3 | |
- 5600da21-5209-4f61-a2e3-5c063bc28ab3 | |
d4b0d252-7abd-4d34-a12c-e90e078bffc0: | |
size: | |
width: 60 | |
height: 60 | |
position: | |
x: 280 | |
'y': 90 | |
z: 2 | |
parent: 9ae5b196-da6c-44c4-b3c7-6c5b4a247dd2 | |
embeds: [] | |
isassociatedwith: | |
- cfd4c217-34e2-4480-be0a-aaf375b77989 | |
iscontainedinside: | |
- 9ae5b196-da6c-44c4-b3c7-6c5b4a247dd2 | |
- 9ae5b196-da6c-44c4-b3c7-6c5b4a247dd2 | |
- 9ae5b196-da6c-44c4-b3c7-6c5b4a247dd2 | |
- 9ae5b196-da6c-44c4-b3c7-6c5b4a247dd2 | |
- 9ae5b196-da6c-44c4-b3c7-6c5b4a247dd2 | |
- 9ae5b196-da6c-44c4-b3c7-6c5b4a247dd2 | |
- 9ae5b196-da6c-44c4-b3c7-6c5b4a247dd2 | |
- 9ae5b196-da6c-44c4-b3c7-6c5b4a247dd2 | |
- 9ae5b196-da6c-44c4-b3c7-6c5b4a247dd2 | |
- 9ae5b196-da6c-44c4-b3c7-6c5b4a247dd2 | |
- 9ae5b196-da6c-44c4-b3c7-6c5b4a247dd2 | |
- 9ae5b196-da6c-44c4-b3c7-6c5b4a247dd2 | |
- 9ae5b196-da6c-44c4-b3c7-6c5b4a247dd2 | |
- 9ae5b196-da6c-44c4-b3c7-6c5b4a247dd2 | |
- 9ae5b196-da6c-44c4-b3c7-6c5b4a247dd2 | |
- 9ae5b196-da6c-44c4-b3c7-6c5b4a247dd2 | |
- 9ae5b196-da6c-44c4-b3c7-6c5b4a247dd2 | |
- 9ae5b196-da6c-44c4-b3c7-6c5b4a247dd2 | |
- 9ae5b196-da6c-44c4-b3c7-6c5b4a247dd2 | |
- 9ae5b196-da6c-44c4-b3c7-6c5b4a247dd2 | |
- 9ae5b196-da6c-44c4-b3c7-6c5b4a247dd2 | |
- 9ae5b196-da6c-44c4-b3c7-6c5b4a247dd2 | |
- 9ae5b196-da6c-44c4-b3c7-6c5b4a247dd2 | |
cfd4c217-34e2-4480-be0a-aaf375b77989: | |
size: | |
width: 60 | |
height: 60 | |
position: | |
x: 160 | |
'y': 110 | |
z: 0 | |
embeds: [] | |
iscontainedinside: | |
- 5600da21-5209-4f61-a2e3-5c063bc28ab3 | |
5ae7fce5-ccaa-427e-abc2-524938fc5797: | |
size: | |
width: 60 | |
height: 60 | |
position: | |
x: 160 | |
'y': 30 | |
z: 0 | |
embeds: [] | |
isassociatedwith: | |
- 602a3b14-8b4b-4a15-8e17-9aed4fa393e6 | |
602a3b14-8b4b-4a15-8e17-9aed4fa393e6: | |
size: | |
width: 60 | |
height: 60 | |
position: | |
x: 80 | |
'y': 110 | |
z: 0 | |
embeds: [] | |
f1bd8aaa-8753-4d4d-ae6f-db653ff35142: | |
size: | |
width: 60 | |
height: 60 | |
position: | |
x: 390 | |
'y': 110 | |
z: 1 | |
parent: 5600da21-5209-4f61-a2e3-5c063bc28ab3 | |
embeds: [] | |
isassociatedwith: | |
- d4b0d252-7abd-4d34-a12c-e90e078bffc0 | |
484ae63a-392e-4d0b-a5ba-06a36f8b2ea2: | |
size: | |
width: 98.02184228950756 | |
height: 140 | |
position: | |
x: 460 | |
'y': 30 | |
z: 1 | |
parent: 5600da21-5209-4f61-a2e3-5c063bc28ab3 | |
embeds: | |
- a130f230-8721-44f9-9b14-a0e2a28078b8 | |
iscontainedinside: | |
- 5600da21-5209-4f61-a2e3-5c063bc28ab3 | |
- 5600da21-5209-4f61-a2e3-5c063bc28ab3 | |
- 5600da21-5209-4f61-a2e3-5c063bc28ab3 | |
- 5600da21-5209-4f61-a2e3-5c063bc28ab3 | |
- 5600da21-5209-4f61-a2e3-5c063bc28ab3 | |
- 5600da21-5209-4f61-a2e3-5c063bc28ab3 | |
- 5600da21-5209-4f61-a2e3-5c063bc28ab3 | |
- 5600da21-5209-4f61-a2e3-5c063bc28ab3 | |
- 5600da21-5209-4f61-a2e3-5c063bc28ab3 | |
- 5600da21-5209-4f61-a2e3-5c063bc28ab3 | |
- 5600da21-5209-4f61-a2e3-5c063bc28ab3 | |
- 5600da21-5209-4f61-a2e3-5c063bc28ab3 | |
a130f230-8721-44f9-9b14-a0e2a28078b8: | |
size: | |
width: 60 | |
height: 60 | |
position: | |
x: 480 | |
'y': 70 | |
z: 2 | |
parent: 484ae63a-392e-4d0b-a5ba-06a36f8b2ea2 | |
embeds: [] | |
isassociatedwith: | |
- f10549b9-19bb-4b09-b30b-a9fe863a481f | |
- 56c07d4c-9bff-43a8-be29-1bb18a50f65b | |
iscontainedinside: | |
- 484ae63a-392e-4d0b-a5ba-06a36f8b2ea2 | |
- 484ae63a-392e-4d0b-a5ba-06a36f8b2ea2 | |
- 484ae63a-392e-4d0b-a5ba-06a36f8b2ea2 | |
- 484ae63a-392e-4d0b-a5ba-06a36f8b2ea2 | |
- 484ae63a-392e-4d0b-a5ba-06a36f8b2ea2 | |
- 484ae63a-392e-4d0b-a5ba-06a36f8b2ea2 | |
- 484ae63a-392e-4d0b-a5ba-06a36f8b2ea2 | |
- 484ae63a-392e-4d0b-a5ba-06a36f8b2ea2 | |
- 484ae63a-392e-4d0b-a5ba-06a36f8b2ea2 | |
- 484ae63a-392e-4d0b-a5ba-06a36f8b2ea2 | |
- 484ae63a-392e-4d0b-a5ba-06a36f8b2ea2 | |
5f5f8959-ab6d-4624-819d-04d678254600: | |
source: | |
id: 5600da21-5209-4f61-a2e3-5c063bc28ab3 | |
target: | |
id: 56c07d4c-9bff-43a8-be29-1bb18a50f65b | |
z: 0 | |
56c07d4c-9bff-43a8-be29-1bb18a50f65b: | |
size: | |
width: 60 | |
height: 60 | |
position: | |
x: 600 | |
'y': 140 | |
z: 0 | |
embeds: [] | |
086449a9-758e-4878-94e7-1a81c671cc6c: | |
source: | |
id: 484ae63a-392e-4d0b-a5ba-06a36f8b2ea2 | |
target: | |
id: 9ae5b196-da6c-44c4-b3c7-6c5b4a247dd2 | |
z: 1 | |
Resources: | |
MYVPCNAME: | |
Type: 'AWS::EC2::VPC' | |
Properties: | |
CidrBlock: 10.0.0.0/16 | |
Metadata: | |
'AWS::CloudFormation::Designer': | |
id: 5600da21-5209-4f61-a2e3-5c063bc28ab3 | |
PublicSubnet: | |
Type: 'AWS::EC2::Subnet' | |
Properties: | |
VpcId: !Ref MYVPCNAME | |
CidrBlock: 10.0.1.0/24 | |
Metadata: | |
'AWS::CloudFormation::Designer': | |
id: 9ae5b196-da6c-44c4-b3c7-6c5b4a247dd2 | |
MainServer: | |
Type: 'AWS::EC2::Instance' | |
Properties: | |
SubnetId: !Ref PublicSubnet | |
SecurityGroupIds: | |
- !Ref ServerSecurityGroup | |
IamInstanceProfile: !Ref ServerProfile | |
KeyName: !Ref SSHKEY | |
ImageId: ami-05c424d59413a2876 | |
InstanceType: t2.micro | |
UserData: !Base64 | |
'Fn::Join': | |
- '' | |
- - | | |
#! /bin/bash | |
- | | |
sudo apt-get update | |
- | | |
sudo apt-get install ruby -y | |
- | | |
sudo apt-get install wget -y | |
- | | |
cd /home/ubuntu | |
- > | |
wget | |
https://aws-codedeploy-eu-west-2.s3.eu-west-2.amazonaws.com/latest/install | |
- | | |
chmod +x ./install | |
- | | |
sudo ./install auto > /tmp/logfile | |
- | | |
sudo apt install nodejs -y | |
- | | |
sudo apt install npm -y | |
- sudo service codedeploy-agent enable --now | |
Metadata: | |
'AWS::CloudFormation::Designer': | |
id: d4b0d252-7abd-4d34-a12c-e90e078bffc0 | |
ServerSecurityGroup: | |
Type: 'AWS::EC2::SecurityGroup' | |
Properties: | |
VpcId: !Ref MYVPCNAME | |
GroupDescription: Development server access over http/ssh | |
SecurityGroupIngress: | |
- IpProtocol: tcp | |
FromPort: 22 | |
ToPort: 22 | |
Description: SSH access | |
CidrIp: !Ref DEVELOPERIP | |
- IpProtocol: tcp | |
FromPort: 80 | |
ToPort: 80 | |
Description: HTTP access | |
CidrIp: 0.0.0.0/0 | |
- IpProtocol: tcp | |
FromPort: 443 | |
ToPort: 443 | |
Description: HTTPS access | |
CidrIp: 0.0.0.0/0 | |
Metadata: | |
'AWS::CloudFormation::Designer': | |
id: cfd4c217-34e2-4480-be0a-aaf375b77989 | |
ServerProfile: | |
Type: 'AWS::IAM::InstanceProfile' | |
Properties: | |
Roles: | |
- !Ref ServerRole | |
Metadata: | |
'AWS::CloudFormation::Designer': | |
id: 5ae7fce5-ccaa-427e-abc2-524938fc5797 | |
ServerRole: | |
Type: 'AWS::IAM::Role' | |
Metadata: | |
'AWS::CloudFormation::Designer': | |
id: 602a3b14-8b4b-4a15-8e17-9aed4fa393e6 | |
Properties: | |
AssumeRolePolicyDocument: | |
Version: 2012-10-17 | |
Statement: | |
- Effect: Allow | |
Principal: | |
Service: | |
- ec2.amazonaws.com | |
Action: | |
- 'sts:AssumeRole' | |
ManagedPolicyArns: | |
- 'arn:aws:iam::aws:policy/AmazonEC2FullAccess' | |
- 'arn:aws:iam::aws:policy/AmazonSESFullAccess' | |
- 'arn:aws:iam::aws:policy/AmazonS3FullAccess' | |
ServerEIP: | |
Type: 'AWS::EC2::EIP' | |
Properties: | |
InstanceId: !Ref MainServer | |
Metadata: | |
'AWS::CloudFormation::Designer': | |
id: f1bd8aaa-8753-4d4d-ae6f-db653ff35142 | |
RouteTable: | |
Type: 'AWS::EC2::RouteTable' | |
Properties: | |
VpcId: !Ref MYVPCNAME | |
Metadata: | |
'AWS::CloudFormation::Designer': | |
id: 484ae63a-392e-4d0b-a5ba-06a36f8b2ea2 | |
PermitAllToIGW: | |
Type: 'AWS::EC2::Route' | |
Properties: | |
RouteTableId: !Ref RouteTable | |
DestinationCidrBlock: 0.0.0.0/0 | |
GatewayId: !Ref IGW | |
Metadata: | |
'AWS::CloudFormation::Designer': | |
id: a130f230-8721-44f9-9b14-a0e2a28078b8 | |
IGWAttachement: | |
Type: 'AWS::EC2::VPCGatewayAttachment' | |
Properties: | |
InternetGatewayId: !Ref IGW | |
VpcId: !Ref MYVPCNAME | |
Metadata: | |
'AWS::CloudFormation::Designer': | |
id: 5f5f8959-ab6d-4624-819d-04d678254600 | |
IGW: | |
Type: 'AWS::EC2::InternetGateway' | |
Properties: {} | |
Metadata: | |
'AWS::CloudFormation::Designer': | |
id: 56c07d4c-9bff-43a8-be29-1bb18a50f65b | |
SubnetRouteTableAssociation: | |
Type: 'AWS::EC2::SubnetRouteTableAssociation' | |
Properties: | |
RouteTableId: !Ref RouteTable | |
SubnetId: !Ref PublicSubnet | |
Metadata: | |
'AWS::CloudFormation::Designer': | |
id: 086449a9-758e-4878-94e7-1a81c671cc6c | |
Parameters: | |
DEVELOPERIP: | |
Description: 'Ip address for development machine to allow ssh, in CIDR format' | |
Type: String | |
SSHKEY: | |
Description: Key pair for instance SSH access | |
Type: 'AWS::EC2::KeyPair::KeyName' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment