Skip to content

Commit 24d246d

Browse files
committed
update examples and function location
1 parent e984ded commit 24d246d

File tree

4 files changed

+15
-15
lines changed

4 files changed

+15
-15
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ No modules.
261261
| Name | Description | Type | Default | Required |
262262
|------|-------------|------|---------|:--------:|
263263
| <a name="input_aliases"></a> [aliases](#input\_aliases) | Extra CNAMEs (alternate domain names), if any, for this distribution. | `list(string)` | `null` | no |
264-
| <a name="input_cloudfront_functions"></a> [cloudfront\_functions](#input\_cloudfront\_functions) | Map of CloudFront Function configurations. Key is used as default function name if 'name' not specified. | <pre>map(object({<br/> name = optional(string)<br/> runtime = optional(string, "cloudfront-js-2.0")<br/> comment = optional(string)<br/> publish = optional(bool, true)<br/> code = string<br/> key_value_store_associations = optional(list(string), null)<br/> }))</pre> | `{}` | no |
264+
| <a name="input_cloudfront_functions"></a> [cloudfront\_functions](#input\_cloudfront\_functions) | Map of CloudFront Function configurations. Key is used as default function name if 'name' not specified. | <pre>map(object({<br/> name = optional(string)<br/> runtime = optional(string, "cloudfront-js-2.0")<br/> comment = optional(string)<br/> publish = optional(bool, true)<br/> code_path = string<br/> key_value_store_associations = optional(list(string), null)<br/> }))</pre> | `{}` | no |
265265
| <a name="input_comment"></a> [comment](#input\_comment) | Any comments you want to include about the distribution. | `string` | `null` | no |
266266
| <a name="input_continuous_deployment_policy_id"></a> [continuous\_deployment\_policy\_id](#input\_continuous\_deployment\_policy\_id) | Identifier of a continuous deployment policy. This argument should only be set on a production distribution. | `string` | `null` | no |
267267
| <a name="input_create_cloudfront_function"></a> [create\_cloudfront\_function](#input\_create\_cloudfront\_function) | Controls if CloudFront Functions should be created | `bool` | `false` | no |

examples/complete/main.tf

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -250,22 +250,22 @@ module "cloudfront" {
250250
create_cloudfront_function = true
251251
cloudfront_functions = {
252252
viewer-request-security = {
253-
runtime = "cloudfront-js-2.0"
254-
comment = "Security headers and cache key normalization"
255-
code = file("${path.module}/viewer-request-security.js")
256-
publish = true
253+
runtime = "cloudfront-js-2.0"
254+
comment = "Security headers and cache key normalization"
255+
code_path = "functions/viewer-request-security.js"
256+
publish = true
257257
}
258258
viewer-response-headers = {
259-
runtime = "cloudfront-js-2.0"
260-
comment = "Add security response headers"
261-
code = file("${path.module}/viewer-response-headers.js")
262-
publish = true
259+
runtime = "cloudfront-js-2.0"
260+
comment = "Add security response headers"
261+
code_path = "functions/viewer-response-headers.js"
262+
publish = true
263263
}
264264
ab-testing = {
265-
runtime = "cloudfront-js-2.0"
266-
comment = "A/B testing function"
267-
code = file("${path.module}/ab-testing.js")
268-
publish = true
265+
runtime = "cloudfront-js-2.0"
266+
comment = "A/B testing function"
267+
code_path = "functions//ab-testing.js"
268+
publish = true
269269
}
270270
# Example with KeyValueStore association (uncomment and provide actual KV store ARN)
271271
# kvstore-redirect = {

main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ resource "aws_cloudfront_function" "this" {
152152
runtime = each.value.runtime
153153
comment = each.value.comment
154154
publish = each.value.publish
155-
code = each.value.code
155+
code = file("${path.module}/${each.value.code_path}")
156156

157157
key_value_store_associations = each.value.key_value_store_associations
158158
}

variables.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ variable "cloudfront_functions" {
306306
runtime = optional(string, "cloudfront-js-2.0")
307307
comment = optional(string)
308308
publish = optional(bool, true)
309-
code = string
309+
code_path = string
310310
key_value_store_associations = optional(list(string), null)
311311
}))
312312
default = {}

0 commit comments

Comments
 (0)