diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-apigateway/test/integ.stepfunctions-api-without-default-method-responses.js.snapshot/SfnRestApiWithoutDefaultMethodResponses.assets.json b/packages/@aws-cdk-testing/framework-integ/test/aws-apigateway/test/integ.stepfunctions-api-without-default-method-responses.js.snapshot/SfnRestApiWithoutDefaultMethodResponses.assets.json new file mode 100644 index 0000000000000..c73a1c50b2f11 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-apigateway/test/integ.stepfunctions-api-without-default-method-responses.js.snapshot/SfnRestApiWithoutDefaultMethodResponses.assets.json @@ -0,0 +1,19 @@ +{ + "version": "34.0.0", + "files": { + "c620c2b41560455e78429a8f5815c6e31bfc885931c79997531b8eaefcb3a767": { + "source": { + "path": "SfnRestApiWithoutDefaultMethodResponses.template.json", + "packaging": "file" + }, + "destinations": { + "current_account-current_region": { + "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", + "objectKey": "c620c2b41560455e78429a8f5815c6e31bfc885931c79997531b8eaefcb3a767.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-apigateway/test/integ.stepfunctions-api-without-default-method-responses.js.snapshot/SfnRestApiWithoutDefaultMethodResponses.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-apigateway/test/integ.stepfunctions-api-without-default-method-responses.js.snapshot/SfnRestApiWithoutDefaultMethodResponses.template.json new file mode 100644 index 0000000000000..7f4daedbd6d91 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-apigateway/test/integ.stepfunctions-api-without-default-method-responses.js.snapshot/SfnRestApiWithoutDefaultMethodResponses.template.json @@ -0,0 +1,276 @@ +{ + "Resources": { + "StateMachineRoleB840431D": { + "Type": "AWS::IAM::Role", + "Properties": { + "AssumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "states.amazonaws.com" + } + } + ], + "Version": "2012-10-17" + } + } + }, + "StateMachine2E01A3A5": { + "Type": "AWS::StepFunctions::StateMachine", + "Properties": { + "DefinitionString": "{\"StartAt\":\"PassTask\",\"States\":{\"PassTask\":{\"Type\":\"Pass\",\"Result\":\"Hello\",\"End\":true}}}", + "RoleArn": { + "Fn::GetAtt": [ + "StateMachineRoleB840431D", + "Arn" + ] + }, + "StateMachineType": "EXPRESS" + }, + "DependsOn": [ + "StateMachineRoleB840431D" + ], + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" + }, + "StepFunctionsRestApiC6E3E883": { + "Type": "AWS::ApiGateway::RestApi", + "Properties": { + "Name": "StepFunctionsRestApi" + } + }, + "StepFunctionsRestApiDeployment8FF8D52A481e2c6fad35132b46721c49969398fb": { + "Type": "AWS::ApiGateway::Deployment", + "Properties": { + "Description": "Automatically created by the RestApi construct", + "RestApiId": { + "Ref": "StepFunctionsRestApiC6E3E883" + } + }, + "DependsOn": [ + "StepFunctionsRestApiANY7699CA92" + ] + }, + "StepFunctionsRestApiDeploymentStageprodE1E3545E": { + "Type": "AWS::ApiGateway::Stage", + "Properties": { + "DeploymentId": { + "Ref": "StepFunctionsRestApiDeployment8FF8D52A481e2c6fad35132b46721c49969398fb" + }, + "RestApiId": { + "Ref": "StepFunctionsRestApiC6E3E883" + }, + "StageName": "prod" + } + }, + "StepFunctionsRestApiANYStartSyncExecutionRole425C03BB": { + "Type": "AWS::IAM::Role", + "Properties": { + "AssumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "apigateway.amazonaws.com" + } + } + ], + "Version": "2012-10-17" + } + } + }, + "StepFunctionsRestApiANYStartSyncExecutionRoleDefaultPolicy7B6D0CED": { + "Type": "AWS::IAM::Policy", + "Properties": { + "PolicyDocument": { + "Statement": [ + { + "Action": "states:StartSyncExecution", + "Effect": "Allow", + "Resource": { + "Ref": "StateMachine2E01A3A5" + } + } + ], + "Version": "2012-10-17" + }, + "PolicyName": "StepFunctionsRestApiANYStartSyncExecutionRoleDefaultPolicy7B6D0CED", + "Roles": [ + { + "Ref": "StepFunctionsRestApiANYStartSyncExecutionRole425C03BB" + } + ] + } + }, + "StepFunctionsRestApiANY7699CA92": { + "Type": "AWS::ApiGateway::Method", + "Properties": { + "AuthorizationType": "NONE", + "HttpMethod": "ANY", + "Integration": { + "Credentials": { + "Fn::GetAtt": [ + "StepFunctionsRestApiANYStartSyncExecutionRole425C03BB", + "Arn" + ] + }, + "IntegrationHttpMethod": "POST", + "IntegrationResponses": [ + { + "ResponseTemplates": { + "application/json": "#set($inputRoot = $input.path('$'))\n#if($input.path('$.status').toString().equals(\"FAILED\"))\n#set($context.responseOverride.status = 500)\n{\n\"error\": \"$input.path('$.error')\",\n\"cause\": \"$input.path('$.cause')\"\n}\n#else\n$input.path('$.output')\n#end" + }, + "StatusCode": "200" + }, + { + "ResponseTemplates": { + "application/json": "{\n \"error\": \"Bad request!\"\n }" + }, + "SelectionPattern": "4\\d{2}", + "StatusCode": "400" + }, + { + "ResponseTemplates": { + "application/json": "\"error\": $input.path('$.error')" + }, + "SelectionPattern": "5\\d{2}", + "StatusCode": "500" + } + ], + "PassthroughBehavior": "NEVER", + "RequestTemplates": { + "application/json": { + "Fn::Join": [ + "", + [ + "## Velocity Template used for API Gateway request mapping template\n##\n## This template forwards the request body, header, path, and querystring\n## to the execution input of the state machine.\n##\n## \"@@\" is used here as a placeholder for '\"' to avoid using escape characters.\n\n#set($inputString = '')\n#set($includeHeaders = false)\n#set($includeQueryString = true)\n#set($includePath = true)\n#set($includeAuthorizer = false)\n#set($allParams = $input.params())\n{\n \"stateMachineArn\": \"", + { + "Ref": "StateMachine2E01A3A5" + }, + "\",\n\n #set($inputString = \"$inputString,@@body@@: $input.body\")\n\n #if ($includeHeaders)\n #set($inputString = \"$inputString, @@header@@:{\")\n #foreach($paramName in $allParams.header.keySet())\n #set($inputString = \"$inputString @@$paramName@@: @@$util.escapeJavaScript($allParams.header.get($paramName))@@\")\n #if($foreach.hasNext)\n #set($inputString = \"$inputString,\")\n #end\n #end\n #set($inputString = \"$inputString }\")\n \n #end\n\n #if ($includeQueryString)\n #set($inputString = \"$inputString, @@querystring@@:{\")\n #foreach($paramName in $allParams.querystring.keySet())\n #set($inputString = \"$inputString @@$paramName@@: @@$util.escapeJavaScript($allParams.querystring.get($paramName))@@\")\n #if($foreach.hasNext)\n #set($inputString = \"$inputString,\")\n #end\n #end\n #set($inputString = \"$inputString }\")\n #end\n\n #if ($includePath)\n #set($inputString = \"$inputString, @@path@@:{\")\n #foreach($paramName in $allParams.path.keySet())\n #set($inputString = \"$inputString @@$paramName@@: @@$util.escapeJavaScript($allParams.path.get($paramName))@@\")\n #if($foreach.hasNext)\n #set($inputString = \"$inputString,\")\n #end\n #end\n #set($inputString = \"$inputString }\")\n #end\n \n #if ($includeAuthorizer)\n #set($inputString = \"$inputString, @@authorizer@@:{\")\n #foreach($paramName in $context.authorizer.keySet())\n #set($inputString = \"$inputString @@$paramName@@: @@$util.escapeJavaScript($context.authorizer.get($paramName))@@\")\n #if($foreach.hasNext)\n #set($inputString = \"$inputString,\")\n #end\n #end\n #set($inputString = \"$inputString }\")\n #end\n\n #set($requestContext = \"\")\n ## Check if the request context should be included as part of the execution input\n #if($requestContext && !$requestContext.empty)\n #set($inputString = \"$inputString,\")\n #set($inputString = \"$inputString @@requestContext@@: $requestContext\")\n #end\n\n #set($inputString = \"$inputString}\")\n #set($inputString = $inputString.replaceAll(\"@@\",'\"'))\n #set($len = $inputString.length() - 1)\n \"input\": \"{$util.escapeJavaScript($inputString.substring(1,$len)).replaceAll(\"\\\\'\",\"'\")}\"\n}\n" + ] + ] + } + }, + "Type": "AWS", + "Uri": { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":apigateway:", + { + "Ref": "AWS::Region" + }, + ":states:action/StartSyncExecution" + ] + ] + } + }, + "ResourceId": { + "Fn::GetAtt": [ + "StepFunctionsRestApiC6E3E883", + "RootResourceId" + ] + }, + "RestApiId": { + "Ref": "StepFunctionsRestApiC6E3E883" + } + } + } + }, + "Outputs": { + "StepFunctionsRestApiEndpoint0DD66FCB": { + "Value": { + "Fn::Join": [ + "", + [ + "https://", + { + "Ref": "StepFunctionsRestApiC6E3E883" + }, + ".execute-api.", + { + "Ref": "AWS::Region" + }, + ".", + { + "Ref": "AWS::URLSuffix" + }, + "/", + { + "Ref": "StepFunctionsRestApiDeploymentStageprodE1E3545E" + }, + "/" + ] + ] + } + }, + "ApiEndpoint": { + "Value": { + "Fn::Join": [ + "", + [ + "https://", + { + "Ref": "StepFunctionsRestApiC6E3E883" + }, + ".execute-api.", + { + "Ref": "AWS::Region" + }, + ".", + { + "Ref": "AWS::URLSuffix" + }, + "/", + { + "Ref": "StepFunctionsRestApiDeploymentStageprodE1E3545E" + }, + "/" + ] + ] + } + } + }, + "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-apigateway/test/integ.stepfunctions-api-without-default-method-responses.js.snapshot/cdk.out b/packages/@aws-cdk-testing/framework-integ/test/aws-apigateway/test/integ.stepfunctions-api-without-default-method-responses.js.snapshot/cdk.out new file mode 100644 index 0000000000000..2313ab5436501 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-apigateway/test/integ.stepfunctions-api-without-default-method-responses.js.snapshot/cdk.out @@ -0,0 +1 @@ +{"version":"34.0.0"} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-apigateway/test/integ.stepfunctions-api-without-default-method-responses.js.snapshot/integ.json b/packages/@aws-cdk-testing/framework-integ/test/aws-apigateway/test/integ.stepfunctions-api-without-default-method-responses.js.snapshot/integ.json new file mode 100644 index 0000000000000..1d229fdd1b220 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-apigateway/test/integ.stepfunctions-api-without-default-method-responses.js.snapshot/integ.json @@ -0,0 +1,12 @@ +{ + "version": "34.0.0", + "testCases": { + "sfn-restapi-without-default-method-responses/DefaultTest": { + "stacks": [ + "SfnRestApiWithoutDefaultMethodResponses" + ], + "assertionStack": "sfn-restapi-without-default-method-responses/DefaultTest/DeployAssert", + "assertionStackName": "sfnrestapiwithoutdefaultmethodresponsesDefaultTestDeployAssert7E2275C8" + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-apigateway/test/integ.stepfunctions-api-without-default-method-responses.js.snapshot/manifest.json b/packages/@aws-cdk-testing/framework-integ/test/aws-apigateway/test/integ.stepfunctions-api-without-default-method-responses.js.snapshot/manifest.json new file mode 100644 index 0000000000000..b600cc07e1fc6 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-apigateway/test/integ.stepfunctions-api-without-default-method-responses.js.snapshot/manifest.json @@ -0,0 +1,167 @@ +{ + "version": "34.0.0", + "artifacts": { + "SfnRestApiWithoutDefaultMethodResponses.assets": { + "type": "cdk:asset-manifest", + "properties": { + "file": "SfnRestApiWithoutDefaultMethodResponses.assets.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "SfnRestApiWithoutDefaultMethodResponses": { + "type": "aws:cloudformation:stack", + "environment": "aws://unknown-account/unknown-region", + "properties": { + "templateFile": "SfnRestApiWithoutDefaultMethodResponses.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}/c620c2b41560455e78429a8f5815c6e31bfc885931c79997531b8eaefcb3a767.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", + "additionalDependencies": [ + "SfnRestApiWithoutDefaultMethodResponses.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": [ + "SfnRestApiWithoutDefaultMethodResponses.assets" + ], + "metadata": { + "/SfnRestApiWithoutDefaultMethodResponses/StateMachine/Role/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "StateMachineRoleB840431D" + } + ], + "/SfnRestApiWithoutDefaultMethodResponses/StateMachine/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "StateMachine2E01A3A5" + } + ], + "/SfnRestApiWithoutDefaultMethodResponses/StepFunctionsRestApi/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "StepFunctionsRestApiC6E3E883" + } + ], + "/SfnRestApiWithoutDefaultMethodResponses/StepFunctionsRestApi/Deployment/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "StepFunctionsRestApiDeployment8FF8D52A481e2c6fad35132b46721c49969398fb" + } + ], + "/SfnRestApiWithoutDefaultMethodResponses/StepFunctionsRestApi/DeploymentStage.prod/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "StepFunctionsRestApiDeploymentStageprodE1E3545E" + } + ], + "/SfnRestApiWithoutDefaultMethodResponses/StepFunctionsRestApi/Endpoint": [ + { + "type": "aws:cdk:logicalId", + "data": "StepFunctionsRestApiEndpoint0DD66FCB" + } + ], + "/SfnRestApiWithoutDefaultMethodResponses/StepFunctionsRestApi/Default/ANY/StartSyncExecutionRole/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "StepFunctionsRestApiANYStartSyncExecutionRole425C03BB" + } + ], + "/SfnRestApiWithoutDefaultMethodResponses/StepFunctionsRestApi/Default/ANY/StartSyncExecutionRole/DefaultPolicy/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "StepFunctionsRestApiANYStartSyncExecutionRoleDefaultPolicy7B6D0CED" + } + ], + "/SfnRestApiWithoutDefaultMethodResponses/StepFunctionsRestApi/Default/ANY/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "StepFunctionsRestApiANY7699CA92" + } + ], + "/SfnRestApiWithoutDefaultMethodResponses/ApiEndpoint": [ + { + "type": "aws:cdk:logicalId", + "data": "ApiEndpoint" + } + ], + "/SfnRestApiWithoutDefaultMethodResponses/BootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "BootstrapVersion" + } + ], + "/SfnRestApiWithoutDefaultMethodResponses/CheckBootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "CheckBootstrapVersion" + } + ] + }, + "displayName": "SfnRestApiWithoutDefaultMethodResponses" + }, + "sfnrestapiwithoutdefaultmethodresponsesDefaultTestDeployAssert7E2275C8.assets": { + "type": "cdk:asset-manifest", + "properties": { + "file": "sfnrestapiwithoutdefaultmethodresponsesDefaultTestDeployAssert7E2275C8.assets.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "sfnrestapiwithoutdefaultmethodresponsesDefaultTestDeployAssert7E2275C8": { + "type": "aws:cloudformation:stack", + "environment": "aws://unknown-account/unknown-region", + "properties": { + "templateFile": "sfnrestapiwithoutdefaultmethodresponsesDefaultTestDeployAssert7E2275C8.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": [ + "sfnrestapiwithoutdefaultmethodresponsesDefaultTestDeployAssert7E2275C8.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": [ + "sfnrestapiwithoutdefaultmethodresponsesDefaultTestDeployAssert7E2275C8.assets" + ], + "metadata": { + "/sfn-restapi-without-default-method-responses/DefaultTest/DeployAssert/BootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "BootstrapVersion" + } + ], + "/sfn-restapi-without-default-method-responses/DefaultTest/DeployAssert/CheckBootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "CheckBootstrapVersion" + } + ] + }, + "displayName": "sfn-restapi-without-default-method-responses/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-apigateway/test/integ.stepfunctions-api-without-default-method-responses.js.snapshot/sfnrestapiwithoutdefaultmethodresponsesDefaultTestDeployAssert7E2275C8.assets.json b/packages/@aws-cdk-testing/framework-integ/test/aws-apigateway/test/integ.stepfunctions-api-without-default-method-responses.js.snapshot/sfnrestapiwithoutdefaultmethodresponsesDefaultTestDeployAssert7E2275C8.assets.json new file mode 100644 index 0000000000000..af88136274bde --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-apigateway/test/integ.stepfunctions-api-without-default-method-responses.js.snapshot/sfnrestapiwithoutdefaultmethodresponsesDefaultTestDeployAssert7E2275C8.assets.json @@ -0,0 +1,19 @@ +{ + "version": "34.0.0", + "files": { + "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": { + "source": { + "path": "sfnrestapiwithoutdefaultmethodresponsesDefaultTestDeployAssert7E2275C8.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-apigateway/test/integ.stepfunctions-api-without-default-method-responses.js.snapshot/sfnrestapiwithoutdefaultmethodresponsesDefaultTestDeployAssert7E2275C8.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-apigateway/test/integ.stepfunctions-api-without-default-method-responses.js.snapshot/sfnrestapiwithoutdefaultmethodresponsesDefaultTestDeployAssert7E2275C8.template.json new file mode 100644 index 0000000000000..ad9d0fb73d1dd --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-apigateway/test/integ.stepfunctions-api-without-default-method-responses.js.snapshot/sfnrestapiwithoutdefaultmethodresponsesDefaultTestDeployAssert7E2275C8.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-apigateway/test/integ.stepfunctions-api-without-default-method-responses.js.snapshot/tree.json b/packages/@aws-cdk-testing/framework-integ/test/aws-apigateway/test/integ.stepfunctions-api-without-default-method-responses.js.snapshot/tree.json new file mode 100644 index 0000000000000..2cd724501f5e8 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-apigateway/test/integ.stepfunctions-api-without-default-method-responses.js.snapshot/tree.json @@ -0,0 +1,471 @@ +{ + "version": "tree-0.1", + "tree": { + "id": "App", + "path": "", + "children": { + "SfnRestApiWithoutDefaultMethodResponses": { + "id": "SfnRestApiWithoutDefaultMethodResponses", + "path": "SfnRestApiWithoutDefaultMethodResponses", + "children": { + "PassTask": { + "id": "PassTask", + "path": "SfnRestApiWithoutDefaultMethodResponses/PassTask", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.2.70" + } + }, + "StateMachine": { + "id": "StateMachine", + "path": "SfnRestApiWithoutDefaultMethodResponses/StateMachine", + "children": { + "Role": { + "id": "Role", + "path": "SfnRestApiWithoutDefaultMethodResponses/StateMachine/Role", + "children": { + "ImportRole": { + "id": "ImportRole", + "path": "SfnRestApiWithoutDefaultMethodResponses/StateMachine/Role/ImportRole", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.2.70" + } + }, + "Resource": { + "id": "Resource", + "path": "SfnRestApiWithoutDefaultMethodResponses/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": "constructs.Construct", + "version": "10.2.70" + } + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.2.70" + } + }, + "Resource": { + "id": "Resource", + "path": "SfnRestApiWithoutDefaultMethodResponses/StateMachine/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::StepFunctions::StateMachine", + "aws:cdk:cloudformation:props": { + "definitionString": "{\"StartAt\":\"PassTask\",\"States\":{\"PassTask\":{\"Type\":\"Pass\",\"Result\":\"Hello\",\"End\":true}}}", + "roleArn": { + "Fn::GetAtt": [ + "StateMachineRoleB840431D", + "Arn" + ] + }, + "stateMachineType": "EXPRESS" + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.2.70" + } + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.2.70" + } + }, + "StepFunctionsRestApi": { + "id": "StepFunctionsRestApi", + "path": "SfnRestApiWithoutDefaultMethodResponses/StepFunctionsRestApi", + "children": { + "Resource": { + "id": "Resource", + "path": "SfnRestApiWithoutDefaultMethodResponses/StepFunctionsRestApi/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::ApiGateway::RestApi", + "aws:cdk:cloudformation:props": { + "name": "StepFunctionsRestApi" + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.2.70" + } + }, + "Deployment": { + "id": "Deployment", + "path": "SfnRestApiWithoutDefaultMethodResponses/StepFunctionsRestApi/Deployment", + "children": { + "Resource": { + "id": "Resource", + "path": "SfnRestApiWithoutDefaultMethodResponses/StepFunctionsRestApi/Deployment/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::ApiGateway::Deployment", + "aws:cdk:cloudformation:props": { + "description": "Automatically created by the RestApi construct", + "restApiId": { + "Ref": "StepFunctionsRestApiC6E3E883" + } + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.2.70" + } + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.2.70" + } + }, + "DeploymentStage.prod": { + "id": "DeploymentStage.prod", + "path": "SfnRestApiWithoutDefaultMethodResponses/StepFunctionsRestApi/DeploymentStage.prod", + "children": { + "Resource": { + "id": "Resource", + "path": "SfnRestApiWithoutDefaultMethodResponses/StepFunctionsRestApi/DeploymentStage.prod/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::ApiGateway::Stage", + "aws:cdk:cloudformation:props": { + "deploymentId": { + "Ref": "StepFunctionsRestApiDeployment8FF8D52A481e2c6fad35132b46721c49969398fb" + }, + "restApiId": { + "Ref": "StepFunctionsRestApiC6E3E883" + }, + "stageName": "prod" + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.2.70" + } + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.2.70" + } + }, + "Endpoint": { + "id": "Endpoint", + "path": "SfnRestApiWithoutDefaultMethodResponses/StepFunctionsRestApi/Endpoint", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.2.70" + } + }, + "Default": { + "id": "Default", + "path": "SfnRestApiWithoutDefaultMethodResponses/StepFunctionsRestApi/Default", + "children": { + "ANY": { + "id": "ANY", + "path": "SfnRestApiWithoutDefaultMethodResponses/StepFunctionsRestApi/Default/ANY", + "children": { + "StartSyncExecutionRole": { + "id": "StartSyncExecutionRole", + "path": "SfnRestApiWithoutDefaultMethodResponses/StepFunctionsRestApi/Default/ANY/StartSyncExecutionRole", + "children": { + "ImportStartSyncExecutionRole": { + "id": "ImportStartSyncExecutionRole", + "path": "SfnRestApiWithoutDefaultMethodResponses/StepFunctionsRestApi/Default/ANY/StartSyncExecutionRole/ImportStartSyncExecutionRole", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.2.70" + } + }, + "Resource": { + "id": "Resource", + "path": "SfnRestApiWithoutDefaultMethodResponses/StepFunctionsRestApi/Default/ANY/StartSyncExecutionRole/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" + } + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.2.70" + } + }, + "DefaultPolicy": { + "id": "DefaultPolicy", + "path": "SfnRestApiWithoutDefaultMethodResponses/StepFunctionsRestApi/Default/ANY/StartSyncExecutionRole/DefaultPolicy", + "children": { + "Resource": { + "id": "Resource", + "path": "SfnRestApiWithoutDefaultMethodResponses/StepFunctionsRestApi/Default/ANY/StartSyncExecutionRole/DefaultPolicy/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::IAM::Policy", + "aws:cdk:cloudformation:props": { + "policyDocument": { + "Statement": [ + { + "Action": "states:StartSyncExecution", + "Effect": "Allow", + "Resource": { + "Ref": "StateMachine2E01A3A5" + } + } + ], + "Version": "2012-10-17" + }, + "policyName": "StepFunctionsRestApiANYStartSyncExecutionRoleDefaultPolicy7B6D0CED", + "roles": [ + { + "Ref": "StepFunctionsRestApiANYStartSyncExecutionRole425C03BB" + } + ] + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.2.70" + } + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.2.70" + } + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.2.70" + } + }, + "Resource": { + "id": "Resource", + "path": "SfnRestApiWithoutDefaultMethodResponses/StepFunctionsRestApi/Default/ANY/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::ApiGateway::Method", + "aws:cdk:cloudformation:props": { + "authorizationType": "NONE", + "httpMethod": "ANY", + "integration": { + "type": "AWS", + "uri": { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":apigateway:", + { + "Ref": "AWS::Region" + }, + ":states:action/StartSyncExecution" + ] + ] + }, + "integrationHttpMethod": "POST", + "requestTemplates": { + "application/json": { + "Fn::Join": [ + "", + [ + "## Velocity Template used for API Gateway request mapping template\n##\n## This template forwards the request body, header, path, and querystring\n## to the execution input of the state machine.\n##\n## \"@@\" is used here as a placeholder for '\"' to avoid using escape characters.\n\n#set($inputString = '')\n#set($includeHeaders = false)\n#set($includeQueryString = true)\n#set($includePath = true)\n#set($includeAuthorizer = false)\n#set($allParams = $input.params())\n{\n \"stateMachineArn\": \"", + { + "Ref": "StateMachine2E01A3A5" + }, + "\",\n\n #set($inputString = \"$inputString,@@body@@: $input.body\")\n\n #if ($includeHeaders)\n #set($inputString = \"$inputString, @@header@@:{\")\n #foreach($paramName in $allParams.header.keySet())\n #set($inputString = \"$inputString @@$paramName@@: @@$util.escapeJavaScript($allParams.header.get($paramName))@@\")\n #if($foreach.hasNext)\n #set($inputString = \"$inputString,\")\n #end\n #end\n #set($inputString = \"$inputString }\")\n \n #end\n\n #if ($includeQueryString)\n #set($inputString = \"$inputString, @@querystring@@:{\")\n #foreach($paramName in $allParams.querystring.keySet())\n #set($inputString = \"$inputString @@$paramName@@: @@$util.escapeJavaScript($allParams.querystring.get($paramName))@@\")\n #if($foreach.hasNext)\n #set($inputString = \"$inputString,\")\n #end\n #end\n #set($inputString = \"$inputString }\")\n #end\n\n #if ($includePath)\n #set($inputString = \"$inputString, @@path@@:{\")\n #foreach($paramName in $allParams.path.keySet())\n #set($inputString = \"$inputString @@$paramName@@: @@$util.escapeJavaScript($allParams.path.get($paramName))@@\")\n #if($foreach.hasNext)\n #set($inputString = \"$inputString,\")\n #end\n #end\n #set($inputString = \"$inputString }\")\n #end\n \n #if ($includeAuthorizer)\n #set($inputString = \"$inputString, @@authorizer@@:{\")\n #foreach($paramName in $context.authorizer.keySet())\n #set($inputString = \"$inputString @@$paramName@@: @@$util.escapeJavaScript($context.authorizer.get($paramName))@@\")\n #if($foreach.hasNext)\n #set($inputString = \"$inputString,\")\n #end\n #end\n #set($inputString = \"$inputString }\")\n #end\n\n #set($requestContext = \"\")\n ## Check if the request context should be included as part of the execution input\n #if($requestContext && !$requestContext.empty)\n #set($inputString = \"$inputString,\")\n #set($inputString = \"$inputString @@requestContext@@: $requestContext\")\n #end\n\n #set($inputString = \"$inputString}\")\n #set($inputString = $inputString.replaceAll(\"@@\",'\"'))\n #set($len = $inputString.length() - 1)\n \"input\": \"{$util.escapeJavaScript($inputString.substring(1,$len)).replaceAll(\"\\\\'\",\"'\")}\"\n}\n" + ] + ] + } + }, + "passthroughBehavior": "NEVER", + "integrationResponses": [ + { + "statusCode": "200", + "responseTemplates": { + "application/json": "#set($inputRoot = $input.path('$'))\n#if($input.path('$.status').toString().equals(\"FAILED\"))\n#set($context.responseOverride.status = 500)\n{\n\"error\": \"$input.path('$.error')\",\n\"cause\": \"$input.path('$.cause')\"\n}\n#else\n$input.path('$.output')\n#end" + } + }, + { + "selectionPattern": "4\\d{2}", + "statusCode": "400", + "responseTemplates": { + "application/json": "{\n \"error\": \"Bad request!\"\n }" + } + }, + { + "selectionPattern": "5\\d{2}", + "statusCode": "500", + "responseTemplates": { + "application/json": "\"error\": $input.path('$.error')" + } + } + ], + "credentials": { + "Fn::GetAtt": [ + "StepFunctionsRestApiANYStartSyncExecutionRole425C03BB", + "Arn" + ] + } + }, + "resourceId": { + "Fn::GetAtt": [ + "StepFunctionsRestApiC6E3E883", + "RootResourceId" + ] + }, + "restApiId": { + "Ref": "StepFunctionsRestApiC6E3E883" + } + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.2.70" + } + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.2.70" + } + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.2.70" + } + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.2.70" + } + }, + "ApiEndpoint": { + "id": "ApiEndpoint", + "path": "SfnRestApiWithoutDefaultMethodResponses/ApiEndpoint", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.2.70" + } + }, + "BootstrapVersion": { + "id": "BootstrapVersion", + "path": "SfnRestApiWithoutDefaultMethodResponses/BootstrapVersion", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.2.70" + } + }, + "CheckBootstrapVersion": { + "id": "CheckBootstrapVersion", + "path": "SfnRestApiWithoutDefaultMethodResponses/CheckBootstrapVersion", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.2.70" + } + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.2.70" + } + }, + "sfn-restapi-without-default-method-responses": { + "id": "sfn-restapi-without-default-method-responses", + "path": "sfn-restapi-without-default-method-responses", + "children": { + "DefaultTest": { + "id": "DefaultTest", + "path": "sfn-restapi-without-default-method-responses/DefaultTest", + "children": { + "Default": { + "id": "Default", + "path": "sfn-restapi-without-default-method-responses/DefaultTest/Default", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.2.70" + } + }, + "DeployAssert": { + "id": "DeployAssert", + "path": "sfn-restapi-without-default-method-responses/DefaultTest/DeployAssert", + "children": { + "BootstrapVersion": { + "id": "BootstrapVersion", + "path": "sfn-restapi-without-default-method-responses/DefaultTest/DeployAssert/BootstrapVersion", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.2.70" + } + }, + "CheckBootstrapVersion": { + "id": "CheckBootstrapVersion", + "path": "sfn-restapi-without-default-method-responses/DefaultTest/DeployAssert/CheckBootstrapVersion", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.2.70" + } + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.2.70" + } + } + }, + "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.2.70" + } + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.2.70" + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-apigateway/test/integ.stepfunctions-api-without-default-method-responses.ts b/packages/@aws-cdk-testing/framework-integ/test/aws-apigateway/test/integ.stepfunctions-api-without-default-method-responses.ts new file mode 100644 index 0000000000000..d4ecd0236d74b --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-apigateway/test/integ.stepfunctions-api-without-default-method-responses.ts @@ -0,0 +1,37 @@ +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 { Construct } from 'constructs'; +import * as apigw from 'aws-cdk-lib/aws-apigateway'; + +class SfnRestApiWithoutDefaultMethodResponsesStack extends cdk.Stack { + constructor(scope: Construct) { + super(scope, 'SfnRestApiWithoutDefaultMethodResponses'); + + const passTask = new sfn.Pass(this, 'PassTask', { + result: { value: 'Hello' }, + }); + + const stateMachine = new sfn.StateMachine(this, 'StateMachine', { + definition: passTask, + stateMachineType: sfn.StateMachineType.EXPRESS, + }); + + const api = new apigw.StepFunctionsRestApi(this, 'StepFunctionsRestApi', { + stateMachine: stateMachine, + useDefaultMethodResponses: false, + }); + + new cdk.CfnOutput(this, 'ApiEndpoint', { + value: api.url, + }); + } +} + +const app = new cdk.App(); +const testCase = new SfnRestApiWithoutDefaultMethodResponsesStack(app); + +new IntegTest(app, 'sfn-restapi-without-default-method-responses', { + testCases: [testCase], +}); +app.synth(); diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-apigateway/test/integ.stepfunctions-startexecution-without-default-method-responses.js.snapshot/aws-cdk-aws-apigateway-stepfunctions-startexecution-without-default-method-responses.assets.json b/packages/@aws-cdk-testing/framework-integ/test/aws-apigateway/test/integ.stepfunctions-startexecution-without-default-method-responses.js.snapshot/aws-cdk-aws-apigateway-stepfunctions-startexecution-without-default-method-responses.assets.json new file mode 100644 index 0000000000000..d7a5f69030ae4 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-apigateway/test/integ.stepfunctions-startexecution-without-default-method-responses.js.snapshot/aws-cdk-aws-apigateway-stepfunctions-startexecution-without-default-method-responses.assets.json @@ -0,0 +1,19 @@ +{ + "version": "34.0.0", + "files": { + "8ceb2b359a62fcef8c8d84d394c6af31f4115ac277951fc24570ed06e2099b1d": { + "source": { + "path": "aws-cdk-aws-apigateway-stepfunctions-startexecution-without-default-method-responses.template.json", + "packaging": "file" + }, + "destinations": { + "current_account-current_region": { + "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", + "objectKey": "8ceb2b359a62fcef8c8d84d394c6af31f4115ac277951fc24570ed06e2099b1d.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-apigateway/test/integ.stepfunctions-startexecution-without-default-method-responses.js.snapshot/aws-cdk-aws-apigateway-stepfunctions-startexecution-without-default-method-responses.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-apigateway/test/integ.stepfunctions-startexecution-without-default-method-responses.js.snapshot/aws-cdk-aws-apigateway-stepfunctions-startexecution-without-default-method-responses.template.json new file mode 100644 index 0000000000000..440975f6c6696 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-apigateway/test/integ.stepfunctions-startexecution-without-default-method-responses.js.snapshot/aws-cdk-aws-apigateway-stepfunctions-startexecution-without-default-method-responses.template.json @@ -0,0 +1,258 @@ +{ + "Resources": { + "myrestapiBAC2BF45": { + "Type": "AWS::ApiGateway::RestApi", + "Properties": { + "Name": "my-rest-api" + } + }, + "myrestapiDeployment010A9D4F284640fa221c0b7931c23aed241b95fc": { + "Type": "AWS::ApiGateway::Deployment", + "Properties": { + "Description": "Automatically created by the RestApi construct", + "RestApiId": { + "Ref": "myrestapiBAC2BF45" + } + }, + "DependsOn": [ + "myrestapiGET3A49A218" + ] + }, + "myrestapiDeploymentStageprod3140E1BE": { + "Type": "AWS::ApiGateway::Stage", + "Properties": { + "DeploymentId": { + "Ref": "myrestapiDeployment010A9D4F284640fa221c0b7931c23aed241b95fc" + }, + "RestApiId": { + "Ref": "myrestapiBAC2BF45" + }, + "StageName": "prod" + } + }, + "myrestapiGETStartSyncExecutionRoleC284C05B": { + "Type": "AWS::IAM::Role", + "Properties": { + "AssumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "apigateway.amazonaws.com" + } + } + ], + "Version": "2012-10-17" + } + } + }, + "myrestapiGETStartSyncExecutionRoleDefaultPolicy8B2F6ADF": { + "Type": "AWS::IAM::Policy", + "Properties": { + "PolicyDocument": { + "Statement": [ + { + "Action": "states:StartSyncExecution", + "Effect": "Allow", + "Resource": { + "Ref": "StateMachine2E01A3A5" + } + } + ], + "Version": "2012-10-17" + }, + "PolicyName": "myrestapiGETStartSyncExecutionRoleDefaultPolicy8B2F6ADF", + "Roles": [ + { + "Ref": "myrestapiGETStartSyncExecutionRoleC284C05B" + } + ] + } + }, + "myrestapiGET3A49A218": { + "Type": "AWS::ApiGateway::Method", + "Properties": { + "AuthorizationType": "NONE", + "HttpMethod": "GET", + "Integration": { + "Credentials": { + "Fn::GetAtt": [ + "myrestapiGETStartSyncExecutionRoleC284C05B", + "Arn" + ] + }, + "IntegrationHttpMethod": "POST", + "IntegrationResponses": [ + { + "ResponseTemplates": { + "application/json": "#set($inputRoot = $input.path('$'))\n#if($input.path('$.status').toString().equals(\"FAILED\"))\n#set($context.responseOverride.status = 500)\n{\n\"error\": \"$input.path('$.error')\",\n\"cause\": \"$input.path('$.cause')\"\n}\n#else\n$input.path('$.output')\n#end" + }, + "StatusCode": "200" + }, + { + "ResponseTemplates": { + "application/json": "{\n \"error\": \"Bad request!\"\n }" + }, + "SelectionPattern": "4\\d{2}", + "StatusCode": "400" + }, + { + "ResponseTemplates": { + "application/json": "\"error\": $input.path('$.error')" + }, + "SelectionPattern": "5\\d{2}", + "StatusCode": "500" + } + ], + "PassthroughBehavior": "NEVER", + "RequestTemplates": { + "application/json": { + "Fn::Join": [ + "", + [ + "## Velocity Template used for API Gateway request mapping template\n##\n## This template forwards the request body, header, path, and querystring\n## to the execution input of the state machine.\n##\n## \"@@\" is used here as a placeholder for '\"' to avoid using escape characters.\n\n#set($inputString = '')\n#set($includeHeaders = false)\n#set($includeQueryString = true)\n#set($includePath = true)\n#set($includeAuthorizer = false)\n#set($allParams = $input.params())\n{\n \"stateMachineArn\": \"", + { + "Ref": "StateMachine2E01A3A5" + }, + "\",\n\n #set($inputString = \"$inputString,@@body@@: $input.body\")\n\n #if ($includeHeaders)\n #set($inputString = \"$inputString, @@header@@:{\")\n #foreach($paramName in $allParams.header.keySet())\n #set($inputString = \"$inputString @@$paramName@@: @@$util.escapeJavaScript($allParams.header.get($paramName))@@\")\n #if($foreach.hasNext)\n #set($inputString = \"$inputString,\")\n #end\n #end\n #set($inputString = \"$inputString }\")\n \n #end\n\n #if ($includeQueryString)\n #set($inputString = \"$inputString, @@querystring@@:{\")\n #foreach($paramName in $allParams.querystring.keySet())\n #set($inputString = \"$inputString @@$paramName@@: @@$util.escapeJavaScript($allParams.querystring.get($paramName))@@\")\n #if($foreach.hasNext)\n #set($inputString = \"$inputString,\")\n #end\n #end\n #set($inputString = \"$inputString }\")\n #end\n\n #if ($includePath)\n #set($inputString = \"$inputString, @@path@@:{\")\n #foreach($paramName in $allParams.path.keySet())\n #set($inputString = \"$inputString @@$paramName@@: @@$util.escapeJavaScript($allParams.path.get($paramName))@@\")\n #if($foreach.hasNext)\n #set($inputString = \"$inputString,\")\n #end\n #end\n #set($inputString = \"$inputString }\")\n #end\n \n #if ($includeAuthorizer)\n #set($inputString = \"$inputString, @@authorizer@@:{\")\n #foreach($paramName in $context.authorizer.keySet())\n #set($inputString = \"$inputString @@$paramName@@: @@$util.escapeJavaScript($context.authorizer.get($paramName))@@\")\n #if($foreach.hasNext)\n #set($inputString = \"$inputString,\")\n #end\n #end\n #set($inputString = \"$inputString }\")\n #end\n\n #set($requestContext = \"\")\n ## Check if the request context should be included as part of the execution input\n #if($requestContext && !$requestContext.empty)\n #set($inputString = \"$inputString,\")\n #set($inputString = \"$inputString @@requestContext@@: $requestContext\")\n #end\n\n #set($inputString = \"$inputString}\")\n #set($inputString = $inputString.replaceAll(\"@@\",'\"'))\n #set($len = $inputString.length() - 1)\n \"input\": \"{$util.escapeJavaScript($inputString.substring(1,$len)).replaceAll(\"\\\\'\",\"'\")}\"\n}\n" + ] + ] + } + }, + "Type": "AWS", + "Uri": { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":apigateway:", + { + "Ref": "AWS::Region" + }, + ":states:action/StartSyncExecution" + ] + ] + } + }, + "MethodResponses": [ + { + "ResponseParameters": { + "method.response.header.Access-Control-Allow-Origin": true + }, + "StatusCode": "200" + } + ], + "ResourceId": { + "Fn::GetAtt": [ + "myrestapiBAC2BF45", + "RootResourceId" + ] + }, + "RestApiId": { + "Ref": "myrestapiBAC2BF45" + } + } + }, + "StateMachineRoleB840431D": { + "Type": "AWS::IAM::Role", + "Properties": { + "AssumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "states.amazonaws.com" + } + } + ], + "Version": "2012-10-17" + } + } + }, + "StateMachine2E01A3A5": { + "Type": "AWS::StepFunctions::StateMachine", + "Properties": { + "DefinitionString": "{\"StartAt\":\"passTask\",\"States\":{\"passTask\":{\"Type\":\"Pass\",\"InputPath\":\"$.somekey\",\"End\":true}}}", + "RoleArn": { + "Fn::GetAtt": [ + "StateMachineRoleB840431D", + "Arn" + ] + }, + "StateMachineType": "EXPRESS" + }, + "DependsOn": [ + "StateMachineRoleB840431D" + ], + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" + } + }, + "Outputs": { + "myrestapiEndpoint0DE8A5DE": { + "Value": { + "Fn::Join": [ + "", + [ + "https://", + { + "Ref": "myrestapiBAC2BF45" + }, + ".execute-api.", + { + "Ref": "AWS::Region" + }, + ".", + { + "Ref": "AWS::URLSuffix" + }, + "/", + { + "Ref": "myrestapiDeploymentStageprod3140E1BE" + }, + "/" + ] + ] + } + } + }, + "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-apigateway/test/integ.stepfunctions-startexecution-without-default-method-responses.js.snapshot/awsapigatewaystepfunctionsstartexecutionwithoutdefaultmethodresponsesDefaultTestDeployAssert8B46AA47.assets.json b/packages/@aws-cdk-testing/framework-integ/test/aws-apigateway/test/integ.stepfunctions-startexecution-without-default-method-responses.js.snapshot/awsapigatewaystepfunctionsstartexecutionwithoutdefaultmethodresponsesDefaultTestDeployAssert8B46AA47.assets.json new file mode 100644 index 0000000000000..c71ba1c42e308 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-apigateway/test/integ.stepfunctions-startexecution-without-default-method-responses.js.snapshot/awsapigatewaystepfunctionsstartexecutionwithoutdefaultmethodresponsesDefaultTestDeployAssert8B46AA47.assets.json @@ -0,0 +1,19 @@ +{ + "version": "34.0.0", + "files": { + "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": { + "source": { + "path": "awsapigatewaystepfunctionsstartexecutionwithoutdefaultmethodresponsesDefaultTestDeployAssert8B46AA47.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-apigateway/test/integ.stepfunctions-startexecution-without-default-method-responses.js.snapshot/awsapigatewaystepfunctionsstartexecutionwithoutdefaultmethodresponsesDefaultTestDeployAssert8B46AA47.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-apigateway/test/integ.stepfunctions-startexecution-without-default-method-responses.js.snapshot/awsapigatewaystepfunctionsstartexecutionwithoutdefaultmethodresponsesDefaultTestDeployAssert8B46AA47.template.json new file mode 100644 index 0000000000000..ad9d0fb73d1dd --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-apigateway/test/integ.stepfunctions-startexecution-without-default-method-responses.js.snapshot/awsapigatewaystepfunctionsstartexecutionwithoutdefaultmethodresponsesDefaultTestDeployAssert8B46AA47.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-apigateway/test/integ.stepfunctions-startexecution-without-default-method-responses.js.snapshot/cdk.out b/packages/@aws-cdk-testing/framework-integ/test/aws-apigateway/test/integ.stepfunctions-startexecution-without-default-method-responses.js.snapshot/cdk.out new file mode 100644 index 0000000000000..2313ab5436501 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-apigateway/test/integ.stepfunctions-startexecution-without-default-method-responses.js.snapshot/cdk.out @@ -0,0 +1 @@ +{"version":"34.0.0"} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-apigateway/test/integ.stepfunctions-startexecution-without-default-method-responses.js.snapshot/integ.json b/packages/@aws-cdk-testing/framework-integ/test/aws-apigateway/test/integ.stepfunctions-startexecution-without-default-method-responses.js.snapshot/integ.json new file mode 100644 index 0000000000000..fcdea34c1e26e --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-apigateway/test/integ.stepfunctions-startexecution-without-default-method-responses.js.snapshot/integ.json @@ -0,0 +1,12 @@ +{ + "version": "34.0.0", + "testCases": { + "aws-apigateway-stepfunctions-startexecution-without-default-method-responses/DefaultTest": { + "stacks": [ + "aws-cdk-aws-apigateway-stepfunctions-startexecution-without-default-method-responses" + ], + "assertionStack": "aws-apigateway-stepfunctions-startexecution-without-default-method-responses/DefaultTest/DeployAssert", + "assertionStackName": "awsapigatewaystepfunctionsstartexecutionwithoutdefaultmethodresponsesDefaultTestDeployAssert8B46AA47" + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-apigateway/test/integ.stepfunctions-startexecution-without-default-method-responses.js.snapshot/manifest.json b/packages/@aws-cdk-testing/framework-integ/test/aws-apigateway/test/integ.stepfunctions-startexecution-without-default-method-responses.js.snapshot/manifest.json new file mode 100644 index 0000000000000..15ff4a51e79b8 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-apigateway/test/integ.stepfunctions-startexecution-without-default-method-responses.js.snapshot/manifest.json @@ -0,0 +1,161 @@ +{ + "version": "34.0.0", + "artifacts": { + "aws-cdk-aws-apigateway-stepfunctions-startexecution-without-default-method-responses.assets": { + "type": "cdk:asset-manifest", + "properties": { + "file": "aws-cdk-aws-apigateway-stepfunctions-startexecution-without-default-method-responses.assets.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "aws-cdk-aws-apigateway-stepfunctions-startexecution-without-default-method-responses": { + "type": "aws:cloudformation:stack", + "environment": "aws://unknown-account/unknown-region", + "properties": { + "templateFile": "aws-cdk-aws-apigateway-stepfunctions-startexecution-without-default-method-responses.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}/8ceb2b359a62fcef8c8d84d394c6af31f4115ac277951fc24570ed06e2099b1d.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", + "additionalDependencies": [ + "aws-cdk-aws-apigateway-stepfunctions-startexecution-without-default-method-responses.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": [ + "aws-cdk-aws-apigateway-stepfunctions-startexecution-without-default-method-responses.assets" + ], + "metadata": { + "/aws-cdk-aws-apigateway-stepfunctions-startexecution-without-default-method-responses/my-rest-api/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "myrestapiBAC2BF45" + } + ], + "/aws-cdk-aws-apigateway-stepfunctions-startexecution-without-default-method-responses/my-rest-api/Deployment/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "myrestapiDeployment010A9D4F284640fa221c0b7931c23aed241b95fc" + } + ], + "/aws-cdk-aws-apigateway-stepfunctions-startexecution-without-default-method-responses/my-rest-api/DeploymentStage.prod/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "myrestapiDeploymentStageprod3140E1BE" + } + ], + "/aws-cdk-aws-apigateway-stepfunctions-startexecution-without-default-method-responses/my-rest-api/Endpoint": [ + { + "type": "aws:cdk:logicalId", + "data": "myrestapiEndpoint0DE8A5DE" + } + ], + "/aws-cdk-aws-apigateway-stepfunctions-startexecution-without-default-method-responses/my-rest-api/Default/GET/StartSyncExecutionRole/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "myrestapiGETStartSyncExecutionRoleC284C05B" + } + ], + "/aws-cdk-aws-apigateway-stepfunctions-startexecution-without-default-method-responses/my-rest-api/Default/GET/StartSyncExecutionRole/DefaultPolicy/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "myrestapiGETStartSyncExecutionRoleDefaultPolicy8B2F6ADF" + } + ], + "/aws-cdk-aws-apigateway-stepfunctions-startexecution-without-default-method-responses/my-rest-api/Default/GET/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "myrestapiGET3A49A218" + } + ], + "/aws-cdk-aws-apigateway-stepfunctions-startexecution-without-default-method-responses/StateMachine/Role/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "StateMachineRoleB840431D" + } + ], + "/aws-cdk-aws-apigateway-stepfunctions-startexecution-without-default-method-responses/StateMachine/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "StateMachine2E01A3A5" + } + ], + "/aws-cdk-aws-apigateway-stepfunctions-startexecution-without-default-method-responses/BootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "BootstrapVersion" + } + ], + "/aws-cdk-aws-apigateway-stepfunctions-startexecution-without-default-method-responses/CheckBootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "CheckBootstrapVersion" + } + ] + }, + "displayName": "aws-cdk-aws-apigateway-stepfunctions-startexecution-without-default-method-responses" + }, + "awsapigatewaystepfunctionsstartexecutionwithoutdefaultmethodresponsesDefaultTestDeployAssert8B46AA47.assets": { + "type": "cdk:asset-manifest", + "properties": { + "file": "awsapigatewaystepfunctionsstartexecutionwithoutdefaultmethodresponsesDefaultTestDeployAssert8B46AA47.assets.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "awsapigatewaystepfunctionsstartexecutionwithoutdefaultmethodresponsesDefaultTestDeployAssert8B46AA47": { + "type": "aws:cloudformation:stack", + "environment": "aws://unknown-account/unknown-region", + "properties": { + "templateFile": "awsapigatewaystepfunctionsstartexecutionwithoutdefaultmethodresponsesDefaultTestDeployAssert8B46AA47.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": [ + "awsapigatewaystepfunctionsstartexecutionwithoutdefaultmethodresponsesDefaultTestDeployAssert8B46AA47.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": [ + "awsapigatewaystepfunctionsstartexecutionwithoutdefaultmethodresponsesDefaultTestDeployAssert8B46AA47.assets" + ], + "metadata": { + "/aws-apigateway-stepfunctions-startexecution-without-default-method-responses/DefaultTest/DeployAssert/BootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "BootstrapVersion" + } + ], + "/aws-apigateway-stepfunctions-startexecution-without-default-method-responses/DefaultTest/DeployAssert/CheckBootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "CheckBootstrapVersion" + } + ] + }, + "displayName": "aws-apigateway-stepfunctions-startexecution-without-default-method-responses/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-apigateway/test/integ.stepfunctions-startexecution-without-default-method-responses.js.snapshot/tree.json b/packages/@aws-cdk-testing/framework-integ/test/aws-apigateway/test/integ.stepfunctions-startexecution-without-default-method-responses.js.snapshot/tree.json new file mode 100644 index 0000000000000..039ad63cb7deb --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-apigateway/test/integ.stepfunctions-startexecution-without-default-method-responses.js.snapshot/tree.json @@ -0,0 +1,471 @@ +{ + "version": "tree-0.1", + "tree": { + "id": "App", + "path": "", + "children": { + "aws-cdk-aws-apigateway-stepfunctions-startexecution-without-default-method-responses": { + "id": "aws-cdk-aws-apigateway-stepfunctions-startexecution-without-default-method-responses", + "path": "aws-cdk-aws-apigateway-stepfunctions-startexecution-without-default-method-responses", + "children": { + "my-rest-api": { + "id": "my-rest-api", + "path": "aws-cdk-aws-apigateway-stepfunctions-startexecution-without-default-method-responses/my-rest-api", + "children": { + "Resource": { + "id": "Resource", + "path": "aws-cdk-aws-apigateway-stepfunctions-startexecution-without-default-method-responses/my-rest-api/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::ApiGateway::RestApi", + "aws:cdk:cloudformation:props": { + "name": "my-rest-api" + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.2.70" + } + }, + "Deployment": { + "id": "Deployment", + "path": "aws-cdk-aws-apigateway-stepfunctions-startexecution-without-default-method-responses/my-rest-api/Deployment", + "children": { + "Resource": { + "id": "Resource", + "path": "aws-cdk-aws-apigateway-stepfunctions-startexecution-without-default-method-responses/my-rest-api/Deployment/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::ApiGateway::Deployment", + "aws:cdk:cloudformation:props": { + "description": "Automatically created by the RestApi construct", + "restApiId": { + "Ref": "myrestapiBAC2BF45" + } + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.2.70" + } + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.2.70" + } + }, + "DeploymentStage.prod": { + "id": "DeploymentStage.prod", + "path": "aws-cdk-aws-apigateway-stepfunctions-startexecution-without-default-method-responses/my-rest-api/DeploymentStage.prod", + "children": { + "Resource": { + "id": "Resource", + "path": "aws-cdk-aws-apigateway-stepfunctions-startexecution-without-default-method-responses/my-rest-api/DeploymentStage.prod/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::ApiGateway::Stage", + "aws:cdk:cloudformation:props": { + "deploymentId": { + "Ref": "myrestapiDeployment010A9D4F284640fa221c0b7931c23aed241b95fc" + }, + "restApiId": { + "Ref": "myrestapiBAC2BF45" + }, + "stageName": "prod" + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.2.70" + } + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.2.70" + } + }, + "Endpoint": { + "id": "Endpoint", + "path": "aws-cdk-aws-apigateway-stepfunctions-startexecution-without-default-method-responses/my-rest-api/Endpoint", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.2.70" + } + }, + "Default": { + "id": "Default", + "path": "aws-cdk-aws-apigateway-stepfunctions-startexecution-without-default-method-responses/my-rest-api/Default", + "children": { + "GET": { + "id": "GET", + "path": "aws-cdk-aws-apigateway-stepfunctions-startexecution-without-default-method-responses/my-rest-api/Default/GET", + "children": { + "StartSyncExecutionRole": { + "id": "StartSyncExecutionRole", + "path": "aws-cdk-aws-apigateway-stepfunctions-startexecution-without-default-method-responses/my-rest-api/Default/GET/StartSyncExecutionRole", + "children": { + "ImportStartSyncExecutionRole": { + "id": "ImportStartSyncExecutionRole", + "path": "aws-cdk-aws-apigateway-stepfunctions-startexecution-without-default-method-responses/my-rest-api/Default/GET/StartSyncExecutionRole/ImportStartSyncExecutionRole", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.2.70" + } + }, + "Resource": { + "id": "Resource", + "path": "aws-cdk-aws-apigateway-stepfunctions-startexecution-without-default-method-responses/my-rest-api/Default/GET/StartSyncExecutionRole/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" + } + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.2.70" + } + }, + "DefaultPolicy": { + "id": "DefaultPolicy", + "path": "aws-cdk-aws-apigateway-stepfunctions-startexecution-without-default-method-responses/my-rest-api/Default/GET/StartSyncExecutionRole/DefaultPolicy", + "children": { + "Resource": { + "id": "Resource", + "path": "aws-cdk-aws-apigateway-stepfunctions-startexecution-without-default-method-responses/my-rest-api/Default/GET/StartSyncExecutionRole/DefaultPolicy/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::IAM::Policy", + "aws:cdk:cloudformation:props": { + "policyDocument": { + "Statement": [ + { + "Action": "states:StartSyncExecution", + "Effect": "Allow", + "Resource": { + "Ref": "StateMachine2E01A3A5" + } + } + ], + "Version": "2012-10-17" + }, + "policyName": "myrestapiGETStartSyncExecutionRoleDefaultPolicy8B2F6ADF", + "roles": [ + { + "Ref": "myrestapiGETStartSyncExecutionRoleC284C05B" + } + ] + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.2.70" + } + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.2.70" + } + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.2.70" + } + }, + "Resource": { + "id": "Resource", + "path": "aws-cdk-aws-apigateway-stepfunctions-startexecution-without-default-method-responses/my-rest-api/Default/GET/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::ApiGateway::Method", + "aws:cdk:cloudformation:props": { + "authorizationType": "NONE", + "httpMethod": "GET", + "integration": { + "type": "AWS", + "uri": { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":apigateway:", + { + "Ref": "AWS::Region" + }, + ":states:action/StartSyncExecution" + ] + ] + }, + "integrationHttpMethod": "POST", + "requestTemplates": { + "application/json": { + "Fn::Join": [ + "", + [ + "## Velocity Template used for API Gateway request mapping template\n##\n## This template forwards the request body, header, path, and querystring\n## to the execution input of the state machine.\n##\n## \"@@\" is used here as a placeholder for '\"' to avoid using escape characters.\n\n#set($inputString = '')\n#set($includeHeaders = false)\n#set($includeQueryString = true)\n#set($includePath = true)\n#set($includeAuthorizer = false)\n#set($allParams = $input.params())\n{\n \"stateMachineArn\": \"", + { + "Ref": "StateMachine2E01A3A5" + }, + "\",\n\n #set($inputString = \"$inputString,@@body@@: $input.body\")\n\n #if ($includeHeaders)\n #set($inputString = \"$inputString, @@header@@:{\")\n #foreach($paramName in $allParams.header.keySet())\n #set($inputString = \"$inputString @@$paramName@@: @@$util.escapeJavaScript($allParams.header.get($paramName))@@\")\n #if($foreach.hasNext)\n #set($inputString = \"$inputString,\")\n #end\n #end\n #set($inputString = \"$inputString }\")\n \n #end\n\n #if ($includeQueryString)\n #set($inputString = \"$inputString, @@querystring@@:{\")\n #foreach($paramName in $allParams.querystring.keySet())\n #set($inputString = \"$inputString @@$paramName@@: @@$util.escapeJavaScript($allParams.querystring.get($paramName))@@\")\n #if($foreach.hasNext)\n #set($inputString = \"$inputString,\")\n #end\n #end\n #set($inputString = \"$inputString }\")\n #end\n\n #if ($includePath)\n #set($inputString = \"$inputString, @@path@@:{\")\n #foreach($paramName in $allParams.path.keySet())\n #set($inputString = \"$inputString @@$paramName@@: @@$util.escapeJavaScript($allParams.path.get($paramName))@@\")\n #if($foreach.hasNext)\n #set($inputString = \"$inputString,\")\n #end\n #end\n #set($inputString = \"$inputString }\")\n #end\n \n #if ($includeAuthorizer)\n #set($inputString = \"$inputString, @@authorizer@@:{\")\n #foreach($paramName in $context.authorizer.keySet())\n #set($inputString = \"$inputString @@$paramName@@: @@$util.escapeJavaScript($context.authorizer.get($paramName))@@\")\n #if($foreach.hasNext)\n #set($inputString = \"$inputString,\")\n #end\n #end\n #set($inputString = \"$inputString }\")\n #end\n\n #set($requestContext = \"\")\n ## Check if the request context should be included as part of the execution input\n #if($requestContext && !$requestContext.empty)\n #set($inputString = \"$inputString,\")\n #set($inputString = \"$inputString @@requestContext@@: $requestContext\")\n #end\n\n #set($inputString = \"$inputString}\")\n #set($inputString = $inputString.replaceAll(\"@@\",'\"'))\n #set($len = $inputString.length() - 1)\n \"input\": \"{$util.escapeJavaScript($inputString.substring(1,$len)).replaceAll(\"\\\\'\",\"'\")}\"\n}\n" + ] + ] + } + }, + "passthroughBehavior": "NEVER", + "integrationResponses": [ + { + "statusCode": "200", + "responseTemplates": { + "application/json": "#set($inputRoot = $input.path('$'))\n#if($input.path('$.status').toString().equals(\"FAILED\"))\n#set($context.responseOverride.status = 500)\n{\n\"error\": \"$input.path('$.error')\",\n\"cause\": \"$input.path('$.cause')\"\n}\n#else\n$input.path('$.output')\n#end" + } + }, + { + "selectionPattern": "4\\d{2}", + "statusCode": "400", + "responseTemplates": { + "application/json": "{\n \"error\": \"Bad request!\"\n }" + } + }, + { + "selectionPattern": "5\\d{2}", + "statusCode": "500", + "responseTemplates": { + "application/json": "\"error\": $input.path('$.error')" + } + } + ], + "credentials": { + "Fn::GetAtt": [ + "myrestapiGETStartSyncExecutionRoleC284C05B", + "Arn" + ] + } + }, + "methodResponses": [ + { + "statusCode": "200", + "responseParameters": { + "method.response.header.Access-Control-Allow-Origin": true + } + } + ], + "resourceId": { + "Fn::GetAtt": [ + "myrestapiBAC2BF45", + "RootResourceId" + ] + }, + "restApiId": { + "Ref": "myrestapiBAC2BF45" + } + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.2.70" + } + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.2.70" + } + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.2.70" + } + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.2.70" + } + }, + "passTask": { + "id": "passTask", + "path": "aws-cdk-aws-apigateway-stepfunctions-startexecution-without-default-method-responses/passTask", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.2.70" + } + }, + "StateMachine": { + "id": "StateMachine", + "path": "aws-cdk-aws-apigateway-stepfunctions-startexecution-without-default-method-responses/StateMachine", + "children": { + "Role": { + "id": "Role", + "path": "aws-cdk-aws-apigateway-stepfunctions-startexecution-without-default-method-responses/StateMachine/Role", + "children": { + "ImportRole": { + "id": "ImportRole", + "path": "aws-cdk-aws-apigateway-stepfunctions-startexecution-without-default-method-responses/StateMachine/Role/ImportRole", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.2.70" + } + }, + "Resource": { + "id": "Resource", + "path": "aws-cdk-aws-apigateway-stepfunctions-startexecution-without-default-method-responses/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": "constructs.Construct", + "version": "10.2.70" + } + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.2.70" + } + }, + "Resource": { + "id": "Resource", + "path": "aws-cdk-aws-apigateway-stepfunctions-startexecution-without-default-method-responses/StateMachine/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::StepFunctions::StateMachine", + "aws:cdk:cloudformation:props": { + "definitionString": "{\"StartAt\":\"passTask\",\"States\":{\"passTask\":{\"Type\":\"Pass\",\"InputPath\":\"$.somekey\",\"End\":true}}}", + "roleArn": { + "Fn::GetAtt": [ + "StateMachineRoleB840431D", + "Arn" + ] + }, + "stateMachineType": "EXPRESS" + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.2.70" + } + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.2.70" + } + }, + "BootstrapVersion": { + "id": "BootstrapVersion", + "path": "aws-cdk-aws-apigateway-stepfunctions-startexecution-without-default-method-responses/BootstrapVersion", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.2.70" + } + }, + "CheckBootstrapVersion": { + "id": "CheckBootstrapVersion", + "path": "aws-cdk-aws-apigateway-stepfunctions-startexecution-without-default-method-responses/CheckBootstrapVersion", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.2.70" + } + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.2.70" + } + }, + "aws-apigateway-stepfunctions-startexecution-without-default-method-responses": { + "id": "aws-apigateway-stepfunctions-startexecution-without-default-method-responses", + "path": "aws-apigateway-stepfunctions-startexecution-without-default-method-responses", + "children": { + "DefaultTest": { + "id": "DefaultTest", + "path": "aws-apigateway-stepfunctions-startexecution-without-default-method-responses/DefaultTest", + "children": { + "Default": { + "id": "Default", + "path": "aws-apigateway-stepfunctions-startexecution-without-default-method-responses/DefaultTest/Default", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.2.70" + } + }, + "DeployAssert": { + "id": "DeployAssert", + "path": "aws-apigateway-stepfunctions-startexecution-without-default-method-responses/DefaultTest/DeployAssert", + "children": { + "BootstrapVersion": { + "id": "BootstrapVersion", + "path": "aws-apigateway-stepfunctions-startexecution-without-default-method-responses/DefaultTest/DeployAssert/BootstrapVersion", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.2.70" + } + }, + "CheckBootstrapVersion": { + "id": "CheckBootstrapVersion", + "path": "aws-apigateway-stepfunctions-startexecution-without-default-method-responses/DefaultTest/DeployAssert/CheckBootstrapVersion", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.2.70" + } + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.2.70" + } + } + }, + "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.2.70" + } + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.2.70" + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-apigateway/test/integ.stepfunctions-startexecution-without-default-method-responses.ts b/packages/@aws-cdk-testing/framework-integ/test/aws-apigateway/test/integ.stepfunctions-startexecution-without-default-method-responses.ts new file mode 100644 index 0000000000000..49d5b24ab1379 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-apigateway/test/integ.stepfunctions-startexecution-without-default-method-responses.ts @@ -0,0 +1,44 @@ +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 * as apigw from 'aws-cdk-lib/aws-apigateway'; + +const app = new cdk.App(); +const stack = new cdk.Stack(app, 'aws-cdk-aws-apigateway-stepfunctions-startexecution-without-default-method-responses'); + +const api = new apigw.RestApi(stack, 'my-rest-api'); +const passTask = new sfn.Pass(stack, 'passTask', { + inputPath: '$.somekey', +}); + +const stateMachine: sfn.IStateMachine = new sfn.StateMachine(stack, 'StateMachine', { + definitionBody: sfn.DefinitionBody.fromChainable(passTask), + stateMachineType: sfn.StateMachineType.EXPRESS, +}); + +const methodOptions = { + methodResponses: [ + { + statusCode: '200', + responseParameters: { + 'method.response.header.Access-Control-Allow-Origin': true, + }, + }, + ], +}; + +const integrationOptions = { + useDefaultMethodResponses: false, +}; + +const integ = apigw.StepFunctionsIntegration.startExecution(stateMachine, integrationOptions); + +api.root.addMethod('GET', integ, methodOptions); + +new IntegTest(app, 'aws-apigateway-stepfunctions-startexecution-without-default-method-responses', { + testCases: [ + stack, + ], +}); + +app.synth(); \ No newline at end of file diff --git a/packages/aws-cdk-lib/aws-apigateway/README.md b/packages/aws-cdk-lib/aws-apigateway/README.md index 56e3c33e4104c..d9380f01c9fd3 100644 --- a/packages/aws-cdk-lib/aws-apigateway/README.md +++ b/packages/aws-cdk-lib/aws-apigateway/README.md @@ -140,6 +140,17 @@ Invoking the endpoint with any HTTP method (`GET`, `POST`, `PUT`, `DELETE`, ...) If the execution fails, an HTTP `500` response is returned with the `error` and `cause` from the execution output as the Response Body. If the request is invalid (ex. bad execution input) HTTP code `400` is returned. +To disable default response models generation use the `useDefaultMethodResponses` property: + +```ts +declare const machine: stepfunctions.IStateMachine; + +new apigateway.StepFunctionsRestApi(this, 'StepFunctionsRestApi', { + stateMachine: machine, + useDefaultMethodResponses: false, +}); +``` + The response from the invocation contains only the `output` field from the [StartSyncExecution](https://docs.aws.amazon.com/step-functions/latest/apireference/API_StartSyncExecution.html#API_StartSyncExecution_ResponseSyntax) API. In case of failures, the fields `error` and `cause` are returned as part of the response. diff --git a/packages/aws-cdk-lib/aws-apigateway/lib/integrations/stepfunctions.ts b/packages/aws-cdk-lib/aws-apigateway/lib/integrations/stepfunctions.ts index c843b795ad97a..d37febc7ef807 100644 --- a/packages/aws-cdk-lib/aws-apigateway/lib/integrations/stepfunctions.ts +++ b/packages/aws-cdk-lib/aws-apigateway/lib/integrations/stepfunctions.ts @@ -83,6 +83,13 @@ export interface StepFunctionsExecutionIntegrationOptions extends IntegrationOpt * @default false */ readonly authorizer?: boolean; + + /** + * Whether to add default response models with 200, 400, and 500 status codes to the method. + * + * @default true + */ + readonly useDefaultMethodResponses?: boolean; } /** @@ -111,6 +118,8 @@ export class StepFunctionsIntegration { class StepFunctionsExecutionIntegration extends AwsIntegration { private readonly stateMachine: sfn.IStateMachine; + private readonly useDefaultMethodResponses: boolean; + constructor(stateMachine: sfn.IStateMachine, options: StepFunctionsExecutionIntegrationOptions = {}) { super({ service: 'states', @@ -125,6 +134,7 @@ class StepFunctionsExecutionIntegration extends AwsIntegration { }); this.stateMachine = stateMachine; + this.useDefaultMethodResponses = options.useDefaultMethodResponses ?? true; } public bind(method: Method): IntegrationConfig { @@ -157,8 +167,10 @@ class StepFunctionsExecutionIntegration extends AwsIntegration { deploymentToken = JSON.stringify({ stateMachineName }); } - for (const methodResponse of METHOD_RESPONSES) { - method.addMethodResponse(methodResponse); + if (this.useDefaultMethodResponses) { + for (const methodResponse of METHOD_RESPONSES) { + method.addMethodResponse(methodResponse); + } } return { diff --git a/packages/aws-cdk-lib/aws-apigateway/lib/stepfunctions-api.ts b/packages/aws-cdk-lib/aws-apigateway/lib/stepfunctions-api.ts index 6adfa8674b15f..3175d852920d8 100644 --- a/packages/aws-cdk-lib/aws-apigateway/lib/stepfunctions-api.ts +++ b/packages/aws-cdk-lib/aws-apigateway/lib/stepfunctions-api.ts @@ -96,6 +96,13 @@ export interface StepFunctionsRestApiProps extends RestApiProps { * @default - a new role is created */ readonly role?: iam.IRole; + + /** + * Whether to add default response models with 200, 400, and 500 status codes to the method. + * + * @default true + */ + readonly useDefaultMethodResponses?: boolean; } /** @@ -118,6 +125,7 @@ export class StepFunctionsRestApi extends RestApi { querystring: props.querystring?? true, headers: props.headers, authorizer: props.authorizer, + useDefaultMethodResponses: props.useDefaultMethodResponses, }); super(scope, id, props); diff --git a/packages/aws-cdk-lib/aws-apigateway/test/integrations/stepfunctions.test.ts b/packages/aws-cdk-lib/aws-apigateway/test/integrations/stepfunctions.test.ts index 26b2a34662b09..ce42451222fe0 100644 --- a/packages/aws-cdk-lib/aws-apigateway/test/integrations/stepfunctions.test.ts +++ b/packages/aws-cdk-lib/aws-apigateway/test/integrations/stepfunctions.test.ts @@ -488,6 +488,44 @@ describe('StepFunctionsIntegration', () => { }, }); }); + + test('default method responses are not created when useDefaultMethodResponses is false', () => { + //GIVEN + const { stack, api, stateMachine } = givenSetup(); + + //WHEN + const methodOptions = { + methodResponses: [ + { + statusCode: '200', + responseParameters: { + 'method.response.header.Access-Control-Allow-Origin': true, + }, + }, + ], + }; + + const integrationOptions = { + useDefaultMethodResponses: false, + }; + + const integ = apigw.StepFunctionsIntegration.startExecution(stateMachine, integrationOptions); + api.root.addMethod('GET', integ, methodOptions); + + // THEN + Template.fromStack(stack).resourceCountIs('AWS::ApiGateway::Method', 1); + Template.fromStack(stack).hasResourceProperties('AWS::ApiGateway::Method', { + HttpMethod: 'GET', + MethodResponses: [ + { + ResponseParameters: { + 'method.response.header.Access-Control-Allow-Origin': true, + }, + StatusCode: '200', + }, + ], + }); + }); }); function givenSetup() { diff --git a/packages/aws-cdk-lib/aws-apigateway/test/stepfunctions-api.test.ts b/packages/aws-cdk-lib/aws-apigateway/test/stepfunctions-api.test.ts index b73ec6a54e777..ba295ac7088c0 100644 --- a/packages/aws-cdk-lib/aws-apigateway/test/stepfunctions-api.test.ts +++ b/packages/aws-cdk-lib/aws-apigateway/test/stepfunctions-api.test.ts @@ -1,4 +1,4 @@ -import { Template } from '../../assertions'; +import { Match, Template } from '../../assertions'; import * as sfn from '../../aws-stepfunctions'; import { StateMachine, DefinitionBody } from '../../aws-stepfunctions'; import * as cdk from '../../core'; @@ -157,6 +157,23 @@ describe('Step Functions api', () => { }); }); + test('default method responses are not created when useDefaultMethodResponses is false', () => { + //GIVEN + const { stack, stateMachine } = givenSetup(); + + //WHEN + new apigw.StepFunctionsRestApi(stack, 'StepFunctionsRestApi', { + stateMachine: stateMachine, + useDefaultMethodResponses: false, + }); + + //THEN + Template.fromStack(stack).hasResourceProperties('AWS::ApiGateway::Method', { + HttpMethod: 'ANY', + MethodResponses: Match.absent(), + }); + }); + test('fails if options.defaultIntegration is set', () => { //GIVEN const { stack, stateMachine } = givenSetup();