diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-logs/test/integ.metricfilter.lit.js.snapshot/aws-cdk-metricfilter-integ.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-logs/test/integ.metricfilter.lit.js.snapshot/aws-cdk-metricfilter-integ.template.json index 32f6577f1b0f2..e50aca80cb811 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-logs/test/integ.metricfilter.lit.js.snapshot/aws-cdk-metricfilter-integ.template.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-logs/test/integ.metricfilter.lit.js.snapshot/aws-cdk-metricfilter-integ.template.json @@ -11,7 +11,7 @@ "MetricFilter1B93B6E5": { "Type": "AWS::Logs::MetricFilter", "Properties": { - "FilterPattern": "{ $.latency = \"*\" }", + "FilterPattern": "{ ($.latency = \"*\") && ($.message = %bind: address already in use%) }", "LogGroupName": { "Ref": "LogGroupF5B46931" }, diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-logs/test/integ.metricfilter.lit.ts b/packages/@aws-cdk-testing/framework-integ/test/aws-logs/test/integ.metricfilter.lit.ts index b06259887204d..92140291d2ce8 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-logs/test/integ.metricfilter.lit.ts +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-logs/test/integ.metricfilter.lit.ts @@ -15,7 +15,10 @@ class MetricFilterIntegStack extends Stack { metricNamespace: 'MyApp', metricName: 'Latency', filterName: 'MyFilterName', - filterPattern: FilterPattern.exists('$.latency'), + filterPattern: FilterPattern.all( + FilterPattern.exists('$.latency'), + FilterPattern.regexValue('$.message', '=', 'bind: address already in use'), + ), metricValue: '$.latency', }); /// !hide diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/apigateway/integ.call-rest-api-cross-region.js.snapshot/CallRestApiInteg-ApiStack.assets.json b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/apigateway/integ.call-rest-api-cross-region.js.snapshot/CallRestApiInteg-ApiStack.assets.json new file mode 100644 index 0000000000000..4f25b81df47c1 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/apigateway/integ.call-rest-api-cross-region.js.snapshot/CallRestApiInteg-ApiStack.assets.json @@ -0,0 +1,34 @@ +{ + "version": "39.0.0", + "files": { + "bbfb567dc956ce71e67ac1f96589821990e2ca48307b93a577bbb345d2de441b": { + "source": { + "path": "asset.bbfb567dc956ce71e67ac1f96589821990e2ca48307b93a577bbb345d2de441b", + "packaging": "zip" + }, + "destinations": { + "current_account-us-west-2": { + "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-us-west-2", + "objectKey": "bbfb567dc956ce71e67ac1f96589821990e2ca48307b93a577bbb345d2de441b.zip", + "region": "us-west-2", + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-us-west-2" + } + } + }, + "319feecbdd79b561ade2169ee0a835fdb91b5ecaecd5b259a64e78735ae73be0": { + "source": { + "path": "CallRestApiInteg-ApiStack.template.json", + "packaging": "file" + }, + "destinations": { + "current_account-us-west-2": { + "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-us-west-2", + "objectKey": "319feecbdd79b561ade2169ee0a835fdb91b5ecaecd5b259a64e78735ae73be0.json", + "region": "us-west-2", + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-us-west-2" + } + } + } + }, + "dockerImages": {} +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/apigateway/integ.call-rest-api-cross-region.js.snapshot/CallRestApiInteg-ApiStack.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/apigateway/integ.call-rest-api-cross-region.js.snapshot/CallRestApiInteg-ApiStack.template.json new file mode 100644 index 0000000000000..b9ae54a163119 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/apigateway/integ.call-rest-api-cross-region.js.snapshot/CallRestApiInteg-ApiStack.template.json @@ -0,0 +1,391 @@ +{ + "Resources": { + "MyRestApi2D1F47A9": { + "Type": "AWS::ApiGateway::RestApi", + "Properties": { + "Name": "MyRestApi" + } + }, + "MyRestApiCloudWatchRoleD4042E8E": { + "Type": "AWS::IAM::Role", + "Properties": { + "AssumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "apigateway.amazonaws.com" + } + } + ], + "Version": "2012-10-17" + }, + "ManagedPolicyArns": [ + { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":iam::aws:policy/service-role/AmazonAPIGatewayPushToCloudWatchLogs" + ] + ] + } + ] + }, + "UpdateReplacePolicy": "Retain", + "DeletionPolicy": "Retain" + }, + "MyRestApiAccount2FB6DB7A": { + "Type": "AWS::ApiGateway::Account", + "Properties": { + "CloudWatchRoleArn": { + "Fn::GetAtt": [ + "MyRestApiCloudWatchRoleD4042E8E", + "Arn" + ] + } + }, + "DependsOn": [ + "MyRestApi2D1F47A9" + ], + "UpdateReplacePolicy": "Retain", + "DeletionPolicy": "Retain" + }, + "MyRestApiDeploymentB555B5824a2dace0b77d6e14d0cc32d4d28422f3": { + "Type": "AWS::ApiGateway::Deployment", + "Properties": { + "Description": "Automatically created by the RestApi construct", + "RestApiId": { + "Ref": "MyRestApi2D1F47A9" + } + }, + "DependsOn": [ + "MyRestApiANY05143F93" + ] + }, + "MyRestApiDeploymentStageprodC33B8E5F": { + "Type": "AWS::ApiGateway::Stage", + "Properties": { + "DeploymentId": { + "Ref": "MyRestApiDeploymentB555B5824a2dace0b77d6e14d0cc32d4d28422f3" + }, + "RestApiId": { + "Ref": "MyRestApi2D1F47A9" + }, + "StageName": "prod" + }, + "DependsOn": [ + "MyRestApiAccount2FB6DB7A" + ] + }, + "MyRestApiANYApiPermissionCallRestApiIntegApiStackMyRestApiC2593C7AANY7E91F016": { + "Type": "AWS::Lambda::Permission", + "Properties": { + "Action": "lambda:InvokeFunction", + "FunctionName": { + "Fn::GetAtt": [ + "Hello4A628BD4", + "Arn" + ] + }, + "Principal": "apigateway.amazonaws.com", + "SourceArn": { + "Fn::Join": [ + "", + [ + "arn:aws:execute-api:us-west-2:", + { + "Ref": "AWS::AccountId" + }, + ":", + { + "Ref": "MyRestApi2D1F47A9" + }, + "/", + { + "Ref": "MyRestApiDeploymentStageprodC33B8E5F" + }, + "/*/" + ] + ] + } + } + }, + "MyRestApiANYApiPermissionTestCallRestApiIntegApiStackMyRestApiC2593C7AANY4B5F396C": { + "Type": "AWS::Lambda::Permission", + "Properties": { + "Action": "lambda:InvokeFunction", + "FunctionName": { + "Fn::GetAtt": [ + "Hello4A628BD4", + "Arn" + ] + }, + "Principal": "apigateway.amazonaws.com", + "SourceArn": { + "Fn::Join": [ + "", + [ + "arn:aws:execute-api:us-west-2:", + { + "Ref": "AWS::AccountId" + }, + ":", + { + "Ref": "MyRestApi2D1F47A9" + }, + "/test-invoke-stage/*/" + ] + ] + } + } + }, + "MyRestApiANY05143F93": { + "Type": "AWS::ApiGateway::Method", + "Properties": { + "AuthorizationType": "NONE", + "HttpMethod": "ANY", + "Integration": { + "IntegrationHttpMethod": "POST", + "Type": "AWS_PROXY", + "Uri": { + "Fn::Join": [ + "", + [ + "arn:aws:apigateway:us-west-2:lambda:path/2015-03-31/functions/", + { + "Fn::GetAtt": [ + "Hello4A628BD4", + "Arn" + ] + }, + "/invocations" + ] + ] + } + }, + "ResourceId": { + "Fn::GetAtt": [ + "MyRestApi2D1F47A9", + "RootResourceId" + ] + }, + "RestApiId": { + "Ref": "MyRestApi2D1F47A9" + } + } + }, + "HelloServiceRole1E55EA16": { + "Type": "AWS::IAM::Role", + "Properties": { + "AssumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "lambda.amazonaws.com" + } + } + ], + "Version": "2012-10-17" + }, + "ManagedPolicyArns": [ + { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" + ] + ] + } + ] + } + }, + "Hello4A628BD4": { + "Type": "AWS::Lambda::Function", + "Properties": { + "Code": { + "ZipFile": "exports.handler = async function(event, context) { return { statusCode: 200, body: \"hello, world!\" }; };" + }, + "Handler": "index.handler", + "Role": { + "Fn::GetAtt": [ + "HelloServiceRole1E55EA16", + "Arn" + ] + }, + "Runtime": "nodejs18.x" + }, + "DependsOn": [ + "HelloServiceRole1E55EA16" + ] + }, + "ExportsWriteruseast10F67B507DDE2E818": { + "Type": "Custom::CrossRegionExportWriter", + "Properties": { + "ServiceToken": { + "Fn::GetAtt": [ + "CustomCrossRegionExportWriterCustomResourceProviderHandlerD8786E8A", + "Arn" + ] + }, + "WriterProps": { + "region": "us-east-1", + "exports": { + "/cdk/exports/CallRestApiInteg-SfnStack/CallRestApiIntegApiStackuswest2RefMyRestApi2D1F47A94BF96318": { + "Ref": "MyRestApi2D1F47A9" + } + } + } + }, + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" + }, + "CustomCrossRegionExportWriterCustomResourceProviderRoleC951B1E1": { + "Type": "AWS::IAM::Role", + "Properties": { + "AssumeRolePolicyDocument": { + "Version": "2012-10-17", + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "lambda.amazonaws.com" + } + } + ] + }, + "ManagedPolicyArns": [ + { + "Fn::Sub": "arn:${AWS::Partition}:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" + } + ], + "Policies": [ + { + "PolicyName": "Inline", + "PolicyDocument": { + "Version": "2012-10-17", + "Statement": [ + { + "Effect": "Allow", + "Resource": [ + { + "Fn::Join": [ + "", + [ + "arn:aws:ssm:us-east-1:", + { + "Ref": "AWS::AccountId" + }, + ":parameter/cdk/exports/*" + ] + ] + } + ], + "Action": [ + "ssm:DeleteParameters", + "ssm:ListTagsForResource", + "ssm:GetParameters", + "ssm:PutParameter" + ] + } + ] + } + } + ] + } + }, + "CustomCrossRegionExportWriterCustomResourceProviderHandlerD8786E8A": { + "Type": "AWS::Lambda::Function", + "Properties": { + "Code": { + "S3Bucket": { + "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-us-west-2" + }, + "S3Key": "bbfb567dc956ce71e67ac1f96589821990e2ca48307b93a577bbb345d2de441b.zip" + }, + "Timeout": 900, + "MemorySize": 128, + "Handler": "__entrypoint__.handler", + "Role": { + "Fn::GetAtt": [ + "CustomCrossRegionExportWriterCustomResourceProviderRoleC951B1E1", + "Arn" + ] + }, + "Runtime": "nodejs20.x" + }, + "DependsOn": [ + "CustomCrossRegionExportWriterCustomResourceProviderRoleC951B1E1" + ] + } + }, + "Outputs": { + "MyRestApiEndpoint4C55E4CB": { + "Value": { + "Fn::Join": [ + "", + [ + "https://", + { + "Ref": "MyRestApi2D1F47A9" + }, + ".execute-api.us-west-2.", + { + "Ref": "AWS::URLSuffix" + }, + "/", + { + "Ref": "MyRestApiDeploymentStageprodC33B8E5F" + }, + "/" + ] + ] + } + } + }, + "Parameters": { + "BootstrapVersion": { + "Type": "AWS::SSM::Parameter::Value", + "Default": "/cdk-bootstrap/hnb659fds/version", + "Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]" + } + }, + "Rules": { + "CheckBootstrapVersion": { + "Assertions": [ + { + "Assert": { + "Fn::Not": [ + { + "Fn::Contains": [ + [ + "1", + "2", + "3", + "4", + "5" + ], + { + "Ref": "BootstrapVersion" + } + ] + } + ] + }, + "AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI." + } + ] + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/apigateway/integ.call-rest-api-cross-region.js.snapshot/CallRestApiInteg-SfnStack.assets.json b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/apigateway/integ.call-rest-api-cross-region.js.snapshot/CallRestApiInteg-SfnStack.assets.json new file mode 100644 index 0000000000000..614c3b019259d --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/apigateway/integ.call-rest-api-cross-region.js.snapshot/CallRestApiInteg-SfnStack.assets.json @@ -0,0 +1,34 @@ +{ + "version": "39.0.0", + "files": { + "d6fa38886a871b64de769ec5016af90a071e6429aa8e7de84f595e4e2462e17d": { + "source": { + "path": "asset.d6fa38886a871b64de769ec5016af90a071e6429aa8e7de84f595e4e2462e17d", + "packaging": "zip" + }, + "destinations": { + "current_account-us-east-1": { + "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-us-east-1", + "objectKey": "d6fa38886a871b64de769ec5016af90a071e6429aa8e7de84f595e4e2462e17d.zip", + "region": "us-east-1", + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-us-east-1" + } + } + }, + "4b53f3b1f75f7c2c40971f3e37d5448f36e7b39949926864276994f8ec2e0d6d": { + "source": { + "path": "CallRestApiInteg-SfnStack.template.json", + "packaging": "file" + }, + "destinations": { + "current_account-us-east-1": { + "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-us-east-1", + "objectKey": "4b53f3b1f75f7c2c40971f3e37d5448f36e7b39949926864276994f8ec2e0d6d.json", + "region": "us-east-1", + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-us-east-1" + } + } + } + }, + "dockerImages": {} +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/apigateway/integ.call-rest-api-cross-region.js.snapshot/CallRestApiInteg-SfnStack.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/apigateway/integ.call-rest-api-cross-region.js.snapshot/CallRestApiInteg-SfnStack.template.json new file mode 100644 index 0000000000000..57a098d1d924d --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/apigateway/integ.call-rest-api-cross-region.js.snapshot/CallRestApiInteg-SfnStack.template.json @@ -0,0 +1,237 @@ +{ + "Resources": { + "StateMachineRoleB840431D": { + "Type": "AWS::IAM::Role", + "Properties": { + "AssumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "states.amazonaws.com" + } + } + ], + "Version": "2012-10-17" + } + } + }, + "StateMachineRoleDefaultPolicyDF1E6607": { + "Type": "AWS::IAM::Policy", + "Properties": { + "PolicyDocument": { + "Statement": [ + { + "Action": "execute-api:Invoke", + "Effect": "Allow", + "Resource": { + "Fn::Join": [ + "", + [ + "arn:aws:execute-api:us-east-1:", + { + "Ref": "AWS::AccountId" + }, + ":", + { + "Fn::GetAtt": [ + "ExportsReader8B249524", + "/cdk/exports/CallRestApiInteg-SfnStack/CallRestApiIntegApiStackuswest2RefMyRestApi2D1F47A94BF96318" + ] + }, + "/prod/GET/*" + ] + ] + } + } + ], + "Version": "2012-10-17" + }, + "PolicyName": "StateMachineRoleDefaultPolicyDF1E6607", + "Roles": [ + { + "Ref": "StateMachineRoleB840431D" + } + ] + } + }, + "StateMachine2E01A3A5": { + "Type": "AWS::StepFunctions::StateMachine", + "Properties": { + "DefinitionString": { + "Fn::Join": [ + "", + [ + "{\"StartAt\":\"Call APIGW\",\"States\":{\"Call APIGW\":{\"End\":true,\"Type\":\"Task\",\"OutputPath\":\"$.ResponseBody\",\"Resource\":\"arn:", + { + "Ref": "AWS::Partition" + }, + ":states:::apigateway:invoke\",\"Parameters\":{\"ApiEndpoint\":\"", + { + "Fn::GetAtt": [ + "ExportsReader8B249524", + "/cdk/exports/CallRestApiInteg-SfnStack/CallRestApiIntegApiStackuswest2RefMyRestApi2D1F47A94BF96318" + ] + }, + ".execute-api.us-west-2.", + { + "Ref": "AWS::URLSuffix" + }, + "\",\"Method\":\"GET\",\"Stage\":\"prod\",\"AuthType\":\"IAM_ROLE\"}}},\"TimeoutSeconds\":30}" + ] + ] + }, + "RoleArn": { + "Fn::GetAtt": [ + "StateMachineRoleB840431D", + "Arn" + ] + } + }, + "DependsOn": [ + "StateMachineRoleDefaultPolicyDF1E6607", + "StateMachineRoleB840431D" + ], + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" + }, + "ExportsReader8B249524": { + "Type": "Custom::CrossRegionExportReader", + "Properties": { + "ServiceToken": { + "Fn::GetAtt": [ + "CustomCrossRegionExportReaderCustomResourceProviderHandler46647B68", + "Arn" + ] + }, + "ReaderProps": { + "region": "us-east-1", + "prefix": "CallRestApiInteg-SfnStack", + "imports": { + "/cdk/exports/CallRestApiInteg-SfnStack/CallRestApiIntegApiStackuswest2RefMyRestApi2D1F47A94BF96318": "{{resolve:ssm:/cdk/exports/CallRestApiInteg-SfnStack/CallRestApiIntegApiStackuswest2RefMyRestApi2D1F47A94BF96318}}" + } + } + }, + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" + }, + "CustomCrossRegionExportReaderCustomResourceProviderRole10531BBD": { + "Type": "AWS::IAM::Role", + "Properties": { + "AssumeRolePolicyDocument": { + "Version": "2012-10-17", + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "lambda.amazonaws.com" + } + } + ] + }, + "ManagedPolicyArns": [ + { + "Fn::Sub": "arn:${AWS::Partition}:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" + } + ], + "Policies": [ + { + "PolicyName": "Inline", + "PolicyDocument": { + "Version": "2012-10-17", + "Statement": [ + { + "Effect": "Allow", + "Resource": { + "Fn::Join": [ + "", + [ + "arn:aws:ssm:us-east-1:", + { + "Ref": "AWS::AccountId" + }, + ":parameter/cdk/exports/CallRestApiInteg-SfnStack/*" + ] + ] + }, + "Action": [ + "ssm:AddTagsToResource", + "ssm:RemoveTagsFromResource", + "ssm:GetParameters" + ] + } + ] + } + } + ] + } + }, + "CustomCrossRegionExportReaderCustomResourceProviderHandler46647B68": { + "Type": "AWS::Lambda::Function", + "Properties": { + "Code": { + "S3Bucket": { + "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-us-east-1" + }, + "S3Key": "d6fa38886a871b64de769ec5016af90a071e6429aa8e7de84f595e4e2462e17d.zip" + }, + "Timeout": 900, + "MemorySize": 128, + "Handler": "__entrypoint__.handler", + "Role": { + "Fn::GetAtt": [ + "CustomCrossRegionExportReaderCustomResourceProviderRole10531BBD", + "Arn" + ] + }, + "Runtime": "nodejs20.x" + }, + "DependsOn": [ + "CustomCrossRegionExportReaderCustomResourceProviderRole10531BBD" + ] + } + }, + "Outputs": { + "stateMachineArn": { + "Value": { + "Ref": "StateMachine2E01A3A5" + } + } + }, + "Parameters": { + "BootstrapVersion": { + "Type": "AWS::SSM::Parameter::Value", + "Default": "/cdk-bootstrap/hnb659fds/version", + "Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]" + } + }, + "Rules": { + "CheckBootstrapVersion": { + "Assertions": [ + { + "Assert": { + "Fn::Not": [ + { + "Fn::Contains": [ + [ + "1", + "2", + "3", + "4", + "5" + ], + { + "Ref": "BootstrapVersion" + } + ] + } + ] + }, + "AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI." + } + ] + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/apigateway/integ.call-rest-api-cross-region.js.snapshot/asset.bbfb567dc956ce71e67ac1f96589821990e2ca48307b93a577bbb345d2de441b/__entrypoint__.js b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/apigateway/integ.call-rest-api-cross-region.js.snapshot/asset.bbfb567dc956ce71e67ac1f96589821990e2ca48307b93a577bbb345d2de441b/__entrypoint__.js new file mode 100644 index 0000000000000..ff3a517fba12d --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/apigateway/integ.call-rest-api-cross-region.js.snapshot/asset.bbfb567dc956ce71e67ac1f96589821990e2ca48307b93a577bbb345d2de441b/__entrypoint__.js @@ -0,0 +1,155 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.external = void 0; +exports.handler = handler; +exports.withRetries = withRetries; +const https = require("https"); +const url = require("url"); +// for unit tests +exports.external = { + sendHttpRequest: defaultSendHttpRequest, + log: defaultLog, + includeStackTraces: true, + userHandlerIndex: './index', +}; +const CREATE_FAILED_PHYSICAL_ID_MARKER = 'AWSCDK::CustomResourceProviderFramework::CREATE_FAILED'; +const MISSING_PHYSICAL_ID_MARKER = 'AWSCDK::CustomResourceProviderFramework::MISSING_PHYSICAL_ID'; +async function handler(event, context) { + const sanitizedEvent = { ...event, ResponseURL: '...' }; + exports.external.log(JSON.stringify(sanitizedEvent, undefined, 2)); + // ignore DELETE event when the physical resource ID is the marker that + // indicates that this DELETE is a subsequent DELETE to a failed CREATE + // operation. + if (event.RequestType === 'Delete' && event.PhysicalResourceId === CREATE_FAILED_PHYSICAL_ID_MARKER) { + exports.external.log('ignoring DELETE event caused by a failed CREATE event'); + await submitResponse('SUCCESS', event); + return; + } + try { + // invoke the user handler. this is intentionally inside the try-catch to + // ensure that if there is an error it's reported as a failure to + // cloudformation (otherwise cfn waits). + // eslint-disable-next-line @typescript-eslint/no-require-imports + const userHandler = require(exports.external.userHandlerIndex).handler; + const result = await userHandler(sanitizedEvent, context); + // validate user response and create the combined event + const responseEvent = renderResponse(event, result); + // submit to cfn as success + await submitResponse('SUCCESS', responseEvent); + } + catch (e) { + const resp = { + ...event, + Reason: exports.external.includeStackTraces ? e.stack : e.message, + }; + if (!resp.PhysicalResourceId) { + // special case: if CREATE fails, which usually implies, we usually don't + // have a physical resource id. in this case, the subsequent DELETE + // operation does not have any meaning, and will likely fail as well. to + // address this, we use a marker so the provider framework can simply + // ignore the subsequent DELETE. + if (event.RequestType === 'Create') { + exports.external.log('CREATE failed, responding with a marker physical resource id so that the subsequent DELETE will be ignored'); + resp.PhysicalResourceId = CREATE_FAILED_PHYSICAL_ID_MARKER; + } + else { + // otherwise, if PhysicalResourceId is not specified, something is + // terribly wrong because all other events should have an ID. + exports.external.log(`ERROR: Malformed event. "PhysicalResourceId" is required: ${JSON.stringify(event)}`); + } + } + // this is an actual error, fail the activity altogether and exist. + await submitResponse('FAILED', resp); + } +} +function renderResponse(cfnRequest, handlerResponse = {}) { + // if physical ID is not returned, we have some defaults for you based + // on the request type. + const physicalResourceId = handlerResponse.PhysicalResourceId ?? cfnRequest.PhysicalResourceId ?? cfnRequest.RequestId; + // if we are in DELETE and physical ID was changed, it's an error. + if (cfnRequest.RequestType === 'Delete' && physicalResourceId !== cfnRequest.PhysicalResourceId) { + throw new Error(`DELETE: cannot change the physical resource ID from "${cfnRequest.PhysicalResourceId}" to "${handlerResponse.PhysicalResourceId}" during deletion`); + } + // merge request event and result event (result prevails). + return { + ...cfnRequest, + ...handlerResponse, + PhysicalResourceId: physicalResourceId, + }; +} +async function submitResponse(status, event) { + const json = { + Status: status, + Reason: event.Reason ?? status, + StackId: event.StackId, + RequestId: event.RequestId, + PhysicalResourceId: event.PhysicalResourceId || MISSING_PHYSICAL_ID_MARKER, + LogicalResourceId: event.LogicalResourceId, + NoEcho: event.NoEcho, + Data: event.Data, + }; + const parsedUrl = url.parse(event.ResponseURL); + const loggingSafeUrl = `${parsedUrl.protocol}//${parsedUrl.hostname}/${parsedUrl.pathname}?***`; + exports.external.log('submit response to cloudformation', loggingSafeUrl, json); + const responseBody = JSON.stringify(json); + const req = { + hostname: parsedUrl.hostname, + path: parsedUrl.path, + method: 'PUT', + headers: { + 'content-type': '', + 'content-length': Buffer.byteLength(responseBody, 'utf8'), + }, + }; + const retryOptions = { + attempts: 5, + sleep: 1000, + }; + await withRetries(retryOptions, exports.external.sendHttpRequest)(req, responseBody); +} +async function defaultSendHttpRequest(options, requestBody) { + return new Promise((resolve, reject) => { + try { + const request = https.request(options, (response) => { + response.resume(); // Consume the response but don't care about it + if (!response.statusCode || response.statusCode >= 400) { + reject(new Error(`Unsuccessful HTTP response: ${response.statusCode}`)); + } + else { + resolve(); + } + }); + request.on('error', reject); + request.write(requestBody); + request.end(); + } + catch (e) { + reject(e); + } + }); +} +function defaultLog(fmt, ...params) { + // eslint-disable-next-line no-console + console.log(fmt, ...params); +} +function withRetries(options, fn) { + return async (...xs) => { + let attempts = options.attempts; + let ms = options.sleep; + while (true) { + try { + return await fn(...xs); + } + catch (e) { + if (attempts-- <= 0) { + throw e; + } + await sleep(Math.floor(Math.random() * ms)); + ms *= 2; + } + } + }; +} +async function sleep(ms) { + return new Promise((ok) => setTimeout(ok, ms)); +} diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/apigateway/integ.call-rest-api-cross-region.js.snapshot/asset.bbfb567dc956ce71e67ac1f96589821990e2ca48307b93a577bbb345d2de441b/index.js b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/apigateway/integ.call-rest-api-cross-region.js.snapshot/asset.bbfb567dc956ce71e67ac1f96589821990e2ca48307b93a577bbb345d2de441b/index.js new file mode 100644 index 0000000000000..3adfdc90f2d53 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/apigateway/integ.call-rest-api-cross-region.js.snapshot/asset.bbfb567dc956ce71e67ac1f96589821990e2ca48307b93a577bbb345d2de441b/index.js @@ -0,0 +1,5 @@ +"use strict";var a=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var S=Object.prototype.hasOwnProperty;var E=(s,t)=>{for(var r in t)a(s,r,{get:t[r],enumerable:!0})},R=(s,t,r,e)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of f(t))!S.call(s,o)&&o!==r&&a(s,o,{get:()=>t[o],enumerable:!(e=d(t,o))||e.enumerable});return s};var y=s=>R(a({},"__esModule",{value:!0}),s);var O={};E(O,{handler:()=>h});module.exports=y(O);var l=require("@aws-sdk/client-ssm");async function h(s){let t=s.ResourceProperties.WriterProps,r=t.exports,e=new l.SSM({region:t.region});try{switch(s.RequestType){case"Create":console.info(`Creating new SSM Parameter exports in region ${t.region}`),await i(e,r),await u(e,r);return;case"Update":let n=s.OldResourceProperties.WriterProps.exports,c=x(r,n),p=C(n,r);if(p.length>0)throw new Error(`Some exports have changed! +`+p.join(` +`));let g=x(n,r);await i(e,g);let w=Object.keys(g);await m(e,w),await i(e,c),console.info(`Creating new SSM Parameter exports in region ${t.region}`),await u(e,c);return;case"Delete":await i(e,r),await m(e,Object.keys(r));return;default:return}}catch(o){throw console.error("Error processing event: ",o),o}}async function u(s,t){await Promise.all(Array.from(Object.entries(t),([r,e])=>s.putParameter({Name:r,Value:e,Type:"String"})))}async function m(s,t){t.sort();for(let e=0;e0&&await s.deleteParameters({Names:o})}}async function i(s,t){let r=new Map;if(await Promise.all(Object.keys(t).map(async e=>{let o=await P(s,e);o.size>0&&r.set(e,o)})),r.size>0){let e=Array.from(r.entries()).map(o=>`${o[0]} is in use by stack(s) ${Array.from(o[1]).join(" ")}`).join(` +`);throw new Error(`Exports cannot be updated: +${e}`)}}async function P(s,t){let r=new Set;try{(await s.listTagsForResource({ResourceId:t,ResourceType:"Parameter"})).TagList?.forEach(o=>{let n=o.Key?.split(":")??[];n[0]==="aws-cdk"&&n[1]==="strong-ref"&&r.add(n[2])})}catch(e){if(e.name==="InvalidResourceId")return new Set;throw e}return r}function x(s,t){return Object.keys(s).filter(r=>!t.hasOwnProperty(r)).reduce((r,e)=>(r[e]=s[e],r),{})}function C(s,t){return Object.keys(s).filter(r=>t.hasOwnProperty(r)&&s[r]!==t[r]).reduce((r,e)=>(r.push(e),r),[])}0&&(module.exports={handler}); diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/apigateway/integ.call-rest-api-cross-region.js.snapshot/asset.d6fa38886a871b64de769ec5016af90a071e6429aa8e7de84f595e4e2462e17d/__entrypoint__.js b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/apigateway/integ.call-rest-api-cross-region.js.snapshot/asset.d6fa38886a871b64de769ec5016af90a071e6429aa8e7de84f595e4e2462e17d/__entrypoint__.js new file mode 100644 index 0000000000000..ff3a517fba12d --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/apigateway/integ.call-rest-api-cross-region.js.snapshot/asset.d6fa38886a871b64de769ec5016af90a071e6429aa8e7de84f595e4e2462e17d/__entrypoint__.js @@ -0,0 +1,155 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.external = void 0; +exports.handler = handler; +exports.withRetries = withRetries; +const https = require("https"); +const url = require("url"); +// for unit tests +exports.external = { + sendHttpRequest: defaultSendHttpRequest, + log: defaultLog, + includeStackTraces: true, + userHandlerIndex: './index', +}; +const CREATE_FAILED_PHYSICAL_ID_MARKER = 'AWSCDK::CustomResourceProviderFramework::CREATE_FAILED'; +const MISSING_PHYSICAL_ID_MARKER = 'AWSCDK::CustomResourceProviderFramework::MISSING_PHYSICAL_ID'; +async function handler(event, context) { + const sanitizedEvent = { ...event, ResponseURL: '...' }; + exports.external.log(JSON.stringify(sanitizedEvent, undefined, 2)); + // ignore DELETE event when the physical resource ID is the marker that + // indicates that this DELETE is a subsequent DELETE to a failed CREATE + // operation. + if (event.RequestType === 'Delete' && event.PhysicalResourceId === CREATE_FAILED_PHYSICAL_ID_MARKER) { + exports.external.log('ignoring DELETE event caused by a failed CREATE event'); + await submitResponse('SUCCESS', event); + return; + } + try { + // invoke the user handler. this is intentionally inside the try-catch to + // ensure that if there is an error it's reported as a failure to + // cloudformation (otherwise cfn waits). + // eslint-disable-next-line @typescript-eslint/no-require-imports + const userHandler = require(exports.external.userHandlerIndex).handler; + const result = await userHandler(sanitizedEvent, context); + // validate user response and create the combined event + const responseEvent = renderResponse(event, result); + // submit to cfn as success + await submitResponse('SUCCESS', responseEvent); + } + catch (e) { + const resp = { + ...event, + Reason: exports.external.includeStackTraces ? e.stack : e.message, + }; + if (!resp.PhysicalResourceId) { + // special case: if CREATE fails, which usually implies, we usually don't + // have a physical resource id. in this case, the subsequent DELETE + // operation does not have any meaning, and will likely fail as well. to + // address this, we use a marker so the provider framework can simply + // ignore the subsequent DELETE. + if (event.RequestType === 'Create') { + exports.external.log('CREATE failed, responding with a marker physical resource id so that the subsequent DELETE will be ignored'); + resp.PhysicalResourceId = CREATE_FAILED_PHYSICAL_ID_MARKER; + } + else { + // otherwise, if PhysicalResourceId is not specified, something is + // terribly wrong because all other events should have an ID. + exports.external.log(`ERROR: Malformed event. "PhysicalResourceId" is required: ${JSON.stringify(event)}`); + } + } + // this is an actual error, fail the activity altogether and exist. + await submitResponse('FAILED', resp); + } +} +function renderResponse(cfnRequest, handlerResponse = {}) { + // if physical ID is not returned, we have some defaults for you based + // on the request type. + const physicalResourceId = handlerResponse.PhysicalResourceId ?? cfnRequest.PhysicalResourceId ?? cfnRequest.RequestId; + // if we are in DELETE and physical ID was changed, it's an error. + if (cfnRequest.RequestType === 'Delete' && physicalResourceId !== cfnRequest.PhysicalResourceId) { + throw new Error(`DELETE: cannot change the physical resource ID from "${cfnRequest.PhysicalResourceId}" to "${handlerResponse.PhysicalResourceId}" during deletion`); + } + // merge request event and result event (result prevails). + return { + ...cfnRequest, + ...handlerResponse, + PhysicalResourceId: physicalResourceId, + }; +} +async function submitResponse(status, event) { + const json = { + Status: status, + Reason: event.Reason ?? status, + StackId: event.StackId, + RequestId: event.RequestId, + PhysicalResourceId: event.PhysicalResourceId || MISSING_PHYSICAL_ID_MARKER, + LogicalResourceId: event.LogicalResourceId, + NoEcho: event.NoEcho, + Data: event.Data, + }; + const parsedUrl = url.parse(event.ResponseURL); + const loggingSafeUrl = `${parsedUrl.protocol}//${parsedUrl.hostname}/${parsedUrl.pathname}?***`; + exports.external.log('submit response to cloudformation', loggingSafeUrl, json); + const responseBody = JSON.stringify(json); + const req = { + hostname: parsedUrl.hostname, + path: parsedUrl.path, + method: 'PUT', + headers: { + 'content-type': '', + 'content-length': Buffer.byteLength(responseBody, 'utf8'), + }, + }; + const retryOptions = { + attempts: 5, + sleep: 1000, + }; + await withRetries(retryOptions, exports.external.sendHttpRequest)(req, responseBody); +} +async function defaultSendHttpRequest(options, requestBody) { + return new Promise((resolve, reject) => { + try { + const request = https.request(options, (response) => { + response.resume(); // Consume the response but don't care about it + if (!response.statusCode || response.statusCode >= 400) { + reject(new Error(`Unsuccessful HTTP response: ${response.statusCode}`)); + } + else { + resolve(); + } + }); + request.on('error', reject); + request.write(requestBody); + request.end(); + } + catch (e) { + reject(e); + } + }); +} +function defaultLog(fmt, ...params) { + // eslint-disable-next-line no-console + console.log(fmt, ...params); +} +function withRetries(options, fn) { + return async (...xs) => { + let attempts = options.attempts; + let ms = options.sleep; + while (true) { + try { + return await fn(...xs); + } + catch (e) { + if (attempts-- <= 0) { + throw e; + } + await sleep(Math.floor(Math.random() * ms)); + ms *= 2; + } + } + }; +} +async function sleep(ms) { + return new Promise((ok) => setTimeout(ok, ms)); +} diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/apigateway/integ.call-rest-api-cross-region.js.snapshot/asset.d6fa38886a871b64de769ec5016af90a071e6429aa8e7de84f595e4e2462e17d/index.js b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/apigateway/integ.call-rest-api-cross-region.js.snapshot/asset.d6fa38886a871b64de769ec5016af90a071e6429aa8e7de84f595e4e2462e17d/index.js new file mode 100644 index 0000000000000..4df534fc1cecc --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/apigateway/integ.call-rest-api-cross-region.js.snapshot/asset.d6fa38886a871b64de769ec5016af90a071e6429aa8e7de84f595e4e2462e17d/index.js @@ -0,0 +1 @@ +"use strict";var p=Object.defineProperty;var _=Object.getOwnPropertyDescriptor;var b=Object.getOwnPropertyNames;var C=Object.prototype.hasOwnProperty;var g=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),T=(r,e)=>{for(var t in e)p(r,t,{get:e[t],enumerable:!0})},v=(r,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of b(e))!C.call(r,s)&&s!==t&&p(r,s,{get:()=>e[s],enumerable:!(o=_(e,s))||o.enumerable});return r};var q=r=>v(p({},"__esModule",{value:!0}),r);var f=g((j,h)=>{"use strict";var l=class{constructor(e){this.value=e,this.next=void 0}},d=class{constructor(){this.clear()}enqueue(e){let t=new l(e);this._head?(this._tail.next=t,this._tail=t):(this._head=t,this._tail=t),this._size++}dequeue(){let e=this._head;if(e)return this._head=this._head.next,this._size--,e.value}clear(){this._head=void 0,this._tail=void 0,this._size=0}get size(){return this._size}*[Symbol.iterator](){let e=this._head;for(;e;)yield e.value,e=e.next}};h.exports=d});var R=g(($,y)=>{"use strict";var k=f(),z=r=>{if(!((Number.isInteger(r)||r===1/0)&&r>0))throw new TypeError("Expected `concurrency` to be a number from 1 and up");let e=new k,t=0,o=()=>{t--,e.size>0&&e.dequeue()()},s=async(n,c,...a)=>{t++;let m=(async()=>n(...a))();c(m);try{await m}catch{}o()},i=(n,c,...a)=>{e.enqueue(s.bind(null,n,c,...a)),(async()=>(await Promise.resolve(),t0&&e.dequeue()()))()},u=(n,...c)=>new Promise(a=>{i(n,a,...c)});return Object.defineProperties(u,{activeCount:{get:()=>t},pendingCount:{get:()=>e.size},clearQueue:{value:()=>{e.clear()}}}),u};y.exports=z});var I={};T(I,{handler:()=>M});module.exports=q(I);var E=require("@aws-sdk/client-ssm"),S=R();async function M(r){let e=r.ResourceProperties.ReaderProps,t=e.imports,o=Object.keys(t),s=`aws-cdk:strong-ref:${e.prefix}`,i=new E.SSM({region:e.region});try{switch(r.RequestType){case"Create":console.info("Tagging SSM Parameter imports"),await w(i,o,s);break;case"Update":let n=r.OldResourceProperties.ReaderProps.imports,c=P(o,Object.keys(n)),a=P(Object.keys(n),o);console.info("Releasing unused SSM Parameter imports"),Object.keys(a).length>0&&await x(i,a,s),console.info("Tagging new SSM Parameter imports"),await w(i,c,s);break;case"Delete":console.info("Releasing all SSM Parameter exports by removing tags"),await x(i,o,s);return}}catch(u){throw console.error("Error importing cross region stack exports: ",u),u}return{Data:t}}async function w(r,e,t){let o=S(10);await Promise.all(e.map(s=>o(async()=>{try{return await r.addTagsToResource({ResourceId:s,ResourceType:"Parameter",Tags:[{Key:t,Value:"true"}]})}catch(i){throw new Error(`Error importing ${s}: ${i}`)}})))}async function x(r,e,t){let o=S(10);await Promise.all(e.map(s=>o(async()=>{try{return await r.removeTagsFromResource({TagKeys:[t],ResourceType:"Parameter",ResourceId:s})}catch(i){if(i.name==="InvalidResourceId")return;throw new Error(`Error releasing import ${s}: ${i}`)}})))}function P(r,e){return r.filter(t=>!e.includes(t))}0&&(module.exports={handler}); diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/apigateway/integ.call-rest-api-cross-region.js.snapshot/callrestapicrossregionDefaultTestDeployAssert2A1021D3.assets.json b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/apigateway/integ.call-rest-api-cross-region.js.snapshot/callrestapicrossregionDefaultTestDeployAssert2A1021D3.assets.json new file mode 100644 index 0000000000000..10220f226185b --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/apigateway/integ.call-rest-api-cross-region.js.snapshot/callrestapicrossregionDefaultTestDeployAssert2A1021D3.assets.json @@ -0,0 +1,19 @@ +{ + "version": "39.0.0", + "files": { + "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": { + "source": { + "path": "callrestapicrossregionDefaultTestDeployAssert2A1021D3.template.json", + "packaging": "file" + }, + "destinations": { + "current_account-current_region": { + "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", + "objectKey": "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22.json", + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" + } + } + } + }, + "dockerImages": {} +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/apigateway/integ.call-rest-api-cross-region.js.snapshot/callrestapicrossregionDefaultTestDeployAssert2A1021D3.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/apigateway/integ.call-rest-api-cross-region.js.snapshot/callrestapicrossregionDefaultTestDeployAssert2A1021D3.template.json new file mode 100644 index 0000000000000..ad9d0fb73d1dd --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/apigateway/integ.call-rest-api-cross-region.js.snapshot/callrestapicrossregionDefaultTestDeployAssert2A1021D3.template.json @@ -0,0 +1,36 @@ +{ + "Parameters": { + "BootstrapVersion": { + "Type": "AWS::SSM::Parameter::Value", + "Default": "/cdk-bootstrap/hnb659fds/version", + "Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]" + } + }, + "Rules": { + "CheckBootstrapVersion": { + "Assertions": [ + { + "Assert": { + "Fn::Not": [ + { + "Fn::Contains": [ + [ + "1", + "2", + "3", + "4", + "5" + ], + { + "Ref": "BootstrapVersion" + } + ] + } + ] + }, + "AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI." + } + ] + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/apigateway/integ.call-rest-api-cross-region.js.snapshot/cdk.out b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/apigateway/integ.call-rest-api-cross-region.js.snapshot/cdk.out new file mode 100644 index 0000000000000..91e1a8b9901d5 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/apigateway/integ.call-rest-api-cross-region.js.snapshot/cdk.out @@ -0,0 +1 @@ +{"version":"39.0.0"} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/apigateway/integ.call-rest-api-cross-region.js.snapshot/integ.json b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/apigateway/integ.call-rest-api-cross-region.js.snapshot/integ.json new file mode 100644 index 0000000000000..ad32065ed6025 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/apigateway/integ.call-rest-api-cross-region.js.snapshot/integ.json @@ -0,0 +1,13 @@ +{ + "version": "39.0.0", + "testCases": { + "call-rest-api-cross-region/DefaultTest": { + "stacks": [ + "CallRestApiInteg-ApiStack", + "CallRestApiInteg-SfnStack" + ], + "assertionStack": "call-rest-api-cross-region/DefaultTest/DeployAssert", + "assertionStackName": "callrestapicrossregionDefaultTestDeployAssert2A1021D3" + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/apigateway/integ.call-rest-api-cross-region.js.snapshot/manifest.json b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/apigateway/integ.call-rest-api-cross-region.js.snapshot/manifest.json new file mode 100644 index 0000000000000..57e260628d732 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/apigateway/integ.call-rest-api-cross-region.js.snapshot/manifest.json @@ -0,0 +1,439 @@ +{ + "version": "39.0.0", + "artifacts": { + "CallRestApiInteg-ApiStack.assets": { + "type": "cdk:asset-manifest", + "properties": { + "file": "CallRestApiInteg-ApiStack.assets.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "CallRestApiInteg-ApiStack": { + "type": "aws:cloudformation:stack", + "environment": "aws://unknown-account/us-west-2", + "properties": { + "templateFile": "CallRestApiInteg-ApiStack.template.json", + "terminationProtection": false, + "validateOnSynth": false, + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-us-west-2", + "cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-us-west-2", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-us-west-2/319feecbdd79b561ade2169ee0a835fdb91b5ecaecd5b259a64e78735ae73be0.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", + "additionalDependencies": [ + "CallRestApiInteg-ApiStack.assets" + ], + "lookupRole": { + "arn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-lookup-role-${AWS::AccountId}-us-west-2", + "requiresBootstrapStackVersion": 8, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "dependencies": [ + "CallRestApiInteg-ApiStack.assets" + ], + "metadata": { + "/CallRestApiInteg-ApiStack/MyRestApi": [ + { + "type": "aws:cdk:analytics:construct", + "data": { + "cloudWatchRole": "*" + } + } + ], + "/CallRestApiInteg-ApiStack/MyRestApi/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "MyRestApi2D1F47A9" + } + ], + "/CallRestApiInteg-ApiStack/MyRestApi/CloudWatchRole": [ + { + "type": "aws:cdk:analytics:construct", + "data": { + "assumedBy": { + "principalAccount": "*", + "assumeRoleAction": "*" + }, + "managedPolicies": [ + { + "managedPolicyArn": "*" + } + ] + } + } + ], + "/CallRestApiInteg-ApiStack/MyRestApi/CloudWatchRole/ImportCloudWatchRole": [ + { + "type": "aws:cdk:analytics:construct", + "data": "*" + } + ], + "/CallRestApiInteg-ApiStack/MyRestApi/CloudWatchRole/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "MyRestApiCloudWatchRoleD4042E8E" + } + ], + "/CallRestApiInteg-ApiStack/MyRestApi/Account": [ + { + "type": "aws:cdk:logicalId", + "data": "MyRestApiAccount2FB6DB7A" + } + ], + "/CallRestApiInteg-ApiStack/MyRestApi/Deployment": [ + { + "type": "aws:cdk:analytics:construct", + "data": { + "description": "*", + "api": "*", + "retainDeployments": "*" + } + } + ], + "/CallRestApiInteg-ApiStack/MyRestApi/Deployment/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "MyRestApiDeploymentB555B5824a2dace0b77d6e14d0cc32d4d28422f3" + } + ], + "/CallRestApiInteg-ApiStack/MyRestApi/DeploymentStage.prod": [ + { + "type": "aws:cdk:analytics:construct", + "data": { + "deployment": "*" + } + } + ], + "/CallRestApiInteg-ApiStack/MyRestApi/DeploymentStage.prod/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "MyRestApiDeploymentStageprodC33B8E5F" + } + ], + "/CallRestApiInteg-ApiStack/MyRestApi/Endpoint": [ + { + "type": "aws:cdk:logicalId", + "data": "MyRestApiEndpoint4C55E4CB" + } + ], + "/CallRestApiInteg-ApiStack/MyRestApi/Default": [ + { + "type": "aws:cdk:analytics:construct", + "data": "*" + } + ], + "/CallRestApiInteg-ApiStack/MyRestApi/Default/ANY": [ + { + "type": "aws:cdk:analytics:construct", + "data": { + "resource": "*", + "httpMethod": "*", + "integration": "*", + "options": "*" + } + } + ], + "/CallRestApiInteg-ApiStack/MyRestApi/Default/ANY/ApiPermission.CallRestApiIntegApiStackMyRestApiC2593C7A.ANY..": [ + { + "type": "aws:cdk:logicalId", + "data": "MyRestApiANYApiPermissionCallRestApiIntegApiStackMyRestApiC2593C7AANY7E91F016" + } + ], + "/CallRestApiInteg-ApiStack/MyRestApi/Default/ANY/ApiPermission.Test.CallRestApiIntegApiStackMyRestApiC2593C7A.ANY..": [ + { + "type": "aws:cdk:logicalId", + "data": "MyRestApiANYApiPermissionTestCallRestApiIntegApiStackMyRestApiC2593C7AANY4B5F396C" + } + ], + "/CallRestApiInteg-ApiStack/MyRestApi/Default/ANY/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "MyRestApiANY05143F93" + } + ], + "/CallRestApiInteg-ApiStack/Hello": [ + { + "type": "aws:cdk:analytics:construct", + "data": { + "runtime": "*", + "handler": "*", + "code": "*" + } + } + ], + "/CallRestApiInteg-ApiStack/Hello/ServiceRole": [ + { + "type": "aws:cdk:analytics:construct", + "data": { + "assumedBy": { + "principalAccount": "*", + "assumeRoleAction": "*" + }, + "managedPolicies": [ + { + "managedPolicyArn": "*" + } + ] + } + } + ], + "/CallRestApiInteg-ApiStack/Hello/ServiceRole/ImportServiceRole": [ + { + "type": "aws:cdk:analytics:construct", + "data": "*" + } + ], + "/CallRestApiInteg-ApiStack/Hello/ServiceRole/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "HelloServiceRole1E55EA16" + } + ], + "/CallRestApiInteg-ApiStack/Hello/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "Hello4A628BD4" + } + ], + "/CallRestApiInteg-ApiStack/ExportsWriteruseast10F67B507/Resource": [ + { + "type": "aws:cdk:analytics:construct", + "data": "*" + } + ], + "/CallRestApiInteg-ApiStack/ExportsWriteruseast10F67B507/Resource/Default": [ + { + "type": "aws:cdk:logicalId", + "data": "ExportsWriteruseast10F67B507DDE2E818" + } + ], + "/CallRestApiInteg-ApiStack/Custom::CrossRegionExportWriterCustomResourceProvider": [ + { + "type": "aws:cdk:is-custom-resource-handler-customResourceProvider", + "data": true + } + ], + "/CallRestApiInteg-ApiStack/Custom::CrossRegionExportWriterCustomResourceProvider/Role": [ + { + "type": "aws:cdk:logicalId", + "data": "CustomCrossRegionExportWriterCustomResourceProviderRoleC951B1E1" + } + ], + "/CallRestApiInteg-ApiStack/Custom::CrossRegionExportWriterCustomResourceProvider/Handler": [ + { + "type": "aws:cdk:logicalId", + "data": "CustomCrossRegionExportWriterCustomResourceProviderHandlerD8786E8A" + } + ], + "/CallRestApiInteg-ApiStack/BootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "BootstrapVersion" + } + ], + "/CallRestApiInteg-ApiStack/CheckBootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "CheckBootstrapVersion" + } + ] + }, + "displayName": "CallRestApiInteg-ApiStack" + }, + "CallRestApiInteg-SfnStack.assets": { + "type": "cdk:asset-manifest", + "properties": { + "file": "CallRestApiInteg-SfnStack.assets.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "CallRestApiInteg-SfnStack": { + "type": "aws:cloudformation:stack", + "environment": "aws://unknown-account/us-east-1", + "properties": { + "templateFile": "CallRestApiInteg-SfnStack.template.json", + "terminationProtection": false, + "validateOnSynth": false, + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-us-east-1", + "cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-us-east-1", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-us-east-1/4b53f3b1f75f7c2c40971f3e37d5448f36e7b39949926864276994f8ec2e0d6d.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", + "additionalDependencies": [ + "CallRestApiInteg-SfnStack.assets" + ], + "lookupRole": { + "arn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-lookup-role-${AWS::AccountId}-us-east-1", + "requiresBootstrapStackVersion": 8, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "dependencies": [ + "CallRestApiInteg-ApiStack", + "CallRestApiInteg-SfnStack.assets" + ], + "metadata": { + "/CallRestApiInteg-SfnStack/StateMachine": [ + { + "type": "aws:cdk:analytics:construct", + "data": { + "definition": { + "id": "*", + "startState": "*", + "endStates": "*" + }, + "timeout": "*" + } + } + ], + "/CallRestApiInteg-SfnStack/StateMachine/Role": [ + { + "type": "aws:cdk:analytics:construct", + "data": { + "assumedBy": { + "principalAccount": "*", + "assumeRoleAction": "*" + } + } + } + ], + "/CallRestApiInteg-SfnStack/StateMachine/Role/ImportRole": [ + { + "type": "aws:cdk:analytics:construct", + "data": "*" + } + ], + "/CallRestApiInteg-SfnStack/StateMachine/Role/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "StateMachineRoleB840431D" + } + ], + "/CallRestApiInteg-SfnStack/StateMachine/Role/DefaultPolicy": [ + { + "type": "aws:cdk:analytics:construct", + "data": "*" + } + ], + "/CallRestApiInteg-SfnStack/StateMachine/Role/DefaultPolicy/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "StateMachineRoleDefaultPolicyDF1E6607" + } + ], + "/CallRestApiInteg-SfnStack/StateMachine/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "StateMachine2E01A3A5" + } + ], + "/CallRestApiInteg-SfnStack/stateMachineArn": [ + { + "type": "aws:cdk:logicalId", + "data": "stateMachineArn" + } + ], + "/CallRestApiInteg-SfnStack/ExportsReader/Resource": [ + { + "type": "aws:cdk:analytics:construct", + "data": "*" + } + ], + "/CallRestApiInteg-SfnStack/ExportsReader/Resource/Default": [ + { + "type": "aws:cdk:logicalId", + "data": "ExportsReader8B249524" + } + ], + "/CallRestApiInteg-SfnStack/Custom::CrossRegionExportReaderCustomResourceProvider": [ + { + "type": "aws:cdk:is-custom-resource-handler-customResourceProvider", + "data": true + } + ], + "/CallRestApiInteg-SfnStack/Custom::CrossRegionExportReaderCustomResourceProvider/Role": [ + { + "type": "aws:cdk:logicalId", + "data": "CustomCrossRegionExportReaderCustomResourceProviderRole10531BBD" + } + ], + "/CallRestApiInteg-SfnStack/Custom::CrossRegionExportReaderCustomResourceProvider/Handler": [ + { + "type": "aws:cdk:logicalId", + "data": "CustomCrossRegionExportReaderCustomResourceProviderHandler46647B68" + } + ], + "/CallRestApiInteg-SfnStack/BootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "BootstrapVersion" + } + ], + "/CallRestApiInteg-SfnStack/CheckBootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "CheckBootstrapVersion" + } + ] + }, + "displayName": "CallRestApiInteg-SfnStack" + }, + "callrestapicrossregionDefaultTestDeployAssert2A1021D3.assets": { + "type": "cdk:asset-manifest", + "properties": { + "file": "callrestapicrossregionDefaultTestDeployAssert2A1021D3.assets.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "callrestapicrossregionDefaultTestDeployAssert2A1021D3": { + "type": "aws:cloudformation:stack", + "environment": "aws://unknown-account/unknown-region", + "properties": { + "templateFile": "callrestapicrossregionDefaultTestDeployAssert2A1021D3.template.json", + "terminationProtection": false, + "validateOnSynth": false, + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}", + "cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", + "additionalDependencies": [ + "callrestapicrossregionDefaultTestDeployAssert2A1021D3.assets" + ], + "lookupRole": { + "arn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-lookup-role-${AWS::AccountId}-${AWS::Region}", + "requiresBootstrapStackVersion": 8, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "dependencies": [ + "callrestapicrossregionDefaultTestDeployAssert2A1021D3.assets" + ], + "metadata": { + "/call-rest-api-cross-region/DefaultTest/DeployAssert/BootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "BootstrapVersion" + } + ], + "/call-rest-api-cross-region/DefaultTest/DeployAssert/CheckBootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "CheckBootstrapVersion" + } + ] + }, + "displayName": "call-rest-api-cross-region/DefaultTest/DeployAssert" + }, + "Tree": { + "type": "cdk:tree", + "properties": { + "file": "tree.json" + } + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/apigateway/integ.call-rest-api-cross-region.js.snapshot/tree.json b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/apigateway/integ.call-rest-api-cross-region.js.snapshot/tree.json new file mode 100644 index 0000000000000..09f7aefa92a4c --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/apigateway/integ.call-rest-api-cross-region.js.snapshot/tree.json @@ -0,0 +1,922 @@ +{ + "version": "tree-0.1", + "tree": { + "id": "App", + "path": "", + "children": { + "CallRestApiInteg-ApiStack": { + "id": "CallRestApiInteg-ApiStack", + "path": "CallRestApiInteg-ApiStack", + "children": { + "MyRestApi": { + "id": "MyRestApi", + "path": "CallRestApiInteg-ApiStack/MyRestApi", + "children": { + "Resource": { + "id": "Resource", + "path": "CallRestApiInteg-ApiStack/MyRestApi/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::ApiGateway::RestApi", + "aws:cdk:cloudformation:props": { + "name": "MyRestApi" + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_apigateway.CfnRestApi", + "version": "0.0.0" + } + }, + "CloudWatchRole": { + "id": "CloudWatchRole", + "path": "CallRestApiInteg-ApiStack/MyRestApi/CloudWatchRole", + "children": { + "ImportCloudWatchRole": { + "id": "ImportCloudWatchRole", + "path": "CallRestApiInteg-ApiStack/MyRestApi/CloudWatchRole/ImportCloudWatchRole", + "constructInfo": { + "fqn": "aws-cdk-lib.Resource", + "version": "0.0.0", + "metadata": [ + "*" + ] + } + }, + "Resource": { + "id": "Resource", + "path": "CallRestApiInteg-ApiStack/MyRestApi/CloudWatchRole/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::IAM::Role", + "aws:cdk:cloudformation:props": { + "assumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "apigateway.amazonaws.com" + } + } + ], + "Version": "2012-10-17" + }, + "managedPolicyArns": [ + { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":iam::aws:policy/service-role/AmazonAPIGatewayPushToCloudWatchLogs" + ] + ] + } + ] + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_iam.CfnRole", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_iam.Role", + "version": "0.0.0", + "metadata": [ + { + "assumedBy": { + "principalAccount": "*", + "assumeRoleAction": "*" + }, + "managedPolicies": [ + { + "managedPolicyArn": "*" + } + ] + } + ] + } + }, + "Account": { + "id": "Account", + "path": "CallRestApiInteg-ApiStack/MyRestApi/Account", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::ApiGateway::Account", + "aws:cdk:cloudformation:props": { + "cloudWatchRoleArn": { + "Fn::GetAtt": [ + "MyRestApiCloudWatchRoleD4042E8E", + "Arn" + ] + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_apigateway.CfnAccount", + "version": "0.0.0" + } + }, + "Deployment": { + "id": "Deployment", + "path": "CallRestApiInteg-ApiStack/MyRestApi/Deployment", + "children": { + "Resource": { + "id": "Resource", + "path": "CallRestApiInteg-ApiStack/MyRestApi/Deployment/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::ApiGateway::Deployment", + "aws:cdk:cloudformation:props": { + "description": "Automatically created by the RestApi construct", + "restApiId": { + "Ref": "MyRestApi2D1F47A9" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_apigateway.CfnDeployment", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_apigateway.Deployment", + "version": "0.0.0", + "metadata": [ + { + "description": "*", + "api": "*", + "retainDeployments": "*" + } + ] + } + }, + "DeploymentStage.prod": { + "id": "DeploymentStage.prod", + "path": "CallRestApiInteg-ApiStack/MyRestApi/DeploymentStage.prod", + "children": { + "Resource": { + "id": "Resource", + "path": "CallRestApiInteg-ApiStack/MyRestApi/DeploymentStage.prod/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::ApiGateway::Stage", + "aws:cdk:cloudformation:props": { + "deploymentId": { + "Ref": "MyRestApiDeploymentB555B5824a2dace0b77d6e14d0cc32d4d28422f3" + }, + "restApiId": { + "Ref": "MyRestApi2D1F47A9" + }, + "stageName": "prod" + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_apigateway.CfnStage", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_apigateway.Stage", + "version": "0.0.0", + "metadata": [ + { + "deployment": "*" + } + ] + } + }, + "Endpoint": { + "id": "Endpoint", + "path": "CallRestApiInteg-ApiStack/MyRestApi/Endpoint", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnOutput", + "version": "0.0.0" + } + }, + "Default": { + "id": "Default", + "path": "CallRestApiInteg-ApiStack/MyRestApi/Default", + "children": { + "ANY": { + "id": "ANY", + "path": "CallRestApiInteg-ApiStack/MyRestApi/Default/ANY", + "children": { + "ApiPermission.CallRestApiIntegApiStackMyRestApiC2593C7A.ANY..": { + "id": "ApiPermission.CallRestApiIntegApiStackMyRestApiC2593C7A.ANY..", + "path": "CallRestApiInteg-ApiStack/MyRestApi/Default/ANY/ApiPermission.CallRestApiIntegApiStackMyRestApiC2593C7A.ANY..", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::Lambda::Permission", + "aws:cdk:cloudformation:props": { + "action": "lambda:InvokeFunction", + "functionName": { + "Fn::GetAtt": [ + "Hello4A628BD4", + "Arn" + ] + }, + "principal": "apigateway.amazonaws.com", + "sourceArn": { + "Fn::Join": [ + "", + [ + "arn:aws:execute-api:us-west-2:", + { + "Ref": "AWS::AccountId" + }, + ":", + { + "Ref": "MyRestApi2D1F47A9" + }, + "/", + { + "Ref": "MyRestApiDeploymentStageprodC33B8E5F" + }, + "/*/" + ] + ] + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_lambda.CfnPermission", + "version": "0.0.0" + } + }, + "ApiPermission.Test.CallRestApiIntegApiStackMyRestApiC2593C7A.ANY..": { + "id": "ApiPermission.Test.CallRestApiIntegApiStackMyRestApiC2593C7A.ANY..", + "path": "CallRestApiInteg-ApiStack/MyRestApi/Default/ANY/ApiPermission.Test.CallRestApiIntegApiStackMyRestApiC2593C7A.ANY..", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::Lambda::Permission", + "aws:cdk:cloudformation:props": { + "action": "lambda:InvokeFunction", + "functionName": { + "Fn::GetAtt": [ + "Hello4A628BD4", + "Arn" + ] + }, + "principal": "apigateway.amazonaws.com", + "sourceArn": { + "Fn::Join": [ + "", + [ + "arn:aws:execute-api:us-west-2:", + { + "Ref": "AWS::AccountId" + }, + ":", + { + "Ref": "MyRestApi2D1F47A9" + }, + "/test-invoke-stage/*/" + ] + ] + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_lambda.CfnPermission", + "version": "0.0.0" + } + }, + "Resource": { + "id": "Resource", + "path": "CallRestApiInteg-ApiStack/MyRestApi/Default/ANY/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::ApiGateway::Method", + "aws:cdk:cloudformation:props": { + "authorizationType": "NONE", + "httpMethod": "ANY", + "integration": { + "type": "AWS_PROXY", + "uri": { + "Fn::Join": [ + "", + [ + "arn:aws:apigateway:us-west-2:lambda:path/2015-03-31/functions/", + { + "Fn::GetAtt": [ + "Hello4A628BD4", + "Arn" + ] + }, + "/invocations" + ] + ] + }, + "integrationHttpMethod": "POST" + }, + "resourceId": { + "Fn::GetAtt": [ + "MyRestApi2D1F47A9", + "RootResourceId" + ] + }, + "restApiId": { + "Ref": "MyRestApi2D1F47A9" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_apigateway.CfnMethod", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_apigateway.Method", + "version": "0.0.0", + "metadata": [ + { + "resource": "*", + "httpMethod": "*", + "integration": "*", + "options": "*" + } + ] + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_apigateway.ResourceBase", + "version": "0.0.0", + "metadata": [ + "*" + ] + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_apigateway.RestApi", + "version": "0.0.0", + "metadata": [ + { + "cloudWatchRole": "*" + } + ] + } + }, + "Hello": { + "id": "Hello", + "path": "CallRestApiInteg-ApiStack/Hello", + "children": { + "ServiceRole": { + "id": "ServiceRole", + "path": "CallRestApiInteg-ApiStack/Hello/ServiceRole", + "children": { + "ImportServiceRole": { + "id": "ImportServiceRole", + "path": "CallRestApiInteg-ApiStack/Hello/ServiceRole/ImportServiceRole", + "constructInfo": { + "fqn": "aws-cdk-lib.Resource", + "version": "0.0.0", + "metadata": [ + "*" + ] + } + }, + "Resource": { + "id": "Resource", + "path": "CallRestApiInteg-ApiStack/Hello/ServiceRole/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::IAM::Role", + "aws:cdk:cloudformation:props": { + "assumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "lambda.amazonaws.com" + } + } + ], + "Version": "2012-10-17" + }, + "managedPolicyArns": [ + { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" + ] + ] + } + ] + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_iam.CfnRole", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_iam.Role", + "version": "0.0.0", + "metadata": [ + { + "assumedBy": { + "principalAccount": "*", + "assumeRoleAction": "*" + }, + "managedPolicies": [ + { + "managedPolicyArn": "*" + } + ] + } + ] + } + }, + "Resource": { + "id": "Resource", + "path": "CallRestApiInteg-ApiStack/Hello/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::Lambda::Function", + "aws:cdk:cloudformation:props": { + "code": { + "zipFile": "exports.handler = async function(event, context) { return { statusCode: 200, body: \"hello, world!\" }; };" + }, + "handler": "index.handler", + "role": { + "Fn::GetAtt": [ + "HelloServiceRole1E55EA16", + "Arn" + ] + }, + "runtime": "nodejs18.x" + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_lambda.CfnFunction", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_lambda.Function", + "version": "0.0.0", + "metadata": [ + { + "runtime": "*", + "handler": "*", + "code": "*" + } + ] + } + }, + "ExportsWriteruseast10F67B507": { + "id": "ExportsWriteruseast10F67B507", + "path": "CallRestApiInteg-ApiStack/ExportsWriteruseast10F67B507", + "children": { + "Resource": { + "id": "Resource", + "path": "CallRestApiInteg-ApiStack/ExportsWriteruseast10F67B507/Resource", + "children": { + "Default": { + "id": "Default", + "path": "CallRestApiInteg-ApiStack/ExportsWriteruseast10F67B507/Resource/Default", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnResource", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.CustomResource", + "version": "0.0.0", + "metadata": [ + "*" + ] + } + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.4.2" + } + }, + "Custom::CrossRegionExportWriterCustomResourceProvider": { + "id": "Custom::CrossRegionExportWriterCustomResourceProvider", + "path": "CallRestApiInteg-ApiStack/Custom::CrossRegionExportWriterCustomResourceProvider", + "children": { + "Staging": { + "id": "Staging", + "path": "CallRestApiInteg-ApiStack/Custom::CrossRegionExportWriterCustomResourceProvider/Staging", + "constructInfo": { + "fqn": "aws-cdk-lib.AssetStaging", + "version": "0.0.0" + } + }, + "Role": { + "id": "Role", + "path": "CallRestApiInteg-ApiStack/Custom::CrossRegionExportWriterCustomResourceProvider/Role", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnResource", + "version": "0.0.0" + } + }, + "Handler": { + "id": "Handler", + "path": "CallRestApiInteg-ApiStack/Custom::CrossRegionExportWriterCustomResourceProvider/Handler", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnResource", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.CustomResourceProviderBase", + "version": "0.0.0" + } + }, + "BootstrapVersion": { + "id": "BootstrapVersion", + "path": "CallRestApiInteg-ApiStack/BootstrapVersion", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnParameter", + "version": "0.0.0" + } + }, + "CheckBootstrapVersion": { + "id": "CheckBootstrapVersion", + "path": "CallRestApiInteg-ApiStack/CheckBootstrapVersion", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnRule", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.Stack", + "version": "0.0.0" + } + }, + "CallRestApiInteg-SfnStack": { + "id": "CallRestApiInteg-SfnStack", + "path": "CallRestApiInteg-SfnStack", + "children": { + "CrossStackReferenceToApi": { + "id": "CrossStackReferenceToApi", + "path": "CallRestApiInteg-SfnStack/CrossStackReferenceToApi", + "constructInfo": { + "fqn": "aws-cdk-lib.aws_apigateway.RestApiBase", + "version": "0.0.0", + "metadata": [] + } + }, + "Call APIGW": { + "id": "Call APIGW", + "path": "CallRestApiInteg-SfnStack/Call APIGW", + "constructInfo": { + "fqn": "aws-cdk-lib.aws_stepfunctions_tasks.CallApiGatewayRestApiEndpoint", + "version": "0.0.0" + } + }, + "StateMachine": { + "id": "StateMachine", + "path": "CallRestApiInteg-SfnStack/StateMachine", + "children": { + "Role": { + "id": "Role", + "path": "CallRestApiInteg-SfnStack/StateMachine/Role", + "children": { + "ImportRole": { + "id": "ImportRole", + "path": "CallRestApiInteg-SfnStack/StateMachine/Role/ImportRole", + "constructInfo": { + "fqn": "aws-cdk-lib.Resource", + "version": "0.0.0", + "metadata": [ + "*" + ] + } + }, + "Resource": { + "id": "Resource", + "path": "CallRestApiInteg-SfnStack/StateMachine/Role/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::IAM::Role", + "aws:cdk:cloudformation:props": { + "assumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "states.amazonaws.com" + } + } + ], + "Version": "2012-10-17" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_iam.CfnRole", + "version": "0.0.0" + } + }, + "DefaultPolicy": { + "id": "DefaultPolicy", + "path": "CallRestApiInteg-SfnStack/StateMachine/Role/DefaultPolicy", + "children": { + "Resource": { + "id": "Resource", + "path": "CallRestApiInteg-SfnStack/StateMachine/Role/DefaultPolicy/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::IAM::Policy", + "aws:cdk:cloudformation:props": { + "policyDocument": { + "Statement": [ + { + "Action": "execute-api:Invoke", + "Effect": "Allow", + "Resource": { + "Fn::Join": [ + "", + [ + "arn:aws:execute-api:us-east-1:", + { + "Ref": "AWS::AccountId" + }, + ":", + { + "Fn::GetAtt": [ + "ExportsReader8B249524", + "/cdk/exports/CallRestApiInteg-SfnStack/CallRestApiIntegApiStackuswest2RefMyRestApi2D1F47A94BF96318" + ] + }, + "/prod/GET/*" + ] + ] + } + } + ], + "Version": "2012-10-17" + }, + "policyName": "StateMachineRoleDefaultPolicyDF1E6607", + "roles": [ + { + "Ref": "StateMachineRoleB840431D" + } + ] + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_iam.CfnPolicy", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_iam.Policy", + "version": "0.0.0", + "metadata": [ + "*" + ] + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_iam.Role", + "version": "0.0.0", + "metadata": [ + { + "assumedBy": { + "principalAccount": "*", + "assumeRoleAction": "*" + } + } + ] + } + }, + "Resource": { + "id": "Resource", + "path": "CallRestApiInteg-SfnStack/StateMachine/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::StepFunctions::StateMachine", + "aws:cdk:cloudformation:props": { + "definitionString": { + "Fn::Join": [ + "", + [ + "{\"StartAt\":\"Call APIGW\",\"States\":{\"Call APIGW\":{\"End\":true,\"Type\":\"Task\",\"OutputPath\":\"$.ResponseBody\",\"Resource\":\"arn:", + { + "Ref": "AWS::Partition" + }, + ":states:::apigateway:invoke\",\"Parameters\":{\"ApiEndpoint\":\"", + { + "Fn::GetAtt": [ + "ExportsReader8B249524", + "/cdk/exports/CallRestApiInteg-SfnStack/CallRestApiIntegApiStackuswest2RefMyRestApi2D1F47A94BF96318" + ] + }, + ".execute-api.us-west-2.", + { + "Ref": "AWS::URLSuffix" + }, + "\",\"Method\":\"GET\",\"Stage\":\"prod\",\"AuthType\":\"IAM_ROLE\"}}},\"TimeoutSeconds\":30}" + ] + ] + }, + "roleArn": { + "Fn::GetAtt": [ + "StateMachineRoleB840431D", + "Arn" + ] + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_stepfunctions.CfnStateMachine", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_stepfunctions.StateMachine", + "version": "0.0.0", + "metadata": [ + { + "definition": { + "id": "*", + "startState": "*", + "endStates": "*" + }, + "timeout": "*" + } + ] + } + }, + "stateMachineArn": { + "id": "stateMachineArn", + "path": "CallRestApiInteg-SfnStack/stateMachineArn", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnOutput", + "version": "0.0.0" + } + }, + "ExportsReader": { + "id": "ExportsReader", + "path": "CallRestApiInteg-SfnStack/ExportsReader", + "children": { + "Resource": { + "id": "Resource", + "path": "CallRestApiInteg-SfnStack/ExportsReader/Resource", + "children": { + "Default": { + "id": "Default", + "path": "CallRestApiInteg-SfnStack/ExportsReader/Resource/Default", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnResource", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.CustomResource", + "version": "0.0.0", + "metadata": [ + "*" + ] + } + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.4.2" + } + }, + "Custom::CrossRegionExportReaderCustomResourceProvider": { + "id": "Custom::CrossRegionExportReaderCustomResourceProvider", + "path": "CallRestApiInteg-SfnStack/Custom::CrossRegionExportReaderCustomResourceProvider", + "children": { + "Staging": { + "id": "Staging", + "path": "CallRestApiInteg-SfnStack/Custom::CrossRegionExportReaderCustomResourceProvider/Staging", + "constructInfo": { + "fqn": "aws-cdk-lib.AssetStaging", + "version": "0.0.0" + } + }, + "Role": { + "id": "Role", + "path": "CallRestApiInteg-SfnStack/Custom::CrossRegionExportReaderCustomResourceProvider/Role", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnResource", + "version": "0.0.0" + } + }, + "Handler": { + "id": "Handler", + "path": "CallRestApiInteg-SfnStack/Custom::CrossRegionExportReaderCustomResourceProvider/Handler", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnResource", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.CustomResourceProviderBase", + "version": "0.0.0" + } + }, + "BootstrapVersion": { + "id": "BootstrapVersion", + "path": "CallRestApiInteg-SfnStack/BootstrapVersion", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnParameter", + "version": "0.0.0" + } + }, + "CheckBootstrapVersion": { + "id": "CheckBootstrapVersion", + "path": "CallRestApiInteg-SfnStack/CheckBootstrapVersion", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnRule", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.Stack", + "version": "0.0.0" + } + }, + "call-rest-api-cross-region": { + "id": "call-rest-api-cross-region", + "path": "call-rest-api-cross-region", + "children": { + "DefaultTest": { + "id": "DefaultTest", + "path": "call-rest-api-cross-region/DefaultTest", + "children": { + "Default": { + "id": "Default", + "path": "call-rest-api-cross-region/DefaultTest/Default", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.4.2" + } + }, + "DeployAssert": { + "id": "DeployAssert", + "path": "call-rest-api-cross-region/DefaultTest/DeployAssert", + "children": { + "BootstrapVersion": { + "id": "BootstrapVersion", + "path": "call-rest-api-cross-region/DefaultTest/DeployAssert/BootstrapVersion", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnParameter", + "version": "0.0.0" + } + }, + "CheckBootstrapVersion": { + "id": "CheckBootstrapVersion", + "path": "call-rest-api-cross-region/DefaultTest/DeployAssert/CheckBootstrapVersion", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnRule", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.Stack", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/integ-tests-alpha.IntegTestCase", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/integ-tests-alpha.IntegTest", + "version": "0.0.0" + } + }, + "Tree": { + "id": "Tree", + "path": "Tree", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.4.2" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.App", + "version": "0.0.0" + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/apigateway/integ.call-rest-api-cross-region.ts b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/apigateway/integ.call-rest-api-cross-region.ts new file mode 100644 index 0000000000000..8843a852f2d62 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/apigateway/integ.call-rest-api-cross-region.ts @@ -0,0 +1,61 @@ +import * as apigateway from 'aws-cdk-lib/aws-apigateway'; +import * as lambda from 'aws-cdk-lib/aws-lambda'; +import * as sfn from 'aws-cdk-lib/aws-stepfunctions'; +import * as cdk from 'aws-cdk-lib'; +import { IntegTest } from '@aws-cdk/integ-tests-alpha'; +import { AuthType, HttpMethod, CallApiGatewayRestApiEndpoint } from 'aws-cdk-lib/aws-stepfunctions-tasks'; +import { STANDARD_NODEJS_RUNTIME } from '../../../config'; + +/* + * Stack verification steps: + * * aws stepfunctions start-execution --state-machine-arn : should return execution arn + * + * * aws stepfunctions describe-execution --execution-arn --query 'status': should return status as SUCCEEDED + * * aws stepfunctions describe-execution --execution-arn --query 'output': should return the string \"hello, world!\" + */ + +const app = new cdk.App(); +const apiStack = new cdk.Stack(app, 'CallRestApiInteg-ApiStack', { + env: { + region: 'us-west-2', + }, +}); +const sfnStack = new cdk.Stack(app, 'CallRestApiInteg-SfnStack', { + env: { + region: 'us-east-1', + }, + crossRegionReferences: true, +}); +const restApi = new apigateway.RestApi(apiStack, 'MyRestApi', { cloudWatchRole: true }); + +const hello = new apigateway.LambdaIntegration(new lambda.Function(apiStack, 'Hello', { + runtime: STANDARD_NODEJS_RUNTIME, + handler: 'index.handler', + code: new lambda.InlineCode('exports.handler = async function(event, context) { return { statusCode: 200, body: "hello, world!" }; };'), +})); +restApi.root.addMethod('ANY', hello); + +const importedRestApi = apigateway.RestApi.fromRestApiId(sfnStack, 'CrossStackReferenceToApi', restApi.restApiId); +const callEndpointJob = new CallApiGatewayRestApiEndpoint(sfnStack, 'Call APIGW', { + api: importedRestApi, + stageName: 'prod', + method: HttpMethod.GET, + region: 'us-west-2', + authType: AuthType.IAM_ROLE, + outputPath: sfn.JsonPath.stringAt('$.ResponseBody'), +}); + +const chain = sfn.Chain.start(callEndpointJob); + +const sm = new sfn.StateMachine(sfnStack, 'StateMachine', { + definition: chain, + timeout: cdk.Duration.seconds(30), +}); + +new cdk.CfnOutput(sfnStack, 'stateMachineArn', { + value: sm.stateMachineArn, +}); + +new IntegTest(app, 'call-rest-api-cross-region', { + testCases: [apiStack, sfnStack], +}); diff --git a/packages/aws-cdk-lib/aws-logs/README.md b/packages/aws-cdk-lib/aws-logs/README.md index ef32158b051e5..07863d584b932 100644 --- a/packages/aws-cdk-lib/aws-logs/README.md +++ b/packages/aws-cdk-lib/aws-logs/README.md @@ -295,6 +295,8 @@ and then descending into it, such as `$.field` or `$.list[0].field`. * `FilterPattern.stringValue(field, comparison, string)`: matches if the given field compares as indicated with the given string value. +* `FilterPattern.regexValue(field, comparison, string)`: matches if the given + field compares as indicated with the given regex pattern. * `FilterPattern.numberValue(field, comparison, number)`: matches if the given field compares as indicated with the given numerical value. * `FilterPattern.isNull(field)`: matches if the given field exists and has the @@ -324,6 +326,7 @@ const pattern = logs.FilterPattern.all( logs.FilterPattern.booleanValue('$.error', true), logs.FilterPattern.numberValue('$.latency', '>', 1000), ), + logs.FilterPattern.regexValue('$.message', '=', 'bind address already in use'), ); ``` diff --git a/packages/aws-cdk-lib/aws-logs/lib/pattern.ts b/packages/aws-cdk-lib/aws-logs/lib/pattern.ts index b37d458a0c3fc..44caabb6fec35 100644 --- a/packages/aws-cdk-lib/aws-logs/lib/pattern.ts +++ b/packages/aws-cdk-lib/aws-logs/lib/pattern.ts @@ -116,6 +116,27 @@ export class FilterPattern { return new JSONNumberPattern(jsonField, comparison, value); } + /** + * A JSON log pattern that compares against a Regex values. + * + * This pattern only matches if the event is a JSON event, and the indicated field inside + * compares with the regex value. + * + * Use '$' to indicate the root of the JSON structure. The comparison operator can only + * compare equality or inequality. + * + * For more information, see: + * + * https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/FilterAndPatternSyntax.html + * + * @param jsonField Field inside JSON. Example: "$.myField" + * @param comparison Comparison to carry out. Either = or !=. + * @param value The regex value to compare to. + */ + public static regexValue(jsonField: string, comparison: string, value: string): JsonPattern { + return new JSONRegexPattern(jsonField, comparison, value); + } + /** * A JSON log pattern that matches if the field exists and has the special value 'null'. * @@ -225,6 +246,16 @@ class JSONStringPattern extends JsonPattern { } } +/** + * A regex comparison for JSON patterns + */ +class JSONRegexPattern extends JsonPattern { + public constructor(jsonField: string, comparison: string, value: string) { + // No validation, we assume these are generated by trusted factory functions + super(`${jsonField} ${comparison} %${value}%`); + } +} + /** * A number comparison for JSON values */ @@ -260,7 +291,7 @@ class JSONAggregatePattern extends JsonPattern { } } -export type RestrictionMap = {[column: string]: ColumnRestriction[]}; +export type RestrictionMap = { [column: string]: ColumnRestriction[] }; const COL_ELLIPSIS = '...'; diff --git a/packages/aws-cdk-lib/aws-logs/test/integ.metricfilter.lit.ts b/packages/aws-cdk-lib/aws-logs/test/integ.metricfilter.lit.ts index dd61bf8ddedc9..ae7ef932c0c0f 100644 --- a/packages/aws-cdk-lib/aws-logs/test/integ.metricfilter.lit.ts +++ b/packages/aws-cdk-lib/aws-logs/test/integ.metricfilter.lit.ts @@ -14,7 +14,10 @@ class MetricFilterIntegStack extends Stack { logGroup, metricNamespace: 'MyApp', metricName: 'Latency', - filterPattern: FilterPattern.exists('$.latency'), + filterPattern: FilterPattern.all( + FilterPattern.exists('$.latency'), + FilterPattern.regexValue('$.message', '=', 'bind: address already in use'), + ), metricValue: '$.latency', }); /// !hide diff --git a/packages/aws-cdk-lib/aws-logs/test/pattern.test.ts b/packages/aws-cdk-lib/aws-logs/test/pattern.test.ts index b49c9cd220588..7ee8104c8e116 100644 --- a/packages/aws-cdk-lib/aws-logs/test/pattern.test.ts +++ b/packages/aws-cdk-lib/aws-logs/test/pattern.test.ts @@ -51,6 +51,12 @@ describe('pattern', () => { expect('{ $.field = "value" }').toEqual(pattern.logPatternString); }); + test('regex pattern', () => { + const pattern = FilterPattern.regexValue('$.field', '=', 'value'); + + expect('{ $.field = %value% }').toEqual(pattern.logPatternString); + }); + test('number patterns', () => { const pattern = FilterPattern.numberValue('$.field', '<=', 300); diff --git a/packages/aws-cdk-lib/aws-stepfunctions-tasks/README.md b/packages/aws-cdk-lib/aws-stepfunctions-tasks/README.md index 0dda2a4278d25..72ccd6bba05c1 100644 --- a/packages/aws-cdk-lib/aws-stepfunctions-tasks/README.md +++ b/packages/aws-cdk-lib/aws-stepfunctions-tasks/README.md @@ -155,6 +155,21 @@ const invokeTask = new tasks.CallApiGatewayRestApiEndpoint(this, 'Call REST API' }); ``` +By default, the API endpoint URI will be constructed using the AWS region of +the stack in which the provided `api` is created. + +To construct the endpoint with a different region, use the `region` parameter: +```ts +import * as apigateway from 'aws-cdk-lib/aws-apigateway'; +const restApi = new apigateway.RestApi(this, 'MyRestApi'); +const invokeTask = new tasks.CallApiGatewayRestApiEndpoint(this, 'Call REST API', { + api: restApi, + stageName: 'prod', + method: tasks.HttpMethod.GET, + region: 'us-west-2', +}); +``` + Be aware that the header values must be arrays. When passing the Task Token in the headers field `WAIT_FOR_TASK_TOKEN` integration, use `JsonPath.array()` to wrap the token in an array: diff --git a/packages/aws-cdk-lib/aws-stepfunctions-tasks/lib/apigateway/call-rest-api.ts b/packages/aws-cdk-lib/aws-stepfunctions-tasks/lib/apigateway/call-rest-api.ts index 888a5f21db5ea..89cf91890787e 100644 --- a/packages/aws-cdk-lib/aws-stepfunctions-tasks/lib/apigateway/call-rest-api.ts +++ b/packages/aws-cdk-lib/aws-stepfunctions-tasks/lib/apigateway/call-rest-api.ts @@ -19,6 +19,13 @@ export interface CallApiGatewayRestApiEndpointOptions { * Name of the stage where the API is deployed to in API Gateway */ readonly stageName: string; + + /** + * Specify a custom Region where the API is deployed, e.g. 'us-east-1'. + * + * @default - Uses the Region of the stack containing the `api`. + */ + readonly region?: string; } /** @@ -128,15 +135,15 @@ export class CallApiGatewayRestApiEndpoint extends CallApiGatewayEndpointBase { constructor(scope: Construct, id: string, private readonly props: CallApiGatewayRestApiEndpointProps) { super(scope, id, props); - this.apiEndpoint = this.getApiEndpoint(); + this.apiEndpoint = this.getApiEndpoint(props.region); this.arnForExecuteApi = props.api.arnForExecuteApi(props.method, props.apiPath, props.stageName); this.stageName = props.stageName; this.taskPolicies = this.createPolicyStatements(); } - private getApiEndpoint(): string { + private getApiEndpoint(region?: string): string { const apiStack = cdk.Stack.of(this.props.api); - return `${this.props.api.restApiId}.execute-api.${apiStack.region}.${apiStack.urlSuffix}`; + return `${this.props.api.restApiId}.execute-api.${region ?? apiStack.region}.${apiStack.urlSuffix}`; } } diff --git a/packages/aws-cdk-lib/aws-stepfunctions-tasks/test/apigateway/call-rest-api.test.ts b/packages/aws-cdk-lib/aws-stepfunctions-tasks/test/apigateway/call-rest-api.test.ts index 9d025c54ce592..20076a603548c 100644 --- a/packages/aws-cdk-lib/aws-stepfunctions-tasks/test/apigateway/call-rest-api.test.ts +++ b/packages/aws-cdk-lib/aws-stepfunctions-tasks/test/apigateway/call-rest-api.test.ts @@ -58,6 +58,58 @@ describe('CallApiGatewayRestApiEndpoint', () => { }); }); + test('provide region override', () => { + // GIVEN + const stack = new cdk.Stack(); + const restApi = new apigateway.RestApi(stack, 'RestApi'); + const region = 'us-west-2'; + + // WHEN + const task = new CallApiGatewayRestApiEndpoint(stack, 'Call', { + api: restApi, + method: HttpMethod.GET, + stageName: 'dev', + region: region, + }); + + // THEN + expect(stack.resolve(task.toStateJson())).toEqual({ + Type: 'Task', + End: true, + Parameters: { + ApiEndpoint: { + 'Fn::Join': [ + '', + [ + { + Ref: 'RestApi0C43BF4B', + }, + `.execute-api.${region}.`, + { + Ref: 'AWS::URLSuffix', + }, + ], + ], + }, + AuthType: 'NO_AUTH', + Method: 'GET', + Stage: 'dev', + }, + Resource: { + 'Fn::Join': [ + '', + [ + 'arn:', + { + Ref: 'AWS::Partition', + }, + ':states:::apigateway:invoke', + ], + ], + }, + }); + }); + test('wait for task token', () => { // GIVEN const stack = new cdk.Stack();