-
-
Save Itch3f/e2a6a6ae4e1a4faf301ead7a3e855fc1 to your computer and use it in GitHub Desktop.
Revisions
-
smagch revised this gist
Nov 7, 2014 . 8 changed files with 158 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1 @@ .git 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1 @@ param.json 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,9 @@ FROM golang:1.3.3 RUN mkdir -p /go/src/app WORKDIR /go/src/app COPY . /go/src/app EXPOSE 8080 RUN ["go", "install", "."] CMD ["app"] 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,3 @@ { "AWSEBDockerrunVersion": "1" } 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,29 @@ #!/bin/bash set -e # ensure param.json exists if [ ! -f param.json ]; then cat <<EOUSAGE param.json file should exist. You can copy param.example.json EOUSAGE exit 1 fi find_param() { local keyName="$1" cat param.json | jq -r --arg keyName $keyName \ '.[] | select(.ParameterKey == $keyName) | .ParameterValue' } BUCKET_NAME=$(find_param S3Bucket) KEY_NAME=$(find_param S3Key) # upload git archive to S3 git archive --format zip HEAD | aws s3 cp - s3://${BUCKET_NAME}/${KEY_NAME} aws cloudformation create-stack \ --stack-name my-stack \ --template-body file://eb.json \ --region ap-northeast-1 \ --parameters file://param.json 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,79 @@ { "AWSTemplateFormatVersion" : "2010-09-09", "Description" : "AWS CloudFormation Docker Test", "Parameters" : { "Subnets": { "Type": "CommaDelimitedList", "Description": "Subnets" }, "VpcId": { "Type": "String", "Description": "VPC Id" }, "S3Bucket": { "Type": "String", "Description": "S3 Bucket name" }, "S3Key": { "Type": "String", "Description": "S3 Key name" } }, "Resources" : { "SampleApplication" : { "Type" : "AWS::ElasticBeanstalk::Application", "Properties" : { "Description" : "AWS Elastic Beanstalk Docker Sample Application", "ApplicationVersions" : [{ "VersionLabel" : "Initial Version", "Description" : "Version 1.0", "SourceBundle" : { "S3Bucket" : {"Ref": "S3Bucket"}, "S3Key": {"Ref": "S3Key"} } }] } }, "SampleEnvironment" : { "Type" : "AWS::ElasticBeanstalk::Environment", "Properties" : { "ApplicationName" : { "Ref" : "SampleApplication" }, "Description" : "AWS Elastic Beanstalk Environment running Docker Sample Application", "SolutionStackName" : "64bit Amazon Linux 2014.09 v1.0.9 running Docker 1.2.0", "VersionLabel" : "Initial Version", "OptionSettings": [ { "Namespace": "aws:autoscaling:launchconfiguration", "OptionName": "InstanceType", "Value": "t2.micro" }, { "Namespace": "aws:ec2:vpc", "OptionName": "VPCId", "Value": { "Ref" : "VpcId" } }, { "Namespace": "aws:ec2:vpc", "OptionName": "Subnets", "Value" : { "Fn::Join": [",", { "Ref" : "Subnets" }] } }, { "Namespace": "aws:ec2:vpc", "OptionName": "ELBSubnets", "Value" : { "Fn::Select": ["0", {"Ref" : "Subnets" }] } } ] } } }, "Outputs" : { "URL" : { "Description" : "The URL of the Elastic Beanstalk environment", "Value" : { "Fn::Join" : [ "", [ "http://", { "Fn::GetAtt" : ["SampleEnvironment", "EndpointURL"] }]]} } } } 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,18 @@ package main import ( "fmt" "html" "log" "net/http" ) func handler(w http.ResponseWriter, r *http.Request) { fmt.Fprintf(w, "Hello, %q", html.EscapeString(r.URL.Path)) } func main() { http.HandleFunc("/", handler) log.Println("start server") log.Fatal(http.ListenAndServe(":8080", nil)) } 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,18 @@ [ { "ParameterKey": "VpcId", "ParameterValue": "default-vpc-id" }, { "ParameterKey": "Subnets", "ParameterValue": "subnets-1, subnet-2" }, { "ParameterKey": "S3Key", "ParameterValue": "docker-sample.zip" }, { "ParameterKey": "S3Bucket", "ParameterValue": "smagch-docker" } ] -
smagch created this gist
Nov 7, 2014 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1 @@ # AWS: CloudFormation with Elastic Beanstalk, Docker Go web app