Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
188 changes: 188 additions & 0 deletions .doc_gen/metadata/cloudfront-functions_metadata.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
cloudfront_functions_add_cache_control_header:
title: Add a cache control header to a &CF; Functions viewer response event
title_abbrev: Add a cache control header
synopsis: add a cache control header to a &CF; Functions viewer response event.

category: CloudFront Functions examples
languages:
JavaScript:
versions:
- sdk_version: 2
github: https://github.com/aws-samples/amazon-cloudfront-functions/tree/main/add-cache-control-header
excerpts:
- description:
snippet_files:
- add-cache-control-header/index.js
services:
cloudfront:
cloudfront_functions_add_cors_header:
title: Add a CORS header to a &CF; Functions viewer response event
title_abbrev: Add a CORS header
synopsis: add a CORS header to a &CF; Functions viewer response event.

category: CloudFront Functions examples
languages:
JavaScript:
versions:
- sdk_version: 2
github: https://github.com/aws-samples/amazon-cloudfront-functions/tree/main/add-cors-header
excerpts:
- description:
snippet_files:
- add-cors-header/index.js
services:
cloudfront:
cloudfront_functions_add_origin_header:
title: Add an origin header to a &CF; Functions viewer request event
title_abbrev: Add an origin header
synopsis: add an origin header to a &CF; Functions viewer request event.

category: CloudFront Functions examples
languages:
JavaScript:
versions:
- sdk_version: 2
github: https://github.com/aws-samples/amazon-cloudfront-functions/tree/main/add-origin-header
excerpts:
- description:
snippet_files:
- add-origin-header/index.js
services:
cloudfront:
cloudfront_functions_add_security_headers:
title: Add HTTP security headers to a &CF; Functions viewer response event
title_abbrev: Add HTTP security headers
synopsis: add HTTP security headers to a &CF; Functions viewer response event.

category: CloudFront Functions examples
languages:
JavaScript:
versions:
- sdk_version: 2
github: https://github.com/aws-samples/amazon-cloudfront-functions/tree/main/add-security-headers
excerpts:
- description:
snippet_files:
- add-security-headers/index.js
services:
cloudfront:
cloudfront_functions_add_true_client_ip_header:
title: Add a true client IP header to a &CF; Functions viewer request event
title_abbrev: Add a true client IP header
synopsis: add a true client IP header to a &CF; Functions viewer request event.

category: CloudFront Functions examples
languages:
JavaScript:
versions:
- sdk_version: 2
github: https://github.com/aws-samples/amazon-cloudfront-functions/tree/main/add-true-client-ip-header
excerpts:
- description:
snippet_files:
- add-true-client-ip-header/index.js
services:
cloudfront:
cloudfront_functions_kvs_conditional_read:
title: Rewrite a request URI based on KeyValueStore configuration for a &CF; Functions viewer request event
title_abbrev: Rewrite a request URI
synopsis: rewrite a request URI based on KeyValueStore configuration for a &CF; Functions viewer request event.

category: CloudFront Functions examples
languages:
JavaScript:
versions:
- sdk_version: 2
github: https://github.com/aws-samples/amazon-cloudfront-functions/tree/main/kvs-conditional-read
excerpts:
- description:
snippet_files:
- kvs-conditional-read/ABUriMappingFunction.js
services:
cloudfront:
cloudfront_functions_kvs_jwt_verify:
title: Validate a simple token in a &CF; Functions viewer request
title_abbrev: Validate a simple token
synopsis: validate a simple token in a &CF; Functions viewer request.

category: CloudFront Functions examples
languages:
JavaScript:
versions:
- sdk_version: 2
github: https://github.com/aws-samples/amazon-cloudfront-functions/tree/main/kvs-jwt-verify
excerpts:
- description:
snippet_files:
- kvs-jwt-verify/verify-jwt.js
services:
cloudfront:
cloudfront_functions_kvs_key_value_pairs:
title: Use key-value pairs in a &CF; Functions viewer request
title_abbrev: Use key-value pairs
synopsis: use key-value pairs in a &CF; Functions viewer request.

category: CloudFront Functions examples
languages:
JavaScript:
versions:
- sdk_version: 2
github: https://github.com/aws-samples/amazon-cloudfront-functions/tree/main/kvs-key-value-pairs
excerpts:
- description:
snippet_files:
- kvs-key-value-pairs/kvs-key-value-pairs.js
services:
cloudfront:
cloudfront_functions_normalize_query_string_parameters:
title: Normalize query string parameters in a &CF; Functions viewer request
title_abbrev: Normalize query string parameters
synopsis: normalize query string parameters in a &CF; Functions viewer request.

category: CloudFront Functions examples
languages:
JavaScript:
versions:
- sdk_version: 2
github: https://github.com/aws-samples/amazon-cloudfront-functions/tree/main/normalize-query-string-parameters
excerpts:
- description:
snippet_files:
- normalize-query-string-parameters/normalize-query-string.js
services:
cloudfront:
cloudfront_functions_redirect_based_on_country:
title: Redirect to a new URL in a &CF; Functions viewer request event
title_abbrev: Redirect to a new URL
synopsis: redirect to a new URL in a &CF; Functions viewer request event.

category: CloudFront Functions examples
languages:
JavaScript:
versions:
- sdk_version: 2
github: https://github.com/aws-samples/amazon-cloudfront-functions/tree/main/redirect-based-on-country
excerpts:
- description:
snippet_files:
- redirect-based-on-country/index.js
services:
cloudfront:
cloudfront_functions_url_rewrite_single_page_apps:
title: Add index.html to request URLs without a file name in a &CF; Functions viewer request event
title_abbrev: Add index.html to request URLs
synopsis: add index.html to request URLs without a file name in a &CF; Functions viewer request event.

category: CloudFront Functions examples
languages:
JavaScript:
versions:
- sdk_version: 2
github: https://github.com/aws-samples/amazon-cloudfront-functions/tree/main/url-rewrite-single-page-apps
excerpts:
- description:
snippet_files:
- url-rewrite-single-page-apps/index.js
services:
cloudfront:

15 changes: 15 additions & 0 deletions .doc_gen/metadata/services.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
cloudfront_functions:
bundle: cloudfront
long: "&CFlong; Functions"
short: "&CF; Functions"
sort: CloudFront Functions
expanded:
long: Amazon CloudFront Functions
short: CloudFront Functions
blurb: helps you write lightweight functions in JavaScript for high-scale, latency-sensitive CDN customizations.
guide:
subtitle: Developer Guide
url: AmazonCloudFront/latest/DeveloperGuide/cloudfront-functions.html
tags:
product_categories: { "Networking & Content Delivery" }
version: 1
22 changes: 22 additions & 0 deletions .github/workflows/validate.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Validate Documentation Metadata

on: # yamllint disable-line rule:truthy
workflow_dispatch:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
validate-doc-metadata:
name: Validate Doc Metadata
runs-on: ubuntu-latest

steps:
- name: checkout repo content
uses: actions/checkout@v4
- name: validate metadata
uses: awsdocs/aws-doc-sdk-examples-tools@2024-09-13-B
with:
doc_gen_only: "False"
strict_titles: "True"
3 changes: 3 additions & 0 deletions add-cache-control-header/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

function handler(event) {
var response = event.response;
var headers = response.headers;
Expand Down
3 changes: 3 additions & 0 deletions add-cors-header/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

function handler(event) {
var request = event.request;
var response = event.response;
Expand Down
3 changes: 3 additions & 0 deletions add-origin-header/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

function handler(event) {
var request = event.request;
var headers = request.headers;
Expand Down
3 changes: 3 additions & 0 deletions add-security-headers/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

function handler(event) {
var response = event.response;
var headers = response.headers;
Expand Down
3 changes: 3 additions & 0 deletions add-true-client-ip-header/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

function handler(event) {
var request = event.request;
var clientIP = event.viewer.ip;
Expand Down
3 changes: 3 additions & 0 deletions kvs-conditional-read/ABUriMappingFunction.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

import cf from 'cloudfront';

// (Optional) Replace KVS_ID with actual KVS ID
Expand Down
3 changes: 3 additions & 0 deletions kvs-jwt-verify/generate-jwt.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0

#!/usr/bin/env bash

#
Expand Down
3 changes: 3 additions & 0 deletions kvs-jwt-verify/verify-jwt.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

import crypto from 'crypto';
import cf from 'cloudfront';

Expand Down
3 changes: 3 additions & 0 deletions kvs-key-value-pairs/kvs-key-value-pairs.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

import cf from 'cloudfront';

// This fails if there is no key value store associated with the function
Expand Down
3 changes: 3 additions & 0 deletions normalize-query-string-parameters/normalize-query-string.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

function handler(event) {
var qs=[];
for (var key in event.request.querystring) {
Expand Down
3 changes: 3 additions & 0 deletions redirect-based-on-country/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

function handler(event) {
var request = event.request;
var headers = request.headers;
Expand Down
3 changes: 3 additions & 0 deletions url-rewrite-single-page-apps/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

function handler(event) {
var request = event.request;
var uri = request.uri;
Expand Down
Loading