-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(apigateway): add useDefaultMethodResponses property for StepFunctionsIntegrations #27645
Changes from 5 commits
f4a4724
cd34e90
80c9a75
2ef1079
f641b81
e6617fb
28f60f2
dd49136
5fa96b6
257285a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<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." | ||
} | ||
] | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Redundant.