amazon-web-servicesamazon-dynamodbaws-cloudformationamazon-kinesis

Add kinesis stream into DynamoDB Global table


I can able to add manually kinesis stream to DynamoDB Global Table for each region .I am keeping the stream as region specific .While adding using Cloudformation template getting error "Resource handler returned message: "Invalid request provided: To enable Kinesis Data Stream in DynamoDBTable, both the stream and table must be in the same region."

The CFT I am using for creation is ,

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'
  FlightInfoStream:
    Description: "Flight info service kinesis stream arn"
    Type: "AWS::SSM::Parameter::Value<String>"
    Default: /flightinfo/kinesis/arn       
  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 FlightInfoStream    
        PointInTimeRecoverySpecification: 
          PointInTimeRecoveryEnabled: true        
      - Region: !Ref AWSReplicatedRegion
        KinesisStreamSpecification:
          StreamArn: !Ref FlightInfoStream      
        PointInTimeRecoverySpecification: 
          PointInTimeRecoveryEnabled: true

if we can attached the kinesis stream that is region specific to global DynamoDB for both the region that would be great !


Solution

  • You tried to pass the same stream ARN into both regions, which will not work. Ensure that you pass the correct stream ARN into each replica, for that given region:

          Replicas:
          - Region: !Ref AWSCurrentRegion
            KinesisStreamSpecification:
              StreamArn: <stream arn from  us-east-1 >    
            PointInTimeRecoverySpecification: 
              PointInTimeRecoveryEnabled: true        
          - Region: !Ref AWSReplicatedRegion
            KinesisStreamSpecification:
              StreamArn: <stream arn from  us-west-2 >     
            PointInTimeRecoverySpecification: 
              PointInTimeRecoveryEnabled: true