├── .gitignore ├── README.md └── templates ├── aws-cf-ec2-s3-architecture.png ├── aws-cf-ec2-s3.json └── aws-cf-ec2-s3.png /.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | *.iml 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # AWS Cloud Formation Templates 2 | 3 | ## Templates 4 | - [EC2 SecurityGroup and S3](#ec2-securitygroup-and-s3) 5 | 6 | # EC2 SecurityGroup and S3 7 | - [CloudFormation JSON Template](/templates/aws-cf-ec2-s3.json) 8 | - Design 9 | 10 | - Architecture 11 | 12 | 13 | -------------------------------------------------------------------------------- /templates/aws-cf-ec2-s3-architecture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TechPrimers/aws-cloud-formation-templates/abb582477545e05c0ac8bd517c6c5ed2e29ed567/templates/aws-cf-ec2-s3-architecture.png -------------------------------------------------------------------------------- /templates/aws-cf-ec2-s3.json: -------------------------------------------------------------------------------- 1 | { 2 | "AWSTemplateFormatVersion": "2010-09-09", 3 | "Parameters": { 4 | "KeyName": { 5 | "Description": "Name of an existing EC2 KeyPair to enable SSH access to the instance", 6 | "Type": "AWS::EC2::KeyPair::KeyName", 7 | "ConstraintDescription": "must be the name of an existing EC2 KeyPair." 8 | }, 9 | "InstanceType": { 10 | "Description": "WebServer EC2 instance type", 11 | "Type": "String", 12 | "Default": "t2.nano", 13 | "AllowedValues": [ 14 | "t1.micro", 15 | "t2.nano" 16 | ], 17 | "ConstraintDescription": "must be a valid EC2 instance type." 18 | }, 19 | "SSHLocation": { 20 | "Description": "The IP address range that can be used to SSH to the EC2 instances", 21 | "Type": "String", 22 | "MinLength": "9", 23 | "MaxLength": "18", 24 | "Default": "0.0.0.0/0", 25 | "AllowedPattern": "(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})/(\\d{1,2})", 26 | "ConstraintDescription": "must be a valid IP CIDR range of the form x.x.x.x/x." 27 | } 28 | }, 29 | "Mappings": { 30 | "AWSInstanceType2Arch": { 31 | "t1.micro": { 32 | "Arch": "HVM64" 33 | }, 34 | "t2.nano": { 35 | "Arch": "HVM64" 36 | } 37 | }, 38 | "AWSRegionArch2AMI": { 39 | "us-east-1": { 40 | "HVM64": "ami-0080e4c5bc078760e", 41 | "HVMG2": "ami-0aeb704d503081ea6" 42 | }, 43 | "us-west-2": { 44 | "HVM64": "ami-01e24be29428c15b2", 45 | "HVMG2": "ami-0fe84a5b4563d8f27" 46 | }, 47 | "us-west-1": { 48 | "HVM64": "ami-0ec6517f6edbf8044", 49 | "HVMG2": "ami-0a7fc72dc0e51aa77" 50 | }, 51 | "eu-west-1": { 52 | "HVM64": "ami-08935252a36e25f85", 53 | "HVMG2": "ami-0d5299b1c6112c3c7" 54 | }, 55 | "eu-west-2": { 56 | "HVM64": "ami-01419b804382064e4", 57 | "HVMG2": "NOT_SUPPORTED" 58 | }, 59 | "eu-west-3": { 60 | "HVM64": "ami-0dd7e7ed60da8fb83", 61 | "HVMG2": "NOT_SUPPORTED" 62 | }, 63 | "eu-central-1": { 64 | "HVM64": "ami-0cfbf4f6db41068ac", 65 | "HVMG2": "ami-0aa1822e3eb913a11" 66 | }, 67 | "eu-north-1": { 68 | "HVM64": "ami-86fe70f8", 69 | "HVMG2": "ami-32d55b4c" 70 | }, 71 | "ap-northeast-1": { 72 | "HVM64": "ami-00a5245b4816c38e6", 73 | "HVMG2": "ami-09d0e0e099ecabba2" 74 | }, 75 | "ap-northeast-2": { 76 | "HVM64": "ami-00dc207f8ba6dc919", 77 | "HVMG2": "NOT_SUPPORTED" 78 | }, 79 | "ap-northeast-3": { 80 | "HVM64": "ami-0b65f69a5c11f3522", 81 | "HVMG2": "NOT_SUPPORTED" 82 | }, 83 | "ap-southeast-1": { 84 | "HVM64": "ami-05b3bcf7f311194b3", 85 | "HVMG2": "ami-0e46ce0d6a87dc979" 86 | }, 87 | "ap-southeast-2": { 88 | "HVM64": "ami-02fd0b06f06d93dfc", 89 | "HVMG2": "ami-0c0ab057a101d8ff2" 90 | }, 91 | "ap-south-1": { 92 | "HVM64": "ami-0ad42f4f66f6c1cc9", 93 | "HVMG2": "ami-0244c1d42815af84a" 94 | }, 95 | "us-east-2": { 96 | "HVM64": "ami-0cd3dfa4e37921605", 97 | "HVMG2": "NOT_SUPPORTED" 98 | }, 99 | "ca-central-1": { 100 | "HVM64": "ami-07423fb63ea0a0930", 101 | "HVMG2": "NOT_SUPPORTED" 102 | }, 103 | "sa-east-1": { 104 | "HVM64": "ami-05145e0b28ad8e0b2", 105 | "HVMG2": "NOT_SUPPORTED" 106 | }, 107 | "cn-north-1": { 108 | "HVM64": "ami-053617c9d818c1189", 109 | "HVMG2": "NOT_SUPPORTED" 110 | }, 111 | "cn-northwest-1": { 112 | "HVM64": "ami-0f7937761741dc640", 113 | "HVMG2": "NOT_SUPPORTED" 114 | } 115 | } 116 | }, 117 | "Resources": { 118 | "EC2Instance": { 119 | "Type": "AWS::EC2::Instance", 120 | "Properties": { 121 | "InstanceType": { 122 | "Ref": "InstanceType" 123 | }, 124 | "SecurityGroups": [ 125 | { 126 | "Ref": "InstanceSecurityGroup" 127 | } 128 | ], 129 | "KeyName": { 130 | "Ref": "KeyName" 131 | }, 132 | "ImageId": { 133 | "Fn::FindInMap": [ 134 | "AWSRegionArch2AMI", 135 | { 136 | "Ref": "AWS::Region" 137 | }, 138 | { 139 | "Fn::FindInMap": [ 140 | "AWSInstanceType2Arch", 141 | { 142 | "Ref": "InstanceType" 143 | }, 144 | "Arch" 145 | ] 146 | } 147 | ] 148 | } 149 | } 150 | }, 151 | "InstanceSecurityGroup": { 152 | "Type": "AWS::EC2::SecurityGroup", 153 | "Properties": { 154 | "GroupDescription": "Enable SSH access via port 22", 155 | "SecurityGroupIngress": [ 156 | { 157 | "IpProtocol": "tcp", 158 | "FromPort": "22", 159 | "ToPort": "22", 160 | "CidrIp": { 161 | "Ref": "SSHLocation" 162 | } 163 | } 164 | ] 165 | } 166 | }, 167 | "S3Bucket": { 168 | "Type": "AWS::S3::Bucket", 169 | "Properties": {}, 170 | "Metadata": { 171 | "AWS::CloudFormation::Designer": { 172 | "id": "578de650-9ae7-4a2d-8caa-6ebc5990a94b" 173 | } 174 | }, 175 | "DependsOn": [ 176 | "EC2Instance" 177 | ] 178 | } 179 | }, 180 | "Outputs": { 181 | "InstanceId": { 182 | "Description": "InstanceId of the newly created EC2 instance", 183 | "Value": { 184 | "Ref": "EC2Instance" 185 | } 186 | }, 187 | "AZ": { 188 | "Description": "Availability Zone of the newly created EC2 instance", 189 | "Value": { 190 | "Fn::GetAtt": [ 191 | "EC2Instance", 192 | "AvailabilityZone" 193 | ] 194 | } 195 | }, 196 | "PublicDNS": { 197 | "Description": "Public DNSName of the newly created EC2 instance", 198 | "Value": { 199 | "Fn::GetAtt": [ 200 | "EC2Instance", 201 | "PublicDnsName" 202 | ] 203 | } 204 | }, 205 | "PublicIP": { 206 | "Description": "Public IP address of the newly created EC2 instance", 207 | "Value": { 208 | "Fn::GetAtt": [ 209 | "EC2Instance", 210 | "PublicIp" 211 | ] 212 | } 213 | } 214 | } 215 | } -------------------------------------------------------------------------------- /templates/aws-cf-ec2-s3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TechPrimers/aws-cloud-formation-templates/abb582477545e05c0ac8bd517c6c5ed2e29ed567/templates/aws-cf-ec2-s3.png --------------------------------------------------------------------------------