diff --git a/apigw-sqs-msg-filtering-cdk/README.md b/apigw-sqs-msg-filtering-cdk/README.md new file mode 100644 index 000000000..b98ca61d0 --- /dev/null +++ b/apigw-sqs-msg-filtering-cdk/README.md @@ -0,0 +1,86 @@ +# Amazon API Gateway to Amazon SQS with message filtering + +This project contains sample AWS CDK code to create an API Gateway Rest API, an SQS Queue and the correct VTL integration mapping template to filter out parts of the message body. + +Learn more about this pattern at Serverless Land Patterns: https://serverlessland.com/patterns/apigw-sqs-msg-filtering-cdk + +Important: this application uses various AWS services and there are costs associated with these services after the Free Tier usage - please see the AWS Pricing page for details. You are responsible for any AWS costs incurred. No warranty is implied in this example. + +## Requirements + +* [Create an AWS account](https://portal.aws.amazon.com/gp/aws/developer/registration/index.html) if you do not already have one and log in. The IAM user that you use must have sufficient permissions to make necessary AWS service calls and manage AWS resources. +* [AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2.html) installed and configured +* [Git Installed](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) +* [Node and NPM](https://nodejs.org/en/download/) installed +* [AWS Cloud Development Kit](https://docs.aws.amazon.com/cdk/latest/guide/cli.html) (AWS CDK) installed + +## Deployment Instructions + +1. Create a new directory, navigate to that directory in a terminal and clone the GitHub repository: + +``` +git clone https://github.com/aws-samples/serverless-patterns +``` + +2. Change directory to the pattern directory: + +``` +cd apigw-sqs-msg-filtering-cdk/cdk +``` + +3. Install dependencies + +``` +npm install +``` + +4. This project uses typescript as client language for AWS CDK. Run the given command to compile TypeScript to JavaScript + +``` +npm run build +``` + +5. Synthesize CloudFormation template from the AWS CDK app + +``` +cdk synth +``` + +6. Deploy the stack to your default AWS account and region. + +``` +cdk deploy +``` + +## Testing + +Run the following command to send a POST request to the REST API endpoint that will then send the filtered message to the SQS queue. Run the commands from the `apigw-sqs-msg-filtering-cdk` folder. + +```bash +export API_GATEWAY_SQS_RESOURCE_ENDPOINT=$(aws cloudformation describe-stacks --stack-name ApigwSqsMsgFilteringCdkStack --query 'Stacks[0].Outputs[?OutputKey==`ApiGatewaySqsResourceEndpoint`].OutputValue' --output text) + +curl --location --request POST $API_GATEWAY_SQS_RESOURCE_ENDPOINT \ +--header 'Content-Type: application/json' \ +-d @test/test-payload.json +``` + +To check and receive messages in the queue, it can be done in the AWS console or by running the following command. Note, replace {MyQueueUrl} placeholder in the command with the endpoint that has been deployed. The endpoint can be found in the CloudFormation stack output. + +```bash +export SQS_QUEUE_URL=$(aws cloudformation describe-stacks --stack-name ApigwSqsMsgFilteringCdkStack --query 'Stacks[0].Outputs[?OutputKey==`SqsQueueUrl`].OutputValue' --output text) + +aws sqs receive-message --queue-url $SQS_QUEUE_URL +``` + +## Cleanup + +1. Delete the stack + ```bash + cdk destroy --all + ``` + +--- + +Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved. + +SPDX-License-Identifier: MIT-0 diff --git a/apigw-sqs-msg-filtering-cdk/cdk/.gitignore b/apigw-sqs-msg-filtering-cdk/cdk/.gitignore new file mode 100644 index 000000000..f60797b6a --- /dev/null +++ b/apigw-sqs-msg-filtering-cdk/cdk/.gitignore @@ -0,0 +1,8 @@ +*.js +!jest.config.js +*.d.ts +node_modules + +# CDK asset staging directory +.cdk.staging +cdk.out diff --git a/apigw-sqs-msg-filtering-cdk/cdk/.npmignore b/apigw-sqs-msg-filtering-cdk/cdk/.npmignore new file mode 100644 index 000000000..c1d6d45dc --- /dev/null +++ b/apigw-sqs-msg-filtering-cdk/cdk/.npmignore @@ -0,0 +1,6 @@ +*.ts +!*.d.ts + +# CDK asset staging directory +.cdk.staging +cdk.out diff --git a/apigw-sqs-msg-filtering-cdk/cdk/bin/apigw-sqs-msg-filtering-cdk.ts b/apigw-sqs-msg-filtering-cdk/cdk/bin/apigw-sqs-msg-filtering-cdk.ts new file mode 100644 index 000000000..639cc0b1c --- /dev/null +++ b/apigw-sqs-msg-filtering-cdk/cdk/bin/apigw-sqs-msg-filtering-cdk.ts @@ -0,0 +1,20 @@ +#!/usr/bin/env node +import * as cdk from 'aws-cdk-lib'; +import { ApigwSqsMsgFilteringCdkStack } from '../lib/apigw-sqs-msg-filtering-cdk-stack'; + +const app = new cdk.App(); +new ApigwSqsMsgFilteringCdkStack(app, 'ApigwSqsMsgFilteringCdkStack', { + /* If you don't specify 'env', this stack will be environment-agnostic. + * Account/Region-dependent features and context lookups will not work, + * but a single synthesized template can be deployed anywhere. */ + + /* Uncomment the next line to specialize this stack for the AWS Account + * and Region that are implied by the current CLI configuration. */ + // env: { account: process.env.CDK_DEFAULT_ACCOUNT, region: process.env.CDK_DEFAULT_REGION }, + + /* Uncomment the next line if you know exactly what Account and Region you + * want to deploy the stack to. */ + // env: { account: '123456789012', region: 'us-east-1' }, + + /* For more information, see https://docs.aws.amazon.com/cdk/latest/guide/environments.html */ +}); \ No newline at end of file diff --git a/apigw-sqs-msg-filtering-cdk/cdk/cdk.json b/apigw-sqs-msg-filtering-cdk/cdk/cdk.json new file mode 100644 index 000000000..c9e33593a --- /dev/null +++ b/apigw-sqs-msg-filtering-cdk/cdk/cdk.json @@ -0,0 +1,94 @@ +{ + "app": "npx ts-node --prefer-ts-exts bin/apigw-sqs-msg-filtering-cdk.ts", + "watch": { + "include": ["**"], + "exclude": [ + "README.md", + "cdk*.json", + "**/*.d.ts", + "**/*.js", + "tsconfig.json", + "package*.json", + "yarn.lock", + "node_modules", + "test" + ] + }, + "context": { + "@aws-cdk/aws-lambda:recognizeLayerVersion": true, + "@aws-cdk/core:checkSecretUsage": true, + "@aws-cdk/core:target-partitions": ["aws", "aws-cn"], + "@aws-cdk-containers/ecs-service-extensions:enableDefaultLogDriver": true, + "@aws-cdk/aws-ec2:uniqueImdsv2TemplateName": true, + "@aws-cdk/aws-ecs:arnFormatIncludesClusterName": true, + "@aws-cdk/aws-iam:minimizePolicies": true, + "@aws-cdk/core:validateSnapshotRemovalPolicy": true, + "@aws-cdk/aws-codepipeline:crossAccountKeyAliasStackSafeResourceName": true, + "@aws-cdk/aws-s3:createDefaultLoggingPolicy": true, + "@aws-cdk/aws-sns-subscriptions:restrictSqsDescryption": true, + "@aws-cdk/aws-apigateway:disableCloudWatchRole": true, + "@aws-cdk/core:enablePartitionLiterals": true, + "@aws-cdk/aws-events:eventsTargetQueueSameAccount": true, + "@aws-cdk/aws-ecs:disableExplicitDeploymentControllerForCircuitBreaker": true, + "@aws-cdk/aws-iam:importedRoleStackSafeDefaultPolicyName": true, + "@aws-cdk/aws-s3:serverAccessLogsUseBucketPolicy": true, + "@aws-cdk/aws-route53-patters:useCertificate": true, + "@aws-cdk/customresources:installLatestAwsSdkDefault": false, + "@aws-cdk/aws-rds:databaseProxyUniqueResourceName": true, + "@aws-cdk/aws-codedeploy:removeAlarmsFromDeploymentGroup": true, + "@aws-cdk/aws-apigateway:authorizerChangeDeploymentLogicalId": true, + "@aws-cdk/aws-ec2:launchTemplateDefaultUserData": true, + "@aws-cdk/aws-secretsmanager:useAttachedSecretResourcePolicyForSecretTargetAttachments": true, + "@aws-cdk/aws-redshift:columnId": true, + "@aws-cdk/aws-stepfunctions-tasks:enableEmrServicePolicyV2": true, + "@aws-cdk/aws-ec2:restrictDefaultSecurityGroup": true, + "@aws-cdk/aws-apigateway:requestValidatorUniqueId": true, + "@aws-cdk/aws-kms:aliasNameRef": true, + "@aws-cdk/aws-kms:applyImportedAliasPermissionsToPrincipal": true, + "@aws-cdk/aws-autoscaling:generateLaunchTemplateInsteadOfLaunchConfig": true, + "@aws-cdk/core:includePrefixInUniqueNameGeneration": true, + "@aws-cdk/aws-efs:denyAnonymousAccess": true, + "@aws-cdk/aws-opensearchservice:enableOpensearchMultiAzWithStandby": true, + "@aws-cdk/aws-lambda-nodejs:useLatestRuntimeVersion": true, + "@aws-cdk/aws-efs:mountTargetOrderInsensitiveLogicalId": true, + "@aws-cdk/aws-rds:auroraClusterChangeScopeOfInstanceParameterGroupWithEachParameters": true, + "@aws-cdk/aws-appsync:useArnForSourceApiAssociationIdentifier": true, + "@aws-cdk/aws-rds:preventRenderingDeprecatedCredentials": true, + "@aws-cdk/aws-codepipeline-actions:useNewDefaultBranchForCodeCommitSource": true, + "@aws-cdk/aws-cloudwatch-actions:changeLambdaPermissionLogicalIdForLambdaAction": true, + "@aws-cdk/aws-codepipeline:crossAccountKeysDefaultValueToFalse": true, + "@aws-cdk/aws-codepipeline:defaultPipelineTypeToV2": true, + "@aws-cdk/aws-kms:reduceCrossAccountRegionPolicyScope": true, + "@aws-cdk/aws-eks:nodegroupNameAttribute": true, + "@aws-cdk/aws-ec2:ebsDefaultGp3Volume": true, + "@aws-cdk/aws-ecs:removeDefaultDeploymentAlarm": true, + "@aws-cdk/custom-resources:logApiResponseDataPropertyTrueDefault": false, + "@aws-cdk/aws-s3:keepNotificationInImportedBucket": false, + "@aws-cdk/core:explicitStackTags": true, + "@aws-cdk/aws-ecs:enableImdsBlockingDeprecatedFeature": false, + "@aws-cdk/aws-ecs:disableEcsImdsBlocking": true, + "@aws-cdk/aws-ecs:reduceEc2FargateCloudWatchPermissions": true, + "@aws-cdk/aws-dynamodb:resourcePolicyPerReplica": true, + "@aws-cdk/aws-ec2:ec2SumTImeoutEnabled": true, + "@aws-cdk/aws-appsync:appSyncGraphQLAPIScopeLambdaPermission": true, + "@aws-cdk/aws-rds:setCorrectValueForDatabaseInstanceReadReplicaInstanceResourceId": true, + "@aws-cdk/core:cfnIncludeRejectComplexResourceUpdateCreatePolicyIntrinsics": true, + "@aws-cdk/aws-lambda-nodejs:sdkV3ExcludeSmithyPackages": true, + "@aws-cdk/aws-stepfunctions-tasks:fixRunEcsTaskPolicy": true, + "@aws-cdk/aws-ec2:bastionHostUseAmazonLinux2023ByDefault": true, + "@aws-cdk/aws-route53-targets:userPoolDomainNameMethodWithoutCustomResource": true, + "@aws-cdk/aws-elasticloadbalancingV2:albDualstackWithoutPublicIpv4SecurityGroupRulesDefault": true, + "@aws-cdk/aws-iam:oidcRejectUnauthorizedConnections": true, + "@aws-cdk/core:enableAdditionalMetadataCollection": true, + "@aws-cdk/aws-lambda:createNewPoliciesWithAddToRolePolicy": false, + "@aws-cdk/aws-s3:setUniqueReplicationRoleName": true, + "@aws-cdk/aws-events:requireEventBusPolicySid": true, + "@aws-cdk/core:aspectPrioritiesMutating": true, + "@aws-cdk/aws-dynamodb:retainTableReplica": true, + "@aws-cdk/aws-stepfunctions:useDistributedMapResultWriterV2": true, + "@aws-cdk/s3-notifications:addS3TrustKeyPolicyForSnsSubscriptions": true, + "@aws-cdk/aws-ec2:requirePrivateSubnetsForEgressOnlyInternetGateway": true, + "@aws-cdk/aws-s3:publicAccessBlockedByDefault": true, + "@aws-cdk/aws-lambda:useCdkManagedLogGroup": true + } +} diff --git a/apigw-sqs-msg-filtering-cdk/cdk/jest.config.js b/apigw-sqs-msg-filtering-cdk/cdk/jest.config.js new file mode 100644 index 000000000..08263b895 --- /dev/null +++ b/apigw-sqs-msg-filtering-cdk/cdk/jest.config.js @@ -0,0 +1,8 @@ +module.exports = { + testEnvironment: 'node', + roots: ['/test'], + testMatch: ['**/*.test.ts'], + transform: { + '^.+\\.tsx?$': 'ts-jest' + } +}; diff --git a/apigw-sqs-msg-filtering-cdk/cdk/lib/apigw-sqs-msg-filtering-cdk-stack.ts b/apigw-sqs-msg-filtering-cdk/cdk/lib/apigw-sqs-msg-filtering-cdk-stack.ts new file mode 100644 index 000000000..ed2e7b9a2 --- /dev/null +++ b/apigw-sqs-msg-filtering-cdk/cdk/lib/apigw-sqs-msg-filtering-cdk-stack.ts @@ -0,0 +1,80 @@ +import * as cdk from 'aws-cdk-lib'; +import { Construct } from 'constructs'; +import { ApiGwSqsConstruct } from './apigw-sqs-msg-filtering'; + +export class ApigwSqsMsgFilteringCdkStack extends cdk.Stack { + constructor(scope: Construct, id: string, props?: cdk.StackProps) { + super(scope, id, props); + + // Create custom sqs queue + const sqsQueue = new cdk.aws_sqs.Queue(this, 'apigwSqs-queue', { + queueName: 'MyQueueName', + }); + + // Create custom api gateway + const apiGateway = new cdk.aws_apigateway.RestApi(this, 'apigwSqs-restApi', { + description: 'APIGW-SQS REST API Gateway', + restApiName: 'apiGatewayToSqs', + deployOptions: { + stageName: 'dev', + }, + // Enable CORS + defaultCorsPreflightOptions: { + allowHeaders: [ + 'Content-Type', + 'X-Amz-Date', + 'Authorization', + 'X-Api-Key', + ], + allowMethods: ['OPTIONS', 'GET', 'POST', 'PUT', 'PATCH', 'DELETE'], + allowOrigins: ['*'], + }, + }); + + // https://docs.aws.amazon.com/AWSSimpleQueueService/latest/APIReference/API_SendMessage.html + const vtlMappingTemplate = ` +{ + #set($payload = $input.path('$')) + #set($messageBody = $input.path('$.messageBody')) + #if($messageBody.notNeededElement) + #set($partToRemove = $messageBody.remove("notNeededElement")) + #end + #set($payload.filteredMessageBody = $messageBody) + "MessageBody": "$util.escapeJavaScript($input.json('$.filteredMessageBody'))", + #if($payload.delaySeconds > 0) + "DelaySeconds": $payload.delaySeconds, + #end + #if($payload.messageAttributes && $payload.messageAttributes.size() > 0) + "MessageAttributes": { + #foreach($attrName in $payload.messageAttributes.keySet()) + #set($attr = $payload.messageAttributes.get($attrName)) + "$attrName": { + "DataType": "$attr.dataType", + #if($attr.dataType == "String" || $attr.dataType.startsWith("String.")) + "StringValue": "$attr.stringValue" + #elseif($attr.dataType == "Binary" || $attr.dataType.startsWith("Binary.")) + "BinaryValue": "$attr.binaryValue" + #else + "StringValue": "$attr.stringValue" + #end + }#if($foreach.hasNext),#end + #end + }, + #end + "QueueUrl": "${sqsQueue.queueUrl}" +} +`; + + new ApiGwSqsConstruct(this, 'apiGwSqs', { + apiGateway: apiGateway, + sqsQueue: sqsQueue, + vtlMappingTemplate: vtlMappingTemplate, + }); + + new cdk.CfnOutput(this, 'ApiGatewayName', { value: apiGateway.restApiName }); + new cdk.CfnOutput(this, 'ApiGatewayUrl', { value: apiGateway.url }); + new cdk.CfnOutput(this, 'ApiGatewaySqsResourceEndpoint', { value: `${apiGateway.url}sqs` }); + new cdk.CfnOutput(this, 'SqsQueueName', { value: sqsQueue.queueName }); + new cdk.CfnOutput(this, 'SqsQueueUrl', { value: sqsQueue.queueUrl }); + } +} diff --git a/apigw-sqs-msg-filtering-cdk/cdk/lib/apigw-sqs-msg-filtering.ts b/apigw-sqs-msg-filtering-cdk/cdk/lib/apigw-sqs-msg-filtering.ts new file mode 100644 index 000000000..580128120 --- /dev/null +++ b/apigw-sqs-msg-filtering-cdk/cdk/lib/apigw-sqs-msg-filtering.ts @@ -0,0 +1,93 @@ + +import { + aws_apigateway as apigw, + aws_sqs as sqs, + aws_iam as iam, +} from 'aws-cdk-lib'; +import { Construct } from 'constructs'; + +export interface ApiGwSqsProps { + /** + * API Gateway object + */ + readonly apiGateway: apigw.IRestApi; + + /** + * SQS Queue object + */ + readonly sqsQueue: sqs.IQueue; + + /** + * VTL Mapping + */ + readonly vtlMappingTemplate: string; +} + +export class ApiGwSqsConstruct extends Construct { + public customApiGateway: apigw.IRestApi; + public customQueue: sqs.IQueue; + + constructor(scope: Construct, id: string, props: ApiGwSqsProps) { + super(scope, id); + + this.customQueue = props.sqsQueue; + this.customApiGateway = props.apiGateway; + + // Create IAM Role for API Gateway + const sqsIntegrationRole = new iam.Role(this, 'apigwSqs-integration-role', { + assumedBy: new iam.ServicePrincipal('apigateway.amazonaws.com'), + }); + + // Grant sqs:SendMessage* to Api Gateway Role + this.customQueue.grantSendMessages(sqsIntegrationRole); + + // ApiGw-SQS Integration + const apiGwSqsIntegration = new apigw.AwsIntegration({ + service: 'sqs', + path: `${process.env.CDK_DEFAULT_ACCOUNT}/${this.customQueue.queueName}`, + integrationHttpMethod: 'POST', + options: { + credentialsRole: sqsIntegrationRole, + requestParameters: { + // https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-making-api-requests-json.html + 'integration.request.header.Content-Type': `'application/x-amz-json-1.0'`, + 'integration.request.header.X-Amz-Target': `'AmazonSQS.SendMessage'` + }, + passthroughBehavior: apigw.PassthroughBehavior.NEVER, + requestTemplates: { + 'application/json': props.vtlMappingTemplate, + }, + integrationResponses: [ + { + statusCode: '200', + }, + { + statusCode: '400', + }, + { + statusCode: '500', + } + ] + }, + }); + + + const sqs_resource = this.customApiGateway.root.addResource('sqs'); + sqs_resource.addMethod('POST', apiGwSqsIntegration, { + methodResponses: [ + { + statusCode: '400', + }, + { + statusCode: '200', + 'responseModels': { + 'application/json': apigw.Model.EMPTY_MODEL + } + }, + { + statusCode: '500', + } + ] + }); + } +} \ No newline at end of file diff --git a/apigw-sqs-msg-filtering-cdk/cdk/package.json b/apigw-sqs-msg-filtering-cdk/cdk/package.json new file mode 100644 index 000000000..f2ed393ef --- /dev/null +++ b/apigw-sqs-msg-filtering-cdk/cdk/package.json @@ -0,0 +1,26 @@ +{ + "name": "cdk", + "version": "0.1.0", + "bin": { + "cdk": "bin/cdk.js" + }, + "scripts": { + "build": "tsc", + "watch": "tsc -w", + "test": "jest", + "cdk": "cdk" + }, + "devDependencies": { + "@types/jest": "^29.5.14", + "@types/node": "22.7.9", + "jest": "^29.7.0", + "ts-jest": "^29.2.5", + "aws-cdk": "2.1021.0", + "ts-node": "^10.9.2", + "typescript": "~5.6.3" + }, + "dependencies": { + "aws-cdk-lib": "2.205.0", + "constructs": "^10.0.0" + } +} diff --git a/apigw-sqs-msg-filtering-cdk/cdk/test/cdk.test.ts b/apigw-sqs-msg-filtering-cdk/cdk/test/cdk.test.ts new file mode 100644 index 000000000..6aff52d02 --- /dev/null +++ b/apigw-sqs-msg-filtering-cdk/cdk/test/cdk.test.ts @@ -0,0 +1,14 @@ +import * as cdk from 'aws-cdk-lib'; +import { Template } from 'aws-cdk-lib/assertions'; +import { ApigwSqsMsgFilteringCdkStack } from '../lib/apigw-sqs-msg-filtering-cdk-stack'; + + +test('SQS Queue Created', () => { + const app = new cdk.App(); + const stack = new ApigwSqsMsgFilteringCdkStack(app, 'MyTestStack'); + + Template.fromStack(stack).hasResource("AWS::ApiGateway::Method", {}); + Template.fromStack(stack).hasResource("AWS::SQS::Queue", {}); +}); + + diff --git a/apigw-sqs-msg-filtering-cdk/cdk/tsconfig.json b/apigw-sqs-msg-filtering-cdk/cdk/tsconfig.json new file mode 100644 index 000000000..28bb557fa --- /dev/null +++ b/apigw-sqs-msg-filtering-cdk/cdk/tsconfig.json @@ -0,0 +1,31 @@ +{ + "compilerOptions": { + "target": "ES2022", + "module": "NodeNext", + "moduleResolution": "NodeNext", + "lib": [ + "es2022" + ], + "declaration": true, + "strict": true, + "noImplicitAny": true, + "strictNullChecks": true, + "noImplicitThis": true, + "alwaysStrict": true, + "noUnusedLocals": false, + "noUnusedParameters": false, + "noImplicitReturns": true, + "noFallthroughCasesInSwitch": false, + "inlineSourceMap": true, + "inlineSources": true, + "experimentalDecorators": true, + "strictPropertyInitialization": false, + "typeRoots": [ + "./node_modules/@types" + ] + }, + "exclude": [ + "node_modules", + "cdk.out" + ] +} diff --git a/apigw-sqs-msg-filtering-cdk/example-pattern.json b/apigw-sqs-msg-filtering-cdk/example-pattern.json new file mode 100644 index 000000000..75f78e369 --- /dev/null +++ b/apigw-sqs-msg-filtering-cdk/example-pattern.json @@ -0,0 +1,58 @@ +{ + "title": "Amazon API Gateway to Amazon SQS with message filtering", + "description": "Simple pattern that sends a messsage directly to an SQS queue via an API Gateway endpoint and uses the Velocity Template Language (VTL) to transform (e.g. fitler) the message body.", + "language": "Node.js", + "level": "200", + "framework": "AWS CDK", + "introBox": { + "headline": "How it works", + "text": [ + "This pattern will create an API Gateway Rest API, an SQS Queue and the correct VTL integration mapping template to filter out parts of the message body." + ] + }, + "gitHub": { + "template": { + "repoURL": "https://github.com/aws-samples/serverless-patterns/tree/main/apigw-sqs-msg-filtering-cdk", + "templateURL": "serverless-patterns/apigw-sqs-msg-filtering-cdk", + "projectFolder": "apigw-sqs-msg-filtering-cdk", + "templateFile": "lib/apigw-sqs-msg-filtering-cdk-stack.ts" + } + }, + "resources": { + "bullets": [ + { + "text": "Working with the AWS CDK in TypeScript", + "link": "https://docs.aws.amazon.com/cdk/v2/guide/work-with-cdk-typescript.html" + }, + { + "text": "Mapping template transformations for REST APIs in API Gateway", + "link": "https://docs.aws.amazon.com/apigateway/latest/developerguide/models-mappings.html" + }, + { + "text": "Reference guide for the Velocity Template Language (VTL)", + "link": "https://velocity.apache.org/engine/1.7/vtl-reference.html" + } + ] + }, + "deploy": { + "text": [ + "Deploy the stack: cdk deploy or npm run deploy" + ] + }, + "testing": { + "text": [ + "See the README in the GitHub repo for detailed testing instructions." + ] + }, + "cleanup": { + "text": ["Delete the stack: cdk delete."] + }, + "authors": [ + { + "name": "André Stoll", + "image": "https://user-images.githubusercontent.com/44157083/231747014-89cb4bc7-d977-45c8-be01-007831d346ad.jpeg", + "bio": "André is a Solutions Architect at Amazon Web Services based in Switzerland focusing on serverless architectures.", + "linkedin": "andre-stoll" + } + ] +} diff --git a/apigw-sqs-msg-filtering-cdk/test/test-payload.json b/apigw-sqs-msg-filtering-cdk/test/test-payload.json new file mode 100644 index 000000000..f9f0f7593 --- /dev/null +++ b/apigw-sqs-msg-filtering-cdk/test/test-payload.json @@ -0,0 +1,25 @@ +{ + "messageBody": { + "neededStringElement": "I am needed!", + "neededNumberElement": 1234, + "notNeededElement": { + "notNeededStringElement": "Not needed", + "notNeededNumberElement": 1234 + } + }, + "delaySeconds": 5, + "messageAttributes": { + "stringAttribute": { + "dataType": "String", + "stringValue": "Lorem Ipsum" + }, + "numberAttribute": { + "dataType": "Number", + "stringValue": "1234567890" + }, + "binaryAttribute": { + "dataType": "Binary", + "binaryValue": "SGVsbG8gV29ybGQ=" + } + } +}