"local" Step Functions 状态机在主机上调用 moto_server 时出现 404 错误
404 Error with "local" Step Functions State Machine calling moto_server on host
在“本地”模式下使用 AWS Step Functions 状态机 (SFSM),即在我的笔记本电脑 Docker 中 运行ning
正在尝试 运行 一个指向我笔记本电脑主机上模拟服务的任务
我可以在 Docker 上正确安装 SFSM,更新它,运行 它
aws stepfunctions --endpoint http://localhost:8083 create-state-machine \
--definition file://src/my_sfn.json \
--role-arn 'arn:aws:iam::ACCTNUM:role/DummyRole' \
--name my_sfn
我可以从 docker 运行 curl http://host.docker.internal:5000
连接到 moto_server
我在 SFSM 容器上安装了 aws cli,运行 aws sns --endpoint http://host.docker.internal:5000 list-topics
它显示了正确的主题
我在我的 docker env 文件中设置 SNS_ENDPOINT url 以指向主机
但是如果运行使用 SFSM:
我总是会收到 404 Not Found 错误
2021-03-04 18:59:24.472: arn:aws:states:us-east-1:ACCTNUM:execution:my_sfn:7151fcf4-7e6f-4b16-9b64-2ac913e27e4c : {"Type":"TaskSubmitFailed","PreviousEventId":4,"TaskSubmitFailedEventDetails":{"ResourceType":"sns","Resource":"publish","Error":"SNS.AmazonSNSException","Cause":"null (Service: AmazonSNS; Status Code: 404; Error Code: 404 NOT FOUND; Request ID: null; Proxy: null)"}}
2021-03-04 18:59:24.473: arn:aws:states:us-east-1:ACCTNUM:execution:my_sfn:7151fcf4-7e6f-4b16-9b64-2ac913e27e4c : {"Type":"ExecutionFailed","PreviousEventId":5,"ExecutionFailedEventDetails":{"Error":"SNS.AmazonSNSException","Cause":"null (Service: AmazonSNS; Status Code: 404; Error Code: 404 NOT FOUND; Request ID: null; Proxy: null)"}}
my_sfn.json:
{
"StartAt": "step1",
"States": {
"step1": {
"Type": "Task",
"Resource": "arn:aws:states:::sns:publish",
"Parameters":{
"Message":{"Input":"howdy"},
"TopicArn":"arn:aws:sns:us-west-2:ACCTNUM:foo"
},
"End": true
}
}
}
docker-env.txt:
SNS_ENDPOINT=http://host.docker.internal:5000
知道如何解决吗?
看来我必须向环境文件添加更多信息:
AWS_ACCOUNT_ID=123456789012
AWS_ACCESS_KEY_ID=AAAAAAAAAAAAAAAA
AWS_SECRET_ACCESS_KEY=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AWS_DEFAULT_REGION=us-west-2
始终使用相同的帐户 ID 和区域,并且有效
在“本地”模式下使用 AWS Step Functions 状态机 (SFSM),即在我的笔记本电脑 Docker 中 运行ning
正在尝试 运行 一个指向我笔记本电脑主机上模拟服务的任务
我可以在 Docker 上正确安装 SFSM,更新它,运行 它
aws stepfunctions --endpoint http://localhost:8083 create-state-machine \
--definition file://src/my_sfn.json \
--role-arn 'arn:aws:iam::ACCTNUM:role/DummyRole' \
--name my_sfn
我可以从 docker 运行 curl http://host.docker.internal:5000
连接到 moto_server
我在 SFSM 容器上安装了 aws cli,运行 aws sns --endpoint http://host.docker.internal:5000 list-topics
它显示了正确的主题
我在我的 docker env 文件中设置 SNS_ENDPOINT url 以指向主机
但是如果运行使用 SFSM:
我总是会收到 404 Not Found 错误2021-03-04 18:59:24.472: arn:aws:states:us-east-1:ACCTNUM:execution:my_sfn:7151fcf4-7e6f-4b16-9b64-2ac913e27e4c : {"Type":"TaskSubmitFailed","PreviousEventId":4,"TaskSubmitFailedEventDetails":{"ResourceType":"sns","Resource":"publish","Error":"SNS.AmazonSNSException","Cause":"null (Service: AmazonSNS; Status Code: 404; Error Code: 404 NOT FOUND; Request ID: null; Proxy: null)"}}
2021-03-04 18:59:24.473: arn:aws:states:us-east-1:ACCTNUM:execution:my_sfn:7151fcf4-7e6f-4b16-9b64-2ac913e27e4c : {"Type":"ExecutionFailed","PreviousEventId":5,"ExecutionFailedEventDetails":{"Error":"SNS.AmazonSNSException","Cause":"null (Service: AmazonSNS; Status Code: 404; Error Code: 404 NOT FOUND; Request ID: null; Proxy: null)"}}
my_sfn.json:
{
"StartAt": "step1",
"States": {
"step1": {
"Type": "Task",
"Resource": "arn:aws:states:::sns:publish",
"Parameters":{
"Message":{"Input":"howdy"},
"TopicArn":"arn:aws:sns:us-west-2:ACCTNUM:foo"
},
"End": true
}
}
}
docker-env.txt:
SNS_ENDPOINT=http://host.docker.internal:5000
知道如何解决吗?
看来我必须向环境文件添加更多信息:
AWS_ACCOUNT_ID=123456789012
AWS_ACCESS_KEY_ID=AAAAAAAAAAAAAAAA
AWS_SECRET_ACCESS_KEY=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AWS_DEFAULT_REGION=us-west-2
始终使用相同的帐户 ID 和区域,并且有效