-
Notifications
You must be signed in to change notification settings - Fork 4.4k
"Calling API gateway using Stepfunctions" feature is not properly supported by CDK, when using CallApiGatewayRestApiEndpoint #14184
Description
We are trying to use the CallApiGatewayRestApiEndpoint construct with WAIT_FOR_TASK_TOKEN integration pattern. Per the AWS docs on the contract, we need to specify the headers like this:
"Headers": { "TaskToken.$": "States.Array($$.Task.Token)" }
However, we're not sure how to do that with the CallApiGatewayRestApiEndpoint construct. We tried something like this, which would generate the expected headers:
headers = aws_stepfunctions.TaskInput.from_object({
"TaskToken.$":"States.Array($$.Task.Token)"
})
step1 = aws_stepfunctions_tasks.CallApiGatewayRestApiEndpoint(
self.wf.stack, "APIGW",
api=rest_api,
method=HttpMethod.POST,
stage_name="prod",
headers=headers,
integration_pattern=aws_stepfunctions.IntegrationPattern.REQUEST_RESPONSE,
auth_type=aws_stepfunctions_tasks.AuthType.IAM_ROLE
)
but when we set IntegrationPattern to WAIT_FOR_TASK_TOKEN, CDK complains that task token is missing:
Task Token is required in headers for WAIT_FOR_TASK_TOKEN pattern. Use JsonPath.taskToken to set the token.
But if we make the value of the header field a string instead of list/array, then CDK wouldn't raise an error. however when we execute this state machine, step functions would complain that the format of header field is incorrect.
headers = aws_stepfunctions.TaskInput.from_object({
"TaskToken.$":"$$.Task.Token"
})
step1 = aws_stepfunctions_tasks.CallApiGatewayRestApiEndpoint(
self.wf.stack, "APIGW",
api=rest_api,
method=HttpMethod.POST,
stage_name="prod",
headers=headers,
integration_pattern=aws_stepfunctions.IntegrationPattern.WAIT_FOR_TASK_TOKEN,
auth_type=aws_stepfunctions_tasks.AuthType.IAM_ROLE
)
Reproduction Steps
Described above
What did you expect to happen?
CDK shouldn't complain when we pass Task Token using States.Array within headers and when we use WAIT_FOR_TASK_TOKEN pattern.
What actually happened?
Seems like for calling API gateway using stepfunctions, we need to pass task token within array inside the header. But CDK doesn't detect task token if we do this way. Also, note that CDK currently doesn't support intrinsic functions (Such as States.Array).
Environment
- CDK CLI Version : 1.98.0
- Framework Version: 1.98.0
- Node.js Version: v14.6.0
- OS : Linux
- Language (Version): Python (3.7.3)
This is 🐛 Bug Report