File tree 6 files changed +42
-3
lines changed
6 files changed +42
-3
lines changed Original file line number Diff line number Diff line change 1
- # tf-aws-static-site
1
+ # tf-aws-static-site
2
+
3
+ Example use:
4
+ ``` hcl
5
+ module "hugo_blog" {
6
+ source = "git::https://github.com/tabletcorry/tf-aws-static-site.git?ref=v1.1"
7
+
8
+ # Name for S3 bucket and possibly other resources in AWS
9
+ name = "hugo-bucket-name"
10
+ # Primary domain name for Cloudfront and certificate
11
+ primary_domain_name = "example.com"
12
+ # Secondary names for Cloudfront and certificate
13
+ secondary_domain_names = ["www.example.com"]
14
+ # JS Cloudfront function script for request path
15
+ request_function_path = "${path.module}/request.js"
16
+ }
17
+ ```
Original file line number Diff line number Diff line change @@ -7,7 +7,6 @@ resource "aws_acm_certificate" "cloudfront" {
7
7
}
8
8
9
9
subject_alternative_names = var. secondary_domain_names
10
-
11
10
}
12
11
13
12
resource "aws_acm_certificate_validation" "cloudfront" {
Original file line number Diff line number Diff line change @@ -70,9 +70,13 @@ resource "aws_cloudfront_distribution" "self" {
70
70
71
71
resource "aws_cloudfront_function" "request" {
72
72
code = file (var. request_function_path )
73
- name = " indexer "
73
+ name = " ${ var . name } -request "
74
74
runtime = " cloudfront-js-1.0"
75
75
publish = true
76
+
77
+ lifecycle {
78
+ create_before_destroy = true
79
+ }
76
80
}
77
81
78
82
resource "aws_cloudfront_response_headers_policy" "self" {
Original file line number Diff line number Diff line change @@ -18,4 +18,9 @@ variable "request_function_path" {
18
18
variable "cloudfront_priceclass" {
19
19
type = string
20
20
default = " PriceClass_200"
21
+ }
22
+
23
+ variable "tags" {
24
+ type = map (string )
25
+ default = {}
21
26
}
Original file line number Diff line number Diff line change 1
1
locals {
2
2
s3_origin_id = " blogs3origin"
3
+ module_tags = {
4
+ module = " tf-aws-static-site"
5
+ module_var_name = var.name
6
+ }
7
+ tags = merge (local. module_tags , var. tags )
3
8
}
Original file line number Diff line number Diff line change 1
1
provider "aws" {
2
2
alias = " us-east-1"
3
3
region = " us-east-1"
4
+
5
+ default_tags {
6
+ tags = local. tags
7
+ }
8
+ }
9
+
10
+ provider "aws" {
11
+ default_tags {
12
+ tags = local. tags
13
+ }
4
14
}
You can’t perform that action at this time.
0 commit comments