CloudFormation配置DynamoDB全局表绑定区域Kinesis流报错排查
解决DynamoDB全局表绑定跨区域Kinesis流的CloudFormation报错
错误根源
报错信息**"Invalid request provided: To enable Kinesis Data Stream in DynamoDBTable, both the stream and table must be in the same region."**的核心原因是:你的模板中两个区域的全局表副本都引用了同一个FlightInfoStream参数对应的Kinesis流ARN——这个流仅属于其中一个区域,导致另一个区域的表副本与流跨区域,违反了DynamoDB的强制要求(流必须与绑定的表副本处于同一区域)。
修正方案
你需要为两个区域分别提供对应区域的Kinesis流ARN,修改后的CloudFormation模板如下:
AWSTemplateFormatVersion: "2010-09-09" Description: 'AWS CloudFormation Template for DynamoDB tables For Flight Information Service' Parameters: flightInformation: Type: String Description: Select dynamodb table name Default: FlightInformationtest BillingMode: Description: Provisioned scaling mode Type: String Default: 'PAY_PER_REQUEST' AllowedValues: - 'PROVISIONED' - 'PAY_PER_REQUEST' # 新增:主区域对应的Kinesis流ARN参数 FlightInfoStreamCurrentRegion: Description: "Flight info service kinesis stream ARN for current region" Type: "AWS::SSM::Parameter::Value<String>" Default: /flightinfo/kinesis/arn-us-east-1 # 新增:副本区域对应的Kinesis流ARN参数 FlightInfoStreamReplicatedRegion: Description: "Flight info service kinesis stream ARN for replicated region" Type: "AWS::SSM::Parameter::Value<String>" Default: /flightinfo/kinesis/arn-us-west-2 AWSCurrentRegion: Type: String Default: us-east-1 AWSReplicatedRegion: Type: String Default: us-west-2 CFNStreamName: Description: This will be used to name the Kinesis DataStream Type: String Default: 'BDT-Flightinfo-Stream' CFNRetensionHours: Description: This will be used to set the retension hours Type: Number Default: 48 Resources: FlightInformation: Type: AWS::DynamoDB::GlobalTable Properties: TableName: !Ref flightInformation BillingMode: !Ref BillingMode AttributeDefinitions: - AttributeName: "partitionKey" AttributeType: "S" - AttributeName: "sortKey" AttributeType: "S" KeySchema: - AttributeName: "partitionKey" KeyType: "HASH" - AttributeName: "sortKey" KeyType: "RANGE" StreamSpecification: StreamViewType: NEW_AND_OLD_IMAGES SSESpecification: SSEEnabled: true SSEType: "KMS" Replicas: - Region: !Ref AWSCurrentRegion KinesisStreamSpecification: StreamArn: !Ref FlightInfoStreamCurrentRegion # 绑定主区域的流 PointInTimeRecoverySpecification: PointInTimeRecoveryEnabled: true - Region: !Ref AWSReplicatedRegion KinesisStreamSpecification: StreamArn: !Ref FlightInfoStreamReplicatedRegion # 绑定副本区域的流 PointInTimeRecoverySpecification: PointInTimeRecoveryEnabled: true
额外说明
- 你需要提前在SSM参数存储中创建两个区域的Kinesis流ARN参数(比如示例中的
/flightinfo/kinesis/arn-us-east-1和/flightinfo/kinesis/arn-us-west-2),确保每个参数对应的流与目标区域完全一致。 - 如果需要通过CloudFormation自动创建两个区域的Kinesis流,可以结合嵌套栈(
AWS::CloudFormation::Stack)分别在对应区域部署流资源,再将生成的ARN传递给全局表的副本配置。
内容的提问来源于stack exchange,提问作者Chintamani
相关产品推荐
相关产品推荐

