问题描述
为了稍微解释一下我的问题,我使用了适用于VS Code的AWS工具包,并且我一直在研究10 minute tutorial,以同时学习步骤功能,SAM和其他一些知识。成功完成part 1: simply doing the tutorial和part 2: combining Lambda and Step Functions之后,我现在决定开始第3步,包括API网关和前端S3存储桶。我可以在控制台中完成所有这些工作,并且除了一件事之外,还可以使用适用于VS Code的AWS Toolkit使其工作。创建状态机后,将使用事件将其链接到API网关。这会自动创建一个IAM角色,以便API网关可以启动状态机。我为此创建了一个单独的角色,该角色在创建后在API网关中使用,并且像一个饰物一样工作。但是,原始的API事件角色仍在创建中。它没有被使用,我可以安全地删除它而不会影响任何东西。
我的问题是,我是否要监督一切,或者这是一个错误,如果是,我该怎么办?
就我而言,这是相关的Yaml,如果您需要更多,请告诉我:
StateMachine:
CallCenterStateMachine:
Type: AWS::Serverless::StateMachine
Properties:
DeFinitionUri: statemachines/CallCenterStateMachine.asl.json
DeFinitionSubstitutions:
OpenCaseFunctionArn: !GetAtt OpenCaseFunction.Arn
AssignCaseFunctionArn: !GetAtt AssignCaseFunction.Arn
WorkOnCaseFunctionArn: !GetAtt WorkOnCaseFunction.Arn
CloseCaseFunctionArn: !GetAtt CloseCaseFunction.Arn
EscalateCaseFunctionArn: !GetAtt EscalateCaseFunction.Arn
Role: !GetAtt CallCenterBasicStepFunctionsRole.Arn
Events:
APIEvent:
Type: Api
Properties:
Path: /case
Method: post
RestApiId: !Ref CallCenteraPI
API网关:
CallCenteraPI:
Type: AWS::Serverless::Api
Properties:
StageName: prod
Cors:
AllowMethods: "'POST,GET,OPTIONS,HEAD'"
AllowHeaders: "'*'"
AllowOrigin: "'*'"
GatewayResponses:
DEFAULT_4xx:
ResponseParameters:
Headers:
Access-Control-Allow-Origin: "'*'"
Access-Control-Allow-Methods: "'POST,OPTIONS'"
Access-Control-Allow-Headers: "'*'"
DEFAULT_5xx:
ResponseParameters:
Headers:
Access-Control-Allow-Origin: "'*'"
Access-Control-Allow-Methods: "'POST,OPTIONS'"
Access-Control-Allow-Headers: "'*'"
DeFinitionBody:
swagger: "2.0"
info:
title: "sam-callcenterwebapp"
paths:
/case:
post:
consumes:
- "application/json"
responses:
"200":
description: "200 response"
headers:
Access-Control-Allow-Origin:
type: "string"
"400":
description: "400 response"
x-amazon-apigateway-integration:
credentials: !GetAtt CallCenteraPIGatewayRole.Arn
uri:
Fn::Sub: "arn:aws:apigateway:${AWS::Region}:states:action/StartExecution"
responses:
"200":
statusCode: "200"
responseParameters:
method.response.header.Access-Control-Allow-Origin: "'*'"
"400":
statusCode: "400"
requestTemplates:
application/json:
Fn::Sub: "{\"input\": \"$util.escapeJavaScript($input.json('$'))\"\,\"stateMachineArn\": \"${CallCenterStateMachine.Arn}\"\
}"
passthroughBehavior: "when_no_match"
httpMethod: "POST"
type: "aws"
options:
consumes:
- "application/json"
produces:
- "application/json"
responses:
"200":
description: "200 response"
headers:
Access-Control-Allow-Origin:
type: "string"
Access-Control-Allow-Methods:
type: "string"
Access-Control-Allow-Headers:
type: "string"
x-amazon-apigateway-integration:
responses:
default:
statusCode: "200"
responseParameters:
method.response.header.Access-Control-Allow-Methods: "'OPTIONS,POST'"
method.response.header.Access-Control-Allow-Headers: "'Content-Type,X-Amz-Date,Authorization,X-Api-Key,X-Amz-Security-Token'"
method.response.header.Access-Control-Allow-Origin: "'*'"
responseTemplates:
application/json: "{}\n"
requestTemplates:
application/json: "{\n \"statusCode\" : 200\n}\n"
passthroughBehavior: "when_no_match"
type: "mock"
以及IAM角色:
CallCenteraPIGatewayRole:
Type: AWS::IAM::Role
Properties:
Description: "API Gateway role. Allows to invoke Step Functions state machine. "
RoleName: !Join
- ''
- - !Ref AWS::StackName
- '-'
- !Ref AWS::Region
- '-'
- CallCenteraPIGatewayRole
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
-
Effect: Allow
Principal:
Service:
- 'apigateway.amazonaws.com'
Action:
- 'sts:AssumeRole'
Policies:
-
PolicyName: 'StateMachine-StartExecution'
PolicyDocument:
Version: '2012-10-17'
Statement:
-
Effect: Allow
Action:
- 'states:StartExecution'
Resource: !GetAtt CallCenterStateMachine.Arn
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)