Skip to content

Commit

Permalink
Add deploy task
Browse files Browse the repository at this point in the history
  • Loading branch information
MattSurabian committed Oct 2, 2015
1 parent 7924494 commit 061b597
Show file tree
Hide file tree
Showing 5 changed files with 252 additions and 0 deletions.
9 changes: 9 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,5 +86,14 @@ gulp.task('images', function(){
.pipe(connect.reload());
});

gulp.task('deploy', function() {
return gulp.src('', {read:false})
.pipe(shell([
'terraform plan',
'terraform apply',
'aws s3 sync dist/ s3://duckhuntjs.com --include \'*\' --acl \'public-read\''
]));
});

gulp.task('default', ['images', 'audio', 'jshint', 'jscs', 'modules']);
gulp.task('dev', ['default', 'watch', 'serve']);
39 changes: 39 additions & 0 deletions infrastructure.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
provider "aws" {
region = "us-east-1"
}

resource "aws_s3_bucket" "www-duckhuntjs-com" {
bucket = "www.duckhuntjs.com"
acl = "public-read"

website {
redirect_all_requests_to = "duckhuntjs.com"
}
}

resource "aws_s3_bucket" "duckhuntjs-com" {
bucket = "duckhuntjs.com"
acl = "public-read"
policy = "${file("s3policy.json")}"

website {
index_document = "index.html"
error_document = "index.html"
}
}

resource "cloudflare_record" "www-duckhuntjs-com" {
domain = "duckhuntjs.com"
name = "www"
value = "${aws_s3_bucket.www-duckhuntjs-com.website_endpoint}"
type = "CNAME"
ttl = 3600
}

resource "cloudflare_record" "duckhuntjs-com" {
domain = "duckhuntjs.com"
name = "duckhuntjs.com"
value = "${aws_s3_bucket.duckhuntjs-com.website_endpoint}"
type = "CNAME"
ttl = 3600
}
12 changes: 12 additions & 0 deletions s3policy.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"Version":"2012-10-17",
"Statement":[
{
"Sid":"AddPerm",
"Effect":"Allow",
"Principal": "*",
"Action":["s3:GetObject"],
"Resource":["arn:aws:s3:::duckhuntjs.com/*"]
}
]
}
96 changes: 96 additions & 0 deletions terraform.tfstate
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
{
"version": 1,
"serial": 14,
"modules": [
{
"path": [
"root"
],
"outputs": {},
"resources": {
"aws_s3_bucket.duckhuntjs-com": {
"type": "aws_s3_bucket",
"primary": {
"id": "duckhuntjs.com",
"attributes": {
"acl": "public-read",
"bucket": "duckhuntjs.com",
"force_destroy": "false",
"hosted_zone_id": "Z3AQBSTGFYJSTF",
"id": "duckhuntjs.com",
"policy": "{\"Statement\":[{\"Action\":\"s3:GetObject\",\"Effect\":\"Allow\",\"Principal\":\"*\",\"Resource\":\"arn:aws:s3:::duckhuntjs.com/*\",\"Sid\":\"AddPerm\"}],\"Version\":\"2012-10-17\"}",
"region": "us-east-1",
"tags.#": "0",
"website.#": "1",
"website.0.error_document": "index.html",
"website.0.index_document": "index.html",
"website.0.redirect_all_requests_to": "",
"website_domain": "s3-website-us-east-1.amazonaws.com",
"website_endpoint": "duckhuntjs.com.s3-website-us-east-1.amazonaws.com"
}
}
},
"aws_s3_bucket.www-duckhuntjs-com": {
"type": "aws_s3_bucket",
"primary": {
"id": "www.duckhuntjs.com",
"attributes": {
"acl": "public-read",
"bucket": "www.duckhuntjs.com",
"force_destroy": "false",
"hosted_zone_id": "Z3AQBSTGFYJSTF",
"id": "www.duckhuntjs.com",
"policy": "",
"region": "us-east-1",
"tags.#": "0",
"website.#": "1",
"website.0.error_document": "",
"website.0.index_document": "",
"website.0.redirect_all_requests_to": "duckhuntjs.com",
"website_domain": "s3-website-us-east-1.amazonaws.com",
"website_endpoint": "www.duckhuntjs.com.s3-website-us-east-1.amazonaws.com"
}
}
},
"cloudflare_record.duckhuntjs-com": {
"type": "cloudflare_record",
"depends_on": [
"aws_s3_bucket.duckhuntjs-com"
],
"primary": {
"id": "379723978",
"attributes": {
"domain": "duckhuntjs.com",
"hostname": "duckhuntjs.com",
"id": "379723978",
"name": "duckhuntjs.com",
"priority": "",
"ttl": "3600",
"type": "CNAME",
"value": "duckhuntjs.com.s3-website-us-east-1.amazonaws.com"
}
}
},
"cloudflare_record.www-duckhuntjs-com": {
"type": "cloudflare_record",
"depends_on": [
"aws_s3_bucket.www-duckhuntjs-com"
],
"primary": {
"id": "379723981",
"attributes": {
"domain": "duckhuntjs.com",
"hostname": "www.duckhuntjs.com",
"id": "379723981",
"name": "www",
"priority": "",
"ttl": "3600",
"type": "CNAME",
"value": "www.duckhuntjs.com.s3-website-us-east-1.amazonaws.com"
}
}
}
}
}
]
}
96 changes: 96 additions & 0 deletions terraform.tfstate.backup
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
{
"version": 1,
"serial": 14,
"modules": [
{
"path": [
"root"
],
"outputs": {},
"resources": {
"aws_s3_bucket.duckhuntjs-com": {
"type": "aws_s3_bucket",
"primary": {
"id": "duckhuntjs.com",
"attributes": {
"acl": "public-read",
"bucket": "duckhuntjs.com",
"force_destroy": "false",
"hosted_zone_id": "Z3AQBSTGFYJSTF",
"id": "duckhuntjs.com",
"policy": "{\"Statement\":[{\"Action\":\"s3:GetObject\",\"Effect\":\"Allow\",\"Principal\":\"*\",\"Resource\":\"arn:aws:s3:::duckhuntjs.com/*\",\"Sid\":\"AddPerm\"}],\"Version\":\"2012-10-17\"}",
"region": "us-east-1",
"tags.#": "0",
"website.#": "1",
"website.0.error_document": "index.html",
"website.0.index_document": "index.html",
"website.0.redirect_all_requests_to": "",
"website_domain": "s3-website-us-east-1.amazonaws.com",
"website_endpoint": "duckhuntjs.com.s3-website-us-east-1.amazonaws.com"
}
}
},
"aws_s3_bucket.www-duckhuntjs-com": {
"type": "aws_s3_bucket",
"primary": {
"id": "www.duckhuntjs.com",
"attributes": {
"acl": "public-read",
"bucket": "www.duckhuntjs.com",
"force_destroy": "false",
"hosted_zone_id": "Z3AQBSTGFYJSTF",
"id": "www.duckhuntjs.com",
"policy": "",
"region": "us-east-1",
"tags.#": "0",
"website.#": "1",
"website.0.error_document": "",
"website.0.index_document": "",
"website.0.redirect_all_requests_to": "duckhuntjs.com",
"website_domain": "s3-website-us-east-1.amazonaws.com",
"website_endpoint": "www.duckhuntjs.com.s3-website-us-east-1.amazonaws.com"
}
}
},
"cloudflare_record.duckhuntjs-com": {
"type": "cloudflare_record",
"depends_on": [
"aws_s3_bucket.duckhuntjs-com"
],
"primary": {
"id": "379723978",
"attributes": {
"domain": "duckhuntjs.com",
"hostname": "duckhuntjs.com",
"id": "379723978",
"name": "duckhuntjs.com",
"priority": "",
"ttl": "3600",
"type": "CNAME",
"value": "duckhuntjs.com.s3-website-us-east-1.amazonaws.com"
}
}
},
"cloudflare_record.www-duckhuntjs-com": {
"type": "cloudflare_record",
"depends_on": [
"aws_s3_bucket.www-duckhuntjs-com"
],
"primary": {
"id": "379723981",
"attributes": {
"domain": "duckhuntjs.com",
"hostname": "www.duckhuntjs.com",
"id": "379723981",
"name": "www",
"priority": "",
"ttl": "3600",
"type": "CNAME",
"value": "www.duckhuntjs.com.s3-website-us-east-1.amazonaws.com"
}
}
}
}
}
]
}

0 comments on commit 061b597

Please sign in to comment.