gpt4 book ai didi

amazon-web-services - 无法使用 CloudFormation 让 API 代理与 SQS 配合使用

转载 作者:行者123 更新时间:2023-12-03 07:30:51 26 4
gpt4 key购买 nike

我正在关注this tutorial我可以使用控制台让一切正常工作。我已将 SQS 队列和 API 创建转换为 CloudFormation,但无法使 API 方法集成正常工作。我已经使用Former2将工作方法转换为CloudFormation(如下所示),但我仍然收到此错误:

Invalid mapping expression specified: Validation Result: 
warnings : [],
errors : [Invalid mapping expression specified: application/x-www-form-urlencoded]
(Service: AmazonApiGateway; Status Code: 400; Error Code: BadRequestException;
Request ID: 1e40fc86-af05-4698-a91a-c1fa8930ee10; Proxy: null)

我的 POST 方法的 CloudFormation 模板如下:

  ApiPostMsgMethod:
DependsOn: 'SqsQueue'
Type: AWS::ApiGateway::Method
Properties:
ApiKeyRequired: false
AuthorizationType: NONE
HttpMethod: POST
Integration:
Credentials: !GetAtt ApiSqsSendMsgRole.Arn
IntegrationHttpMethod: POST
IntegrationResponses:
- StatusCode: '200'
PassthroughBehavior: NEVER
RequestParameters:
integration.request.header.Content-Type: 'application/x-www-form-urlencoded'
RequestTemplates:
application/json : 'Action=SendMessage&MessageBody=$input.body'
TimeoutInMillis: 1200
Type: AWS
Uri: !Join
- ""
- - !Sub "arn:aws:apigateway:${AWS::Region}:sqs:path/${AWS::AccountId}/"
- !Sub ${EnvironmentName}-queue
MethodResponses:
- StatusCode: 200
OperationName: PostSqsItem
ResourceId: !Ref SqsResource
RestApiId: !Ref SqsRestApi

Former2 从工作 POST 方法返回以下模板:

    httpMethod: POST
authorizationType: NONE
apiKeyRequired: false
requestParameters: <empty object>
methodResponses:
200:
statusCode: 200
responseModels:
application/json: Empty
methodIntegration:
type: AWS
httpMethod: POST
uri: arn:aws:apigateway:###:sqs:path/###/###
credentials: arn:aws:iam::###:role/###
requestParameters:
integration.request.header.Content-Type: 'application/x-www-form-urlencoded'
requestTemplates:
application/json: Action=SendMessage&MessageBody=$input.body
passthroughBehavior: NEVER
timeoutInMillis: 29000
cacheNamespace: ###
integrationResponses:
200:
statusCode: 200
responseTemplates:

restApiId: ###
resourceId: ###

我的引用和替换似乎有效,但我仍然收到此集成错误。我错过了什么吗?

最佳答案

我认为在我看来,麻烦是从这里来的

integration.request.header.Content-Type: 'application/x-www-form-urlencoded'

应该是这样的

integration.request.header.Content-Type: "'application/x-www-form-urlencoded'"

关于amazon-web-services - 无法使用 CloudFormation 让 API 代理与 SQS 配合使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66753261/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com