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ヶ月前240ビュー
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)

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ