简体   繁体   English

AWS CDK Typescript 模板中未生成导入 DynamoDB 表

[英]AWS CDK Typescript Import DynamoDB table not generated in template

I am not able to import a DynamoDB table into a stack whereas I am able to import a Secret.我无法将 DynamoDB 表导入堆栈,但可以导入 Secret。 I double checked the arns.我仔细检查了 arns。 Both the secret and ddb are in same region. secret 和 ddb 都在同一个区域。 But I am not able to import ddb table alone.但是我无法单独导入 ddb 表。

// 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?问题:我们是否像https://aws.amazon.com/blogs/aws/new-import-existing-resources-into-a-cloudformation-stack/中提到的手动创建 template.json 以导入 DynamoDB 表? Then what is the use of the Table.fromTableArn() method?那么Table.fromTableArn()方法有什么用呢?

The Something.fromSomethingArn methods all return read-only references . Something.fromSomethingArn方法都返回只读引用 The methods do not perform cloud-side lookups.这些方法不执行云端查找。 The ISomething interface-type constructs these methods return don't permit modification of the resource. ISomething 接口类型构造这些方法返回不允许修改资源。 They are glorified ARN wrappers, useful for adding an existing resource to a stack resource's IAM policy, for instance.它们是美化的 ARN 包装器,例如,可用于将现有资源添加到堆栈资源的 IAM 策略。

The CDK CLI has experimental import functionality. CDK CLI 具有实验性的导入功能。 cdk import brings eligible resource types under CDK stack management. cdk import符合条件的资源类型置于 CDK 堆栈管理之下。 AWS::DynamoDB::Table is an importable resource type. AWS::DynamoDB::Table是一种可导入的资源类型。 Once imported, these resources can be manipulated like any other construct.一旦导入,这些资源就可以像任何其他构造一样进行操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM