SecretTargetAttachment L2 construct
An attached secret.
Example
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import { aws_secretsmanager as secretsmanager } from 'aws-cdk-lib';
declare const secret: secretsmanager.Secret;
declare const secretAttachmentTarget: secretsmanager.ISecretAttachmentTarget;
const secretTargetAttachment = new secretsmanager.SecretTargetAttachment(this, 'MySecretTargetAttachment', {
secret: secret,
target: secretAttachmentTarget,
});
# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
from aws_cdk import aws_secretsmanager as secretsmanager
# secret: secretsmanager.Secret
# secret_attachment_target: secretsmanager.ISecretAttachmentTarget
secret_target_attachment = secretsmanager.SecretTargetAttachment(self, "MySecretTargetAttachment",
secret=secret,
target=secret_attachment_target
)
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.services.secretsmanager.*;
Secret secret;
ISecretAttachmentTarget secretAttachmentTarget;
SecretTargetAttachment secretTargetAttachment = SecretTargetAttachment.Builder.create(this, "MySecretTargetAttachment")
.secret(secret)
.target(secretAttachmentTarget)
.build();
// Install: dotnet add package Amazon.CDK.Lib
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
using Amazon.CDK.AWS.SecretsManager;
Secret secret;
ISecretAttachmentTarget secretAttachmentTarget;
var secretTargetAttachment = new SecretTargetAttachment(this, "MySecretTargetAttachment", new SecretTargetAttachmentProps {
Secret = secret,
Target = secretAttachmentTarget
});
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import "github.com/aws/aws-cdk-go/awscdk"
var secret Secret
var secretAttachmentTarget ISecretAttachmentTarget
secretTargetAttachment := awscdk.Aws_secretsmanager.NewSecretTargetAttachment(this, jsii.String("MySecretTargetAttachment"), &SecretTargetAttachmentProps{
Secret: secret,
Target: secretAttachmentTarget,
})
Initializer
new SecretTargetAttachment(scope: Construct, id: string, props: SecretTargetAttachmentProps)
SecretTargetAttachment(scope: Construct, id: str, props: SecretTargetAttachmentProps)
new SecretTargetAttachment(Construct scope, String id, SecretTargetAttachmentProps props)
new SecretTargetAttachment(Construct scope, string id, SecretTargetAttachmentProps props)
NewSecretTargetAttachment(Scope Construct, Id *string, Props SecretTargetAttachmentProps)
Construct Props
targetISecretAttachmentTargettargetISecretAttachmentTargettargetISecretAttachmentTargetTargetISecretAttachmentTargetTargetISecretAttachmentTargetrequired#Properties
When not specified, the default KMS key for the account and region is being used.
envResourceEnvironmentenvResourceEnvironmentenvResourceEnvironmentEnvResourceEnvironmentEnvResourceEnvironmentrequired#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.
PROPERTY_INJECTION_IDstringproperty_injection_idstrPROPERTY_INJECTION_IDStringPROPERTY_INJECTION_IDstringPROPERTY_INJECTION_ID*stringrequiredstatic#Will return the full ARN if available, otherwise a partial arn. For secrets imported by the deprecated fromSecretName, it will return the secretName.
This is equal to secretArn in most cases, but is undefined when a full ARN is not available (e.g., secrets imported by name).
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#secretTargetAttachmentRefSecretTargetAttachmentReferencesecret_target_attachment_refSecretTargetAttachmentReferencesecretTargetAttachmentRefSecretTargetAttachmentReferenceSecretTargetAttachmentRefSecretTargetAttachmentReferenceSecretTargetAttachmentRefSecretTargetAttachmentReferencerequired#secretTargetAttachmentSecretArnstringsecret_target_attachment_secret_arnstrsecretTargetAttachmentSecretArnStringSecretTargetAttachmentSecretArnstringSecretTargetAttachmentSecretArn*stringrequired#secretValueSecretValuesecret_valueSecretValuesecretValueSecretValueSecretValueSecretValueSecretValueSecretValuerequired#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#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#This is required because a secret can only have a single resource policy. If we do not forward policy additions, a new policy resource is created using the secret attachment ARN. This ends up being rejected by CloudFormation.
applyCrossStackReferenceStrength(strength: ReferenceStrength): voiddef apply_cross_stack_reference_strength(self, strength: ReferenceStrength) -> Nonepublic void applyCrossStackReferenceStrength(ReferenceStrength strength)public void ApplyCrossStackReferenceStrength(ReferenceStrength strength)func ApplyCrossStackReferenceStrength(Strength ReferenceStrength)#notes · 1 parameter
When set, any cross-stack reference to this resource will use the specified mechanism instead of the global default determined by the @aws-cdk/core:defaultCrossStackReferences context key. This is useful for selectively weakening specific references to avoid the "deadly embrace" problem without changing the app-wide default.
Parameters
strengthstrengthstrengthstrengthStrength— - The reference strength to use for this resource.
applyRemovalPolicy(policy: RemovalPolicy): voiddef apply_removal_policy(self, policy: RemovalPolicy) -> Nonepublic void applyRemovalPolicy(RemovalPolicy policy)public void ApplyRemovalPolicy(RemovalPolicy policy)func ApplyRemovalPolicy(Policy RemovalPolicy)#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): ISecretdef attach(self, target: ISecretAttachmentTarget) -> ISecretpublic ISecret attach(ISecretAttachmentTarget target)public ISecret Attach(ISecretAttachmentTarget target)func Attach(Target ISecretAttachmentTarget) ISecret#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#1 parameter
Parameters
optionsoptionsoptionsoptionsOptions— Options.
denyAccountRootDelete(): voiddef deny_account_root_delete(self, ) -> Nonepublic void denyAccountRootDelete()public void DenyAccountRootDelete()func DenyAccountRootDelete()#fromSecretTargetAttachmentSecretArn(scope: Construct, id: string, secretTargetAttachmentSecretArn: string): ISecretTargetAttachment@staticmethod def from_secret_target_attachment_secret_arn(scope: Construct, id: str, secret_target_attachment_secret_arn: str) -> ISecretTargetAttachmentpublic static ISecretTargetAttachment fromSecretTargetAttachmentSecretArn(Construct scope, String id, String secretTargetAttachmentSecretArn)public static ISecretTargetAttachment FromSecretTargetAttachmentSecretArn(Construct scope, string id, string secretTargetAttachmentSecretArn)func FromSecretTargetAttachmentSecretArn(Scope Construct, Id *string, SecretTargetAttachmentSecretArn *string) ISecretTargetAttachmentstatic#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#grantWrite(grantee: IGrantable): Grantdef grant_write(self, grantee: IGrantable) -> Grantpublic Grant grantWrite(IGrantable grantee)public Grant GrantWrite(IGrantable grantee)func GrantWrite(Grantee IGrantable) Grant#isConstruct(x: any): boolean@staticmethod def is_construct(x: Any) -> boolpublic static Boolean isConstruct(Object x)public static bool IsConstruct(object x)func IsConstruct(X interface{}) *boolstatic#notes · 1 parameter · returns
Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.
Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.
Parameters
xxxxX— Any object.
Returns: true if x is an object created from a class which extends Construct.
isOwnedResource(construct: IConstruct): boolean@staticmethod def is_owned_resource(construct: IConstruct) -> boolpublic static Boolean isOwnedResource(IConstruct construct)public static bool IsOwnedResource(IConstruct construct)func IsOwnedResource(Construct IConstruct) *boolstatic#isResource(construct: IConstruct): boolean@staticmethod def is_resource(construct: IConstruct) -> boolpublic static Boolean isResource(IConstruct construct)public static bool IsResource(IConstruct construct)func IsResource(Construct IConstruct) *boolstatic#secretValueFromJson(jsonField: string): SecretValuedef secret_value_from_json(self, json_field: str) -> SecretValuepublic SecretValue secretValueFromJson(String jsonField)public SecretValue SecretValueFromJson(string jsonField)func SecretValueFromJson(JsonField *string) SecretValue#toString(): stringdef to_string(self, ) -> strpublic String toString()public string ToString()func ToString() *string#with(...mixins: IMixin[]): IConstructdef with(self, mixins: IMixin) -> IConstructpublic IConstruct with(IMixin mixins)public IConstruct With(IMixin mixins)func With(Mixins IMixin) IConstruct#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. Use multiple with() calls if subsequent mixins should apply to added constructs.