File tree Expand file tree Collapse file tree 1 file changed +22
-5
lines changed
Expand file tree Collapse file tree 1 file changed +22
-5
lines changed Original file line number Diff line number Diff line change @@ -169,6 +169,10 @@ module "cloudfront" {
169169 viewer-request = {
170170 function_arn = aws_cloudfront_function.example.arn
171171 }
172+ # Or ARN reference to standalone function created with the module
173+ viewer-response = {
174+ function_arn = module.standalone_cloudfront_functions.cloudfront_functions.example.arn
175+ }
172176
173177 # Option 2: Dynamic reference to module-managed function by key/name
174178 # Uncomment to use module-managed functions instead:
@@ -179,11 +183,6 @@ module "cloudfront" {
179183 # viewer-response = {
180184 # function_key = "viewer-response-headers"
181185 # }
182-
183- # For this example, using standalone function for both
184- viewer-response = {
185- function_arn = aws_cloudfront_function.example.arn
186- }
187186 }
188187 },
189188 {
@@ -337,6 +336,24 @@ module "cloudfront" {
337336 tags = local. tags
338337}
339338
339+ # Create CloudFront function using the module
340+ module "standalone_cloudfront_functions" {
341+ source = " ../../"
342+
343+ # Don't create main resources, only functions
344+ create = false
345+
346+ cloudfront_functions = {
347+ example = {
348+ name = " shared-${ local . name } "
349+ runtime = " cloudfront-js-1.0"
350+ code = file (" ./functions/example-function.js" )
351+ }
352+ }
353+
354+ origin_access_control = {}
355+ }
356+
340357module "records" {
341358 source = " terraform-aws-modules/route53/aws//modules/records"
342359 version = " ~> 5.0"
You can’t perform that action at this time.
0 commit comments