How to get streamArn of a manually created dynamodb table in CloudFormation

Viewed 629

I am trying to create a cloudformation template to deploy a lambda and this lambda will have DynamoDB as trigger. So, to accommodate that I am using AWS::Lambda::EventSourceMapping in my cloudformation template and hardcoding EventSourceArn for each dynamodb table.

My question, is there any way to get streamArn of a existing DynamoDB table, which is created manually? or I have to pass this value hardcoded from parameter section.

Please help me with you advice.

2 Answers

There is no native CloudFormation functionality to retrieve the manually created resource Arns with the exception of certain parameter types.

If you intend to keep this resource as a manually created resource you would need to pass in as a parameter into your template so that you can reference it, either referencing as a string or a SSM based parameter.

Alternatively you could construct a Custom resource that accepts the DynamoDB table name as a parameter and triggers a Lambda to get the Arn of the stream.

If you wanted to managed the table in CloudFormation you could construct the resource in your CloudFormation template and then import into the stack. By doing this you could then reference the StreamArn of the DynamoDB table resource.

All the things you create manually are available in AWS console and you could check all arns.

For you specific case go to AWS Console -> DynamoDB -> Select your table.

enter image description here

Note: I would recommend using cloudformation and avoid using manual things if this is deployed somewhere for real.

Related