localstack
localstack copied to clipboard
bug: Unable to invoke StepFunction from API Gateway.
Is there an existing issue for this?
- [X] I have searched the existing issues
Current Behavior
- Insert these code to default cdk project
import * as apigw from "aws-cdk-lib/aws-apigateway";
import * as stepfunctions from "aws-cdk-lib/aws-stepfunctions";
import { Construct } from "constructs";
export class ApiGWStepFns extends Construct {
constructor(scope: Construct, id: string) {
super(scope, id);
const sfn = this.defineSfn(`${id}Sfn`);
this.defineApiGw(sfn);
}
defineSfn = (stateMachineName: string) => {
const step = new stepfunctions.Pass(this, `${stateMachineName}Pass`, {
result: { value: "Hello.World" },
});
const workflow = stepfunctions.Chain.start(step);
const sfn = new stepfunctions.StateMachine(this, stateMachineName, {
stateMachineName,
stateMachineType: stepfunctions.StateMachineType.EXPRESS,
definitionBody: stepfunctions.DefinitionBody.fromChainable(workflow),
});
return sfn;
};
defineApiGw = (sfn: stepfunctions.StateMachine) => {
return new apigw.StepFunctionsRestApi(this, "api", {
stateMachine: sfn,
});
};
}
- cdklocal deploy
- Run
APIID=$(aws --endpoint-url http://127.0.0.1:4566 apigateway get-rest-apis --query "items[*]".id --output text)
curl -X POST \
http://$APIID.execute-api.localhost.localstack.cloud:4566/prod/
- Error {"Type": "User", "message": "Error invoking integration for API Gateway ID '1h0vyqn2i0': An error occurred (StateMachineDoesNotExist) when calling the StartExecution operation: State Machine Does Not Exist: 'arn:aws:states:ap-northeast-1:000000000000:stateMachine:dbWriteSfn'", "__type": "InvalidRequest"}%
Expected Behavior
Show result of step function?
How are you starting LocalStack?
With a docker-compose file
Steps To Reproduce
How are you starting localstack (e.g., bin/localstack command, arguments, or docker-compose.yml)
docker compose up -d
docker-compose.yml
version: "3.8"
services:
localstack:
container_name: "${LOCALSTACK_DOCKER_NAME:-localstack-main}"
image: localstack/localstack
ports:
- "127.0.0.1:4566:4566" # LocalStack Gateway
- "127.0.0.1:4510-4559:4510-4559" # external services port range
environment:
# LocalStack configuration: https://docs.localstack.cloud/references/configuration/
- DEBUG=${DEBUG:-0}
volumes:
- "${LOCALSTACK_VOLUME_DIR:-./volume}:/var/lib/localstack"
- "/var/run/docker.sock:/var/run/docker.sock"
Client commands (e.g., AWS SDK code snippet, or sequence of "awslocal" commands)
curl -X POST http://$APIID.execute-api.localhost.localstack.cloud:4566/prod/
Environment
- OS: macOS 12
- LocalStack: latest (Docker image)
Anything else?
No response
Welcome to LocalStack! Thanks for reporting your first issue and our team will be working towards fixing the issue for you or reach out for more background information. We recommend joining our Slack Community for real-time help and drop a message to LocalStack Pro Support if you are a Pro user! If you are willing to contribute towards fixing this issue, please have a look at our contributing guidelines and our contributing guide.