Last active
September 20, 2018 14:32
-
-
Save RohitRox/1a5a3c771b32d5c6f22ad5f08b0504bd to your computer and use it in GitHub Desktop.
Hello World Cloudformation Template
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
AWSTemplateFormatVersion: 2010-09-09 | |
Description: Deploys a basic httpd hello world app in an EC2 instance, create and attach a security group for the instance | |
Mappings: | |
Infra: | |
Vpcs: | |
Main: vpc-xxxx | |
Subnets: | |
Public: | |
- subnet-xxxx | |
- subnet-xxxx | |
Resources: | |
# Security Group | |
AppSecurityGroup: | |
Type: AWS::EC2::SecurityGroup | |
Properties: | |
GroupName: webapp-hello-security-group | |
GroupDescription: Web App Security Group, HTTP traffic in, all traffic out, SSH enabled | |
VpcId: !FindInMap [Infra, Vpcs, Main] | |
SecurityGroupIngress: | |
- CidrIp: 0.0.0.0/0 | |
IpProtocol: tcp | |
ToPort: 80 | |
FromPort: 80 | |
- CidrIp: 0.0.0.0/0 | |
IpProtocol: tcp | |
ToPort: 22 | |
FromPort: 22 | |
# App Instance | |
App: | |
Type: AWS::EC2::Instance | |
Properties: | |
# Hello Aws Community AMI | |
ImageId: ami-8b5bb6e8 | |
InstanceType: t2.micro | |
KeyName: ec2-key-name | |
SubnetId: !Select [ 0, !FindInMap [Infra, Subnets, Public] ] | |
SecurityGroupIds: | |
- !Ref AppSecurityGroup | |
Tags: | |
- Key: Environment | |
Value: test | |
- Key: Role | |
Value: web | |
Outputs: | |
App: | |
Description: App Instance | |
Value: !Ref App | |
AppUrl: | |
Description: App Endpoint | |
Value: !GetAtt App.PublicDnsName |
Author
RohitRox
commented
Sep 20, 2018
•
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment