1.19.0版,下面的脚本可以正常工作。
import secretsmanager = require('@aws-cdk/aws-secretsmanager');
const target : secretsmanager.ISecretAttachmentTarget = {
asSecretAttachmentTarget: () => ({
targetId: `arn:aws:rds:${this.region}:${this.account}:cluster:${this.database.ref}`,
targetType: secretsmanager.AttachmentTargetType.CLUSTER
})
};
const myUserSecretAttached = this.dbSecrets.addTargetAttachment('AttachedSecret', {target})
在1.20.0版本中,不推荐使用addTargetAttachment。因此我使用了attach。在ISecretAttachmentTarget targetType中,不建议使用secretsmanager.AttachmentTargetType。那还有什么选择呢? 我尝试了下面的脚本,该脚本引发错误“使用了不赞成使用的符号,请参考文档以寻求更好的选择。”
import secretsmanager = require('@aws-cdk/aws-secretsmanager');
const target : secretsmanager.ISecretAttachmentTarget = {
asSecretAttachmentTarget: () => ({
targetId: `arn:aws:rds:${this.region}:${this.account}:cluster:${this.database.ref}`,
targetType: secretsmanager.AttachmentTargetType.CLUSTER
})
};
const myUserSecretAttached = this.dbSecrets.attach(target)
答案 0 :(得分:0)
AttachmenTargetType
被错误地弃用。
仅弃用其某些常量:secretsmanager.AttachmentTargetType.CLUSTER
现在为secretsmanager.AttachmentTargetType.RDS_DB_CLUSTER
,而secretsmanager.AttachmentTargetType.INSTANCE
现在为secretsmanager.AttachmentTargetType.RDS_DB_INSTANCE
。
请注意,如果在您的示例中this.database
是一个Cluster
实例,则可以执行以下操作:
this.dbSecrets.attach(this.database);