Importing the Existing Resources into CloudFormation management, It doesn't seem to explain an option of importing through CDK

0

Importing the existing resources into CloudFormation management: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/resource-import.html, It doesn't seem to explain an option to import through **CDK ** . how can we achieve that through CDK? In my case here, I created a new pipeline app, stack through CDK for an account thats holding manually created DDB Tables. I would want to import existing DDB tables that were created manually on console,I want to enable streams on these tables from CDK. could you please guide me here?

1 Answer
1

For that you use either fromTableName, fromTableArn methods from the DynamoDB Table construct:

import * as cdk from '@aws-cdk/core';
import * as dynamodb from '@aws-cdk/aws-dynamodb';

class MyStack extends cdk.Stack {
  constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) {
    super(scope, id, props);

    const existingTable = dynamodb.Table.fromTableName(this, 'ExistingTable', 'YourExistingTableName');
  }
}
profile pictureAWS
EXPERT
answered 6 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions