Skip to content
v2.273.0

ISecret Interface ​

A secret in AWS Secrets Manager.

Properties ​

encryptionKeyIKeyencryption_keyIKeyencryptionKeyIKeyEncryptionKeyIKeyEncryptionKeyIKey#
The customer-managed encryption key that is used to encrypt this secret, if any.

When not specified, the default KMS key for the account and region is being used.

The environment this resource belongs to.
notes

For resources that are created and managed in a Stack (those created by creating new class instances like new Role(), new Bucket(), etc.), this is always the same as the environment of the stack they belong to.

For referenced resources (those obtained from referencing methods like Role.fromRoleArn(), Bucket.fromBucketName(), etc.), they might be different than the stack they were imported into.

nodeNodenodeNodenodeNodeNodeNodeNodeNoderequired#
The tree node.
secretArnstringsecret_arnstrsecretArnStringSecretArnstringSecretArn*stringrequired#
The ARN of the secret in AWS Secrets Manager.

Will return the full ARN if available, otherwise a partial arn. For secrets imported by the deprecated fromSecretName, it will return the secretName.

secretFullArnstringsecret_full_arnstrsecretFullArnStringSecretFullArnstringSecretFullArn*string#
The full ARN of the secret in AWS Secrets Manager, which is the ARN including the Secrets Manager-supplied 6-character suffix.

This is equal to secretArn in most cases, but is undefined when a full ARN is not available (e.g., secrets imported by name).

secretNamestringsecret_namestrsecretNameStringSecretNamestringSecretName*stringrequired#
The name of the secret.

For "owned" secrets, this will be the full resource name (secret name + suffix), unless the '@aws-cdk/aws-secretsmanager:parseOwnedSecretName' feature flag is set.

secretRefSecretReferencesecret_refSecretReferencesecretRefSecretReferenceSecretRefSecretReferenceSecretRefSecretReferencerequired#
A reference to a Secret resource.
secretValueSecretValuesecret_valueSecretValuesecretValueSecretValueSecretValueSecretValueSecretValueSecretValuerequired#
Retrieve the value of the stored secret as a `SecretValue`.
stackStackstackStackstackStackStackStackStackStackrequired#
The stack in which this resource is defined.

Methods ​

addRotationSchedule(id: string, options: RotationScheduleOptions): RotationScheduledef add_rotation_schedule(self, id: str, options: RotationScheduleOptions) -> RotationSchedulepublic RotationSchedule addRotationSchedule(String id, RotationScheduleOptions options)public RotationSchedule AddRotationSchedule(string id, RotationScheduleOptions options)func AddRotationSchedule(Id *string, Options RotationScheduleOptions) RotationSchedule#
Adds a rotation schedule to the secret.
addToResourcePolicy(statement: PolicyStatement): AddToResourcePolicyResultdef add_to_resource_policy(self, statement: PolicyStatement) -> AddToResourcePolicyResultpublic AddToResourcePolicyResult addToResourcePolicy(PolicyStatement statement)public AddToResourcePolicyResult AddToResourcePolicy(PolicyStatement statement)func AddToResourcePolicy(Statement PolicyStatement) AddToResourcePolicyResult#
Adds a statement to the IAM resource policy associated with this secret.

If this secret was created in this stack, a resource policy will be automatically created upon the first call to addToResourcePolicy. If the secret is imported, then this is a no-op.

applyRemovalPolicy(policy: RemovalPolicy): voiddef apply_removal_policy(self, policy: RemovalPolicy) -> Nonepublic void applyRemovalPolicy(RemovalPolicy policy)public void ApplyRemovalPolicy(RemovalPolicy policy)func ApplyRemovalPolicy(Policy RemovalPolicy)#
Apply the given removal policy to this resource.
notes

The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you've removed it from the CDK application or because you've made a change that requires the resource to be replaced.

The resource can be deleted (RemovalPolicy.DESTROY), or left in your AWS account for data recovery and cleanup later (RemovalPolicy.RETAIN).

attach(target: ISecretAttachmentTarget): ISecret // chainabledef attach(self, target: ISecretAttachmentTarget) -> ISecretpublic ISecret attach(ISecretAttachmentTarget target)public ISecret Attach(ISecretAttachmentTarget target)func Attach(Target ISecretAttachmentTarget) ISecret#
Attach a target to this secret.
1 parameter · returns

Parameters

  • targettargettargettargetTarget — The target to attach.

Returns: An attached secret

cfnDynamicReferenceKey(options?: SecretsManagerSecretOptions): stringdef cfn_dynamic_reference_key(self, options: typing.Optional[SecretsManagerSecretOptions] = None) -> strpublic String cfnDynamicReferenceKey(SecretsManagerSecretOptions options)public string CfnDynamicReferenceKey(SecretsManagerSecretOptions? options = null)func CfnDynamicReferenceKey(Options SecretsManagerSecretOptions) *string#
Returns a key which can be used within an AWS CloudFormation dynamic reference to dynamically load this secret from AWS Secrets Manager.
1 parameter

Parameters

  • optionsoptionsoptionsoptionsOptions — Options.
denyAccountRootDelete(): voiddef deny_account_root_delete(self, ) -> Nonepublic void denyAccountRootDelete()public void DenyAccountRootDelete()func DenyAccountRootDelete()#
Denies the `DeleteSecret` action to all principals within the current account.
grantRead(grantee: IGrantable, versionStages?: string[]): Grantdef grant_read(self, grantee: IGrantable, version_stages: typing.Optional[typing.List[str]] = None) -> Grantpublic Grant grantRead(IGrantable grantee, List<String> versionStages)public Grant GrantRead(IGrantable grantee, string[]? versionStages = null)func GrantRead(Grantee IGrantable, VersionStages *[]*string) Grant#
Grants reading the secret value to some role.
2 parameters

Parameters

  • granteegranteegranteegranteeGrantee — the principal being granted permission.
  • versionStagesversion_stagesversionStagesversionStagesVersionStages — the version stages the grant is limited to.
grantWrite(grantee: IGrantable): Grantdef grant_write(self, grantee: IGrantable) -> Grantpublic Grant grantWrite(IGrantable grantee)public Grant GrantWrite(IGrantable grantee)func GrantWrite(Grantee IGrantable) Grant#
Grants writing and updating the secret value to some role.
1 parameter

Parameters

  • granteegranteegranteegranteeGrantee — the principal being granted permission.
secretValueFromJson(key: string): SecretValuedef secret_value_from_json(self, key: str) -> SecretValuepublic SecretValue secretValueFromJson(String key)public SecretValue SecretValueFromJson(string key)func SecretValueFromJson(Key *string) SecretValue#
Interpret the secret as a JSON object and return a field's value from it as a `SecretValue`.
with(...mixins: IMixin[]): IConstructdef with(self, mixins: IMixin) -> IConstructpublic IConstruct with(IMixin mixins)public IConstruct With(IMixin mixins)func With(Mixins IMixin) IConstruct#
Applies one or more mixins to this construct.

Mixins are applied in order. The list of constructs is captured at the start of the call, so constructs added by a mixin will not be visited.

1 parameter · returns

Parameters

  • mixinsmixinsmixinsmixinsMixins — The mixins to apply.

Returns: This construct for chaining