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.
- 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 ]
- 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.