Created
April 13, 2016 15:24
-
-
Save jhwhite/a0abb6e00f6c7ca1c974bef84cb2b8f3 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
{ | |
"Parameters": { | |
"KeyPair":{ | |
"Description": "Key pair for instance", | |
"Type": "AWS::EC2::KeyPair::KeyName" | |
} | |
}, | |
"Resources": { | |
"S3Bucket": { | |
"Type" : "AWS::S3::Bucket", | |
"Properties" : { | |
"BucketName" : "cvilleclinicaltrials.com", | |
"WebsiteConfiguration" : { | |
"IndexDocument" : "index.html" | |
} | |
} | |
}, | |
"cvilleclinicaltrialsBucketPolicy" : { | |
"Type": "AWS::S3::BucketPolicy", | |
"Properties": { | |
"Bucket": "cvilleclinicaltrials.com", | |
"PolicyDocument": { | |
"Version":"2012-10-17", | |
"Statement":[{ | |
"Sid":"PublicReadGetObject", | |
"Effect":"Allow", | |
"Principal": "*", | |
"Action":["s3:GetObject"], | |
"Resource":["arn:aws:s3:::cvilleclinicaltrials.com/*" | |
] | |
} | |
] | |
} | |
} | |
}, | |
"Ec2Instance": { | |
"Type": "AWS::EC2::Instance", | |
"Metadata": { | |
"AWS::Cloudformation::Init": { | |
"config": { | |
"packages": { | |
"apt": { | |
"openjdk-7-jre": [], | |
"nginx": [], | |
"git":[] | |
} | |
} | |
} | |
} | |
}, | |
"Properties": { | |
"ImageId": "ami-fce3c696", | |
"InstanceType": "t2.micro", | |
"KeyName": {"Ref": "KeyPair"}, | |
"SecurityGroups": [{"Ref": "InstanceSecurityGroup"}], | |
"Tags": [{ | |
"Key": "Name", | |
"Value": "ec2-clin-trials" | |
}], | |
"UserData": { | |
"Fn::Base64": { | |
"Fn::Join": [ | |
"", | |
[ | |
"#!/bin/bash\n", | |
"wget https://download.elasticsearch.org/elasticsearch/release/org/elasticsearch/distribution/deb/elasticsearch/2.2.1/elasticsearch-2.2.1.deb \n", | |
"sudo apt-get -y update\n", | |
"sudo dpkg -i elasticsearch-1.7.2.deb\n", | |
"sudo update-rc.d elasticsearch defaults\n", | |
"/usr/local/bin/cfn-init --region ", | |
{ | |
"Ref": "AWS::Region" | |
}, | |
" -s ", | |
{ | |
"Ref": "AWS::StackName" | |
}, | |
" -r Ec2Instance\n" | |
]] | |
} | |
} | |
} | |
}, | |
"InstanceSecurityGroup": { | |
"Type": "AWS::EC2::SecurityGroup", | |
"Properties": { | |
"GroupDescription": "Enable SSH access via port 22", | |
"SecurityGroupIngress": [ | |
{ "IpProtocol": "tcp", "FromPort": "22", "ToPort": "22", "CidrIp": "71.206.186.223/32" }, | |
{ "IpProtocol": "tcp", "FromPort": "80", "ToPort": "80", "CidrIp": "0.0.0.0/0" } | |
] | |
} | |
} | |
}, | |
"Outputs" : { | |
"WebsiteDNSName" : { | |
"Description" : "Public DNS for SSH", | |
"Value" : { "Fn::GetAtt" : [ "Ec2Instance", "PublicDnsName" ] } | |
}, | |
"WebSiteIPAddress": { | |
"Description": "Public IP for SSH", | |
"Value": {"Fn::GetAtt": [ "Ec2Instance", "PublicIp"]} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment