AWS Cloudformation -属性验证失败:[属性{/RequestParameters/MessageAtt



我一直在努力了解如何克服这个错误:

Property validation failure: [Value of property {/RequestParameters/MessageAttributes} does not match type {String}]

正在讨论的云形成资源是:

HttpApiPayloadRouteIntegration:
Type: AWS::ApiGatewayV2::Integration
Properties:
ApiId: !Ref HttpApi
Description: Proxy incoming HTTP Payload into SQS
IntegrationType: AWS_PROXY
IntegrationSubtype: SQS-SendMessage
PayloadFormatVersion: "1.0"
CredentialsArn: !GetAtt HttpApiRole.Arn
RequestParameters:
QueueUrl: !Ref HTTPApiEventQueue
MessageBody: $request.body
MessageGroupId: $request.body.repository.full_name
MessageDeduplicationId:
!Join [
"-",
[$request.body.repository.full_name, $request.body.alert.number],
]
MessageAttributes:
- firstAttribute:
DataType: String
StringValue: hello world
- secondAttribute:
DataType: String
StringValue: goodbye world

错误发生在这里:

MessageAttributes:
- firstAttribute:
DataType: String
StringValue: hello world
- secondAttribute:
DataType: String
StringValue: goodbye world

I have try:

MessageAttributes:
firstAttribute:
DataType: String
StringValue: hello world
secondAttribute:
DataType: String
StringValue: goodbye world
MessageAttributes:
- firstAttribute:
DataType: String
StringValue: hello world
- secondAttribute:
DataType: String
StringValue: goodbye world
MessageAttributes:
firstAttribute:
Name: firstAttribute
Type: String
Value: hello world
secondAttribute:
Name: secondAttribute
Type: String
Value: goodbye world
我的问题是……如何在yaml云形成模板中发送MessageAttributes ?

AWS文档在这里说,在YAML模板中,属性RequestParameters像JSON一样被解析。

这里有一个YAML模板示例:

MyIntegration:
Type: AWS::ApiGatewayV2::Integration
Properties:
ApiId: !Ref MyApi
Description: HTTP proxy integration
IntegrationType: HTTP_PROXY
IntegrationMethod: ANY
IntegrationUri: https://api.example.com
PayloadFormatVersion: 1.0
RequestParameters:
"append:header.header1": "$context.requestId"
ResponseParameters:
"200":
ResponseParameters:
- Source: "headerValue"
Destination: "append:header.header2" 

CLI示例:

aws apigatewayv2 create-integration 
--api-id abcdef123 
--integration-subtype SQS-SendMessage 
--integration-type AWS_PROXY 
--payload-format-version 1.0 
--credentials-arn arn:aws:iam::123456789012:role/apigateway-sqs 
--request-parameters '{"QueueUrl": "$request.header.queueUrl", "MessageBody": "$request.body.message"}'

看起来Request Parameters一直是JSON格式的映射

最新更新