I'm struggling while implementing an AWS::Serverless::StateMachine with SAM, my workflow is supposed to take much less than 30 seconds and i want to make a Synchronous invocation.
Right now there is an existing feature request on SAM repository: https://github.com/aws/serverless-application-model/discussions/3305 that asks for StartSyncExcecution support.
My approach was creating a default step function and updating it via API (the whole repository is already using SAM and all the lambdas that the step function is going to use too) so changing my IaC main tool is not to consider.
something like this:
aws apigateway update-integration \
--rest-api-id example \
--resource-id example \
--http-method PATCH \
--patch-operations '[
{
"op": "replace",
"path": "/uri",
"value": "arn:aws:apigateway:us-east-1:states:action/StartSyncExecution"
},
{
"op": "replace",
"path": "/requestTemplates/application~1json",
"value": "{\"input\":\"{\\\"path\\\":\\\"$context.path\\\",\\\"httpMethod\\\":\\\"$context.httpMethod\\\",\\\"body\\\":\\\"$util.escapeJavaScript($util.escapeJavaScript($input.json('$')))\\\",\\\"path\\\":\\\"$context.resourcePath\\\",\\\"requestContext\\\":{\\\"authorizer\\\":{\\\"claims\\\":{\\\"cognito:username\\\":\\\"$context.authorizer.claims['cognito:username']\\\"}}}}\",\"stateMachineArn\":\"arn:aws:states:region:account:stateMachine:example\"}"
}
]'
next problem was CORS for PATCH and POSTS
the following configuration worked via console (but i cannot use it, everything should be configured by ci/cd):
I am trying not to do updates via API since it is less maintainable, but for the previous update i had no choice (far as I know) So if there is no option, then what does it matter?
the question here is: how to configure CORS for this? there is an easy way to do it with SAM? if you ever did this with the API can you share an example?
