I am not able to import a DynamoDB table into a stack whereas I am able to import a Secret. I double checked the arns. Both the secret and ddb are in same region. But I am not able to import ddb table alone.
// This works
const mySecret = Secret.fromSecretCompleteArn(this, "TestSecret", "arn:aws...");
// Dynamo Db table does not get imported however
// Following this doc https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_dynamodb.Table.html#static-fromwbrtablewbrarnscope-id-tablearn
const myDdbTable = Table.fromTableArn(this, "MyTable", "arn:aws...")
Question: Do we create template.json manually and manual steps as mentioned in https://aws.amazon.com/blogs/aws/new-import-existing-resources-into-a-cloudformation-stack/ for importing DynamoDB table? Then what is the use of the Table.fromTableArn()
method?
CodePudding user response:
The Something.fromSomethingArn
methods all return read-only references. The methods do not perform cloud-side lookups. The ISomething
interface-type constructs these methods return don't permit modification of the resource. They are glorified ARN wrappers, useful for adding an existing resource to a stack resource's IAM policy, for instance.
The CDK CLI has experimental import functionality. cdk import
brings eligible resource types under CDK stack management. AWS::DynamoDB::Table
is an importable resource type. Once imported, these resources can be manipulated like any other construct.