-
-
Notifications
You must be signed in to change notification settings - Fork 248
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added optional regional s3 endpoint. Added Example (#17)
* Added the ability to specify a regional endpoint. Updated README. Created working example. * Added output in example that provided instructions for beginners * Added origin_force_destroy to all s3 buckets so that the module can be destroyed if required. * Fixed another destruction issue. * Updated for consistency * Changed the 'static' bucket * added variable for static_s3_bucket
- Loading branch information
1 parent
1537e47
commit 3e299e3
Showing
9 changed files
with
135 additions
and
23 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,8 @@ | ||
# Compiled files | ||
*.tfstate | ||
*.tfstate.backup | ||
*.terraform.tfstate* | ||
**/*.tfstate | ||
**/*.tfstate.backup | ||
**/*.terraform.tfstate* | ||
# Module directory | ||
.terraform/ | ||
|
||
.idea | ||
*.iml | ||
|
||
**/.terraform |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>Your CDN is working</title> | ||
</head> | ||
<body> | ||
<H1>Your CDN is working!</H1> | ||
</body> | ||
</html> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
resource "aws_route53_zone" "primary" { | ||
name = "cloudposse.com" | ||
force_destroy = "true" | ||
} | ||
|
||
module "cdn" { | ||
source = "../" | ||
namespace = "cp" | ||
stage = "dev" | ||
name = "app-cdn" | ||
aliases = ["assets.cloudposse.com"] | ||
parent_zone_id = "${aws_route53_zone.primary.zone_id}" | ||
use_regional_s3_endpoint = "true" | ||
origin_force_destroy = "true" | ||
} | ||
|
||
resource "aws_s3_bucket_object" "index" { | ||
bucket = "${module.cdn.s3_bucket}" | ||
key = "index.html" | ||
source = "${path.module}/index.html" | ||
content_type = "text/html" | ||
etag = "${md5(file("${path.module}/index.html"))}" | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
output "cf_id" { | ||
value = "${module.cdn.cf_id}" | ||
} | ||
|
||
output "cf_arn" { | ||
value = "${module.cdn.cf_arn}" | ||
} | ||
|
||
output "cf_status" { | ||
value = "${module.cdn.cf_status}" | ||
} | ||
|
||
output "cf_domain_name" { | ||
value = "${module.cdn.cf_domain_name}" | ||
} | ||
|
||
output "cf_etag" { | ||
value = "${module.cdn.cf_etag}" | ||
} | ||
|
||
output "cf_hosted_zone_id" { | ||
value = "${module.cdn.cf_hosted_zone_id}" | ||
} | ||
|
||
output "s3_bucket" { | ||
value = "${module.cdn.s3_bucket}" | ||
} | ||
|
||
output "s3_bucket_domain_name" { | ||
value = "${module.cdn.s3_bucket_domain_name}" | ||
} | ||
|
||
output "details" { | ||
value = <<DOC | ||
When the `cf_status` changes to `Deployed` from `InProgress` | ||
(You can check it by doing an extra `terraform apply` every few minutes.) | ||
The site can be viewed at https://${module.cdn.cf_domain_name} | ||
DOC | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
provider "aws" { | ||
region = "eu-west-2" | ||
|
||
# Make it faster by skipping something | ||
skip_get_ec2_platforms = true | ||
skip_metadata_api_check = true | ||
skip_region_validation = true | ||
skip_credentials_validation = true | ||
skip_requesting_account_id = true | ||
} |
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
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
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