From 099530125a68b733793d5bf6c195c190fc1f538a Mon Sep 17 00:00:00 2001 From: Harshil Sanjay Jain Date: Tue, 18 Jun 2024 14:18:06 -0400 Subject: [PATCH] Update javadoc and example with new policy --- examples/cloudfront/cloudfront.gyro | 71 ++++++++++++++++++- .../aws/cloudfront/CloudFrontResource.java | 34 ++++----- 2 files changed, 88 insertions(+), 17 deletions(-) diff --git a/examples/cloudfront/cloudfront.gyro b/examples/cloudfront/cloudfront.gyro index 466cb8011..9a3094f17 100644 --- a/examples/cloudfront/cloudfront.gyro +++ b/examples/cloudfront/cloudfront.gyro @@ -1,3 +1,71 @@ +aws::cloudfront-cache-policy cache-policy-example + cache-policy-config + default-ttl: 3600 + max-ttl: 86400 + min-ttl: 0 + name: "cache-policy-example" + + key-param + accept-encoding-brotli: true + accept-encoding-gzip: true + + headers-config + header-behavior: "whitelist" + headers: [ + "example-header1", + "example-header2" + ] + end + + query-strings-config + query-string-behavior: "whitelist" + query-strings: [ + "example-query1", + "example-query2" + ] + end + + cookies-config + cookie-behavior: "whitelist" + cookies: [ + "example-cookie1", + "example-cookie2" + ] + end + end + end +end + +aws::cloudfront-origin-request-policy origin-request-policy-example + origin-request-policy-config + name: "origin-request-policy-example" + + headers-config + header-behavior: "whitelist" + headers: [ + "example-header1", + "example-header2" + ] + end + + query-strings-config + query-string-behavior: "whitelist" + query-strings: [ + "example-query1", + "example-query2" + ] + end + + cookies-config + cookie-behavior: "whitelist" + cookies: [ + "example-cookie1", + "example-cookie2" + ] + end + end +end + aws::cloudfront cloudfront-example enabled: true ipv6-enabled: false @@ -22,7 +90,8 @@ aws::cloudfront cloudfront-example viewer-protocol-policy: "allow-all" allowed-methods: ["GET", "HEAD"] cached-methods: ["GET", "HEAD"] - headers: ["Origin"] + cache-policy: $(aws::cloudfront-cache-policy cache-policy-example) + origin-request-policy: $(aws::cloudfront-origin-request-policy origin-request-policy-example) end behavior diff --git a/src/main/java/gyro/aws/cloudfront/CloudFrontResource.java b/src/main/java/gyro/aws/cloudfront/CloudFrontResource.java index 9ae793dbc..ca947822e 100644 --- a/src/main/java/gyro/aws/cloudfront/CloudFrontResource.java +++ b/src/main/java/gyro/aws/cloudfront/CloudFrontResource.java @@ -73,10 +73,15 @@ * aws::cloudfront cloudfront-example * enabled: true * ipv6-enabled: false - * comment: "cloudfront-example - static asset cache" + * comment: "$(project) - static asset cache" * * origin - * id: $(aws::s3-bucket bucket).name + * id: "S3-$(project)-brightspot" + * domain-name: "$(project)-brightspot.s3.us-east-1.amazonaws.com" + * end + * + * origin + * id: "elb-$(project)-web" * domain-name: "www.google.com" * * custom-origin @@ -85,16 +90,17 @@ * end * * default-cache-behavior - * target-origin-id: $(aws::s3-bucket bucket).name + * target-origin-id: "S3-$(project)-brightspot" * viewer-protocol-policy: "allow-all" * allowed-methods: ["GET", "HEAD"] * cached-methods: ["GET", "HEAD"] - * headers: ["Origin"] + * cache-policy: $(aws::cloudfront-cache-policy cache-policy-example) + * origin-request-policy: $(aws::cloudfront-origin-request-policy origin-request-policy-example) * end * * behavior * path-pattern: "/dims?/*" - * target-origin-id: $(aws::s3-bucket bucket).name + * target-origin-id: "elb-$(project)-web" * viewer-protocol-policy: "allow-all" * allowed-methods: ["GET", "HEAD"] * query-string: true @@ -105,21 +111,17 @@ * restrictions: ["US"] * end * - * custom-error-response - * error-code: 400 - * ttl: 0 - * end - * - * logging - * bucket: $(aws::s3-bucket bucket) - * bucket-prefix: "my-bucket/logs" - * include-cookies: false - * end + * @for error-code, ttl -in [400, 0, 403, 5, 404, 5, 500, 0, 502, 0, 503, 0, 504, 0] + * custom-error-response + * error-code: $(error-code) + * ttl: $(ttl) + * end + * @end * * tags: { * Name: "content cache" * } - * end + * end */ @Type("cloudfront") public class CloudFrontResource extends AwsResource implements Copyable {