Parameterize list of replica regions in DynamoDB SAM Template

0

I am trying to parameterize value of regions in Replica/Region property of DynamoDB SAM Template using 2 methods - one using sam toml file, another with hardcoded values.

  1. Using samconfig.toml as:
  • parameter-overrides section to have "ddbregionlist="us-east-1,us-east-2""
  • template.yml to have
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: SAM Template for deployment of DynamoDB resources

Parameters:
  ddbregionlist:
    Type: CommaDelimitedList
    Default: "us-east-1, us-east-2"

Resources:
  #-------------------** DynamoDB Table **--------------------

  DDBTable:
    Type: AWS::DynamoDB::GlobalTable
    Properties:
      TableName: ddbtable
      AttributeDefinitions:
        - AttributeName: "id"
          AttributeType: "S"
      KeySchema:
        - AttributeName: "id"
          KeyType: "HASH"
      BillingMode: "PAY_PER_REQUEST"
      StreamSpecification: 
        StreamViewType: NEW_AND_OLD_IMAGES
      Replicas:
        - Region: !Select [ 0, !Ref ddbregionlist ]
        - Region: !Select [ 1, !Ref ddbregionlist ]
  1. With direct hardcoded values for Replica Regions - everything same template as above with difference as below -
Replicas:
        - Region: !Select [ 0, [ "us-east-1", "us-east-2" ] ]
        - Region: !Select [ 1, [ "us-east-1", "us-east-2" ] ]

None of the above methods is working and here the portion of log which I am seeing.

Unable to resolve property Region: OrderedDict([('Fn::Select', ['0', ['us-east-1', 'us-east-2']])]). Leaving as is.

Resource handler returned message: "Resource of type 'AWS::DynamoDB::GlobalTable' with identifier 'ddbtable' did not stabilize." (RequestToken: <....>, HandlerErrorCode: NotStabilized)

Possibly, samconfig values are not getting passed, however, hardcoded values in #2 should have worked as per this link - [https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-select.html].

I suppose, I am using correct syntax. Can someone please help me resolve this ? Thanks in advance.

  • Hi, your template is hardly readable. You should update your question and use the Code Block formatter (see the button with </> logo) to keep your yaml properly structured.

  • Updated question. Hope its fine now.

  • Yes, thank you. It is now much more readable for people willing to answer your question.

Mani
질문됨 5달 전238회 조회
1개 답변
0

Hi,

Thanks for the formatting of the question.

Your problem may come from the fact that you specify the indices as strings "0", "1" while they should be integers 0,1 when in YAML as per documentation: see section "Comma-delimited list parameter type" of https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/parameters-section-structure.html

Best,

Didier

profile pictureAWS
전문가
답변함 5달 전
  • Thanks Didier! I realized it was a miss and using integer indexes worked. However, this did not resolve the main error. I suppose the error comes, if we are passing some wrong value for resource creation. Could you please suggest what could be wrong in my template ? I have updated the code using integer values.

    Error: Resource handler returned message: "Resource of type 'AWS::DynamoDB::GlobalTable' with identifier 'ddbtable' did not stabilize." (RequestToken: <......>, HandlerErrorCode: NotStabilized)

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠