-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(apigateway): add useDefaultMethodResponses property for StepFunc…
…tionsIntegrations (#27645) In `StepFunctionsIntegration`, method response models (`methodResponses`) with 200, 400 and 500 status codes are added by default. This PR adds `useDefaultMethodResponses` property not to add default method response models by set it to `false`. Closes #27520. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
- Loading branch information
Showing
23 changed files
with
2,148 additions
and
3 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
...-default-method-responses.js.snapshot/SfnRestApiWithoutDefaultMethodResponses.assets.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
276 changes: 276 additions & 0 deletions
276
...efault-method-responses.js.snapshot/SfnRestApiWithoutDefaultMethodResponses.template.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<String>", | ||
"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." | ||
} | ||
] | ||
} | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
...gateway/test/integ.stepfunctions-api-without-default-method-responses.js.snapshot/cdk.out
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
12 changes: 12 additions & 0 deletions
12
...eway/test/integ.stepfunctions-api-without-default-method-responses.js.snapshot/integ.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.