
Route traffic dynamically between API Gateway endpoints using CloudFront Functions and Key Value Store without redeploying infrastructure.
git clone https://github.com/aws-samples/serverless-patterns/cd serverless-patterns/cloudfront-keyvaluestore-apigw-routing/typescript/cdkClone the repository: git clone https://github.com/aws-samples/serverless-patternsChange directory: cd cloudfront-keyvaluestore-apigw-routing/typescript/cdkInstall dependencies: npm installDeploy the CDK stack: cdk deployaws cloudfront-keyvaluestore describe-key-value-store --kvs-arn=[KVSTOREARN]aws cloudfront-keyvaluestore update-keys --kvs-arn=[KVSTOREARN] --if-match=[ETAG] --puts '[{"Key": "APIGW1URL", "Value": "[APIGATEWAY1URL]"},{"Key": "APIGW2URL", "Value": "[APIGATEWAY2URL]"}]'curl -i -L [CLOUDFRONTDOMAINNAME]{"message": "Hello from API 1"} or {"message": "Hello from API 2"}cdk destroy