I am trying to test a step function locally. I have defined my stateMachine.json and added my credentials (aws_access_key_id and aws_secret_access_key) with aws configure
.
I am following this steps to run the state machine: https://docs.aws.amazon.com/step-functions/latest/dg/sfn-local-lambda.html. But when I start the execution I get this error:
2021-08-08 05:37:56.464: arn:aws:states:us-east-1:123456789012:execution:StateMachine:firstTest : {"Type":"LambdaFunctionFailed","PreviousEventId":4,"LambdaFunctionFailedEventDetails":{"Error":"Lambda.AWSLambdaException","Cause":"The security token included in the request is invalid. (Service: AWSLambda; Status Code: 403; Error Code: UnrecognizedClientException; Request ID: 66622740-bcbc-4397-8c97-75454dca550d; Proxy: null)"}}
Which can be the error?
You need to set environmental variable LAMBDA_ENDPOINT
as host.docker.internal
.
At Step 3, you run this command:
sam local start-lambda
The output is like:
...
* Running on http://127.0.0.1:3001/ (Press CTRL+C to quit)
Remember 3001
, this will be used below.
Then, refer to Step Functions Local configuration options.
It says, aws-stepfunctions-local-credentials.txt
contains credentials.
Include LAMBDA_ENDPOINT=http://host.docker.internal:3001
.
Example of credential file:
AWS_ACCOUNT_ID= ...
AWS_DEFAULT_REGION= ...
AWS_ACCESS_KEY_ID= ...
AWS_SECRET_ACCESS_KEY= ...
LAMBDA_ENDPOINT=http://host.docker.internal:3001