-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Upgrade to v12 - step1 * Upgrade to v12
- Loading branch information
1 parent
3ea3b02
commit 8de1566
Showing
12 changed files
with
123 additions
and
87 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,43 +1,43 @@ | ||
# ACM Certificate generation | ||
resource "aws_acm_certificate" "cert" { | ||
provider = "aws.cloudfront" | ||
domain_name = "${var.fqdn}" | ||
provider = aws.cloudfront | ||
domain_name = var.fqdn | ||
validation_method = "DNS" | ||
} | ||
|
||
resource "aws_route53_record" "cert_validation" { | ||
provider = "aws.cloudfront" | ||
name = "${aws_acm_certificate.cert.domain_validation_options.0.resource_record_name}" | ||
type = "${aws_acm_certificate.cert.domain_validation_options.0.resource_record_type}" | ||
zone_id = "${data.aws_route53_zone.main.id}" | ||
records = ["${aws_acm_certificate.cert.domain_validation_options.0.resource_record_value}"] | ||
provider = aws.cloudfront | ||
name = aws_acm_certificate.cert.domain_validation_options[0].resource_record_name | ||
type = aws_acm_certificate.cert.domain_validation_options[0].resource_record_type | ||
zone_id = data.aws_route53_zone.main.id | ||
records = [aws_acm_certificate.cert.domain_validation_options[0].resource_record_value] | ||
ttl = 60 | ||
} | ||
|
||
resource "aws_acm_certificate_validation" "cert" { | ||
provider = "aws.cloudfront" | ||
certificate_arn = "${aws_acm_certificate.cert.arn}" | ||
validation_record_fqdns = ["${aws_route53_record.cert_validation.fqdn}"] | ||
provider = aws.cloudfront | ||
certificate_arn = aws_acm_certificate.cert.arn | ||
validation_record_fqdns = [aws_route53_record.cert_validation.fqdn] | ||
} | ||
|
||
|
||
# Route 53 record for the static site | ||
|
||
data "aws_route53_zone" "main" { | ||
provider = "aws.main" | ||
name = "${var.cookieDomain}" | ||
provider = aws.main | ||
name = var.cookieDomain | ||
private_zone = false | ||
} | ||
|
||
resource "aws_route53_record" "web" { | ||
provider = "aws.main" | ||
zone_id = "${data.aws_route53_zone.main.zone_id}" | ||
name = "${var.fqdn}" | ||
provider = aws.main | ||
zone_id = data.aws_route53_zone.main.zone_id | ||
name = var.fqdn | ||
type = "A" | ||
|
||
alias { | ||
name = "${module.main.cf_domain_name}" | ||
zone_id = "${module.main.cf_hosted_zone_id}" | ||
name = module.main.cf_domain_name | ||
zone_id = module.main.cf_hosted_zone_id | ||
evaluate_target_health = false | ||
} | ||
} | ||
|
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 |
---|---|---|
@@ -1,23 +1,24 @@ | ||
output "s3_domain" { | ||
value = "${module.main.s3_website_endpoint}" | ||
value = module.main.s3_website_endpoint | ||
} | ||
|
||
output "cloudfront_domain" { | ||
value = "${module.main.cf_domain_name}" | ||
value = module.main.cf_domain_name | ||
} | ||
|
||
output "cloudfront_hosted_zone_id" { | ||
value = "${module.main.cf_hosted_zone_id}" | ||
value = module.main.cf_hosted_zone_id | ||
} | ||
|
||
output "cloudfront_distribution_id" { | ||
value = "${module.main.cf_distribution_id}" | ||
value = module.main.cf_distribution_id | ||
} | ||
|
||
output "route53_fqdn" { | ||
value = "${aws_route53_record.web.fqdn}" | ||
value = aws_route53_record.web.fqdn | ||
} | ||
|
||
output "acm_certificate_arn" { | ||
value = "${aws_acm_certificate_validation.cert.certificate_arn}" | ||
value = aws_acm_certificate_validation.cert.certificate_arn | ||
} | ||
|
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,13 +1,26 @@ | ||
variable "region" { | ||
description = "fix region empty issue of terraform v12" | ||
type = string | ||
default = "us-east-1" | ||
} | ||
|
||
# AWS Region for S3 and other resources | ||
provider "aws" { | ||
// region = "us-east-1" | ||
region = "us-west-2" | ||
alias = "main" | ||
alias = "main" | ||
version = "~> 2.9" | ||
} | ||
|
||
|
||
# AWS Region for Cloudfront (ACM certs only supports us-east-1) | ||
provider "aws" { | ||
region = "us-east-1" | ||
alias = "cloudfront" | ||
alias = "cloudfront" | ||
version = "~> 2.9" | ||
} | ||
|
||
|
||
|
||
provider "aws" { | ||
region = var.region | ||
} |
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,5 +1,7 @@ | ||
resource "aws_s3_bucket_object" "object" { | ||
bucket = "${var.bucketName}" | ||
key = "${var.bucketKey}" | ||
bucket = var.bucketName | ||
key = var.bucketKey | ||
source = "${path.module}/config.json" | ||
provider = aws.main | ||
} | ||
|
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,4 @@ | ||
|
||
terraform { | ||
required_version = ">= 0.12" | ||
} |
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 |
---|---|---|
@@ -1,23 +1,24 @@ | ||
output "fn_name" { | ||
value = "${aws_lambda_function.this.function_name}" | ||
value = aws_lambda_function.this.function_name | ||
} | ||
|
||
output "arn" { | ||
value = "${aws_lambda_function.this.arn}" | ||
value = aws_lambda_function.this.arn | ||
} | ||
|
||
output "qualified_arn" { | ||
value = "${aws_lambda_function.this.qualified_arn}" | ||
value = aws_lambda_function.this.qualified_arn | ||
} | ||
|
||
output "invoke_arn" { | ||
value = "${aws_lambda_function.this.invoke_arn}" | ||
value = aws_lambda_function.this.invoke_arn | ||
} | ||
|
||
output "id" { | ||
value = "${aws_lambda_function.this.id}" | ||
value = aws_lambda_function.this.id | ||
} | ||
|
||
output "version" { | ||
value = "${aws_lambda_function.this.version}" | ||
value = aws_lambda_function.this.version | ||
} | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
|
||
terraform { | ||
required_version = ">= 0.12" | ||
} |