Class CfnSecret
- All Implemented Interfaces:
IInspectable,ITaggable,ISecretRef,software.amazon.jsii.JsiiSerializable,software.constructs.IConstruct,software.constructs.IDependable
A secret can be a password, a set of credentials such as a user name and password, an OAuth token, or other secret information that you store in an encrypted form in Secrets Manager.
For Amazon RDS master user credentials, see AWS::RDS::DBCluster MasterUserSecret .
For Amazon Redshift admin user credentials, see AWS::Redshift::Cluster .
To retrieve a secret in a CloudFormation template, use a dynamic reference . For more information, see Retrieve a secret in an AWS CloudFormation resource .
For information about creating a secret in the console, see Create a secret . For information about creating a secret using the CLI or SDK, see CreateSecret .
For information about retrieving a secret in code, see Retrieve secrets from Secrets Manager .
Example:
// 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.*;
CfnSecret cfnSecret = CfnSecret.Builder.create(this, "MyCfnSecret")
.description("description")
.generateSecretString(GenerateSecretStringProperty.builder()
.excludeCharacters("excludeCharacters")
.excludeLowercase(false)
.excludeNumbers(false)
.excludePunctuation(false)
.excludeUppercase(false)
.generateStringKey("generateStringKey")
.includeSpace(false)
.passwordLength(123)
.requireEachIncludedType(false)
.secretStringTemplate("secretStringTemplate")
.build())
.kmsKeyId("kmsKeyId")
.name("name")
.replicaRegions(List.of(ReplicaRegionProperty.builder()
.region("region")
// the properties below are optional
.kmsKeyId("kmsKeyId")
.build()))
.secretString("secretString")
.tags(List.of(CfnTag.builder()
.key("key")
.value("value")
.build()))
.build();
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classA fluent builder forCfnSecret.static interfaceGenerates a random password.static interfaceSpecifies aRegionand theKmsKeyIdfor a replica secret.Nested classes/interfaces inherited from class software.amazon.jsii.JsiiObject
software.amazon.jsii.JsiiObject.InitializationModeNested classes/interfaces inherited from interface software.constructs.IConstruct
software.constructs.IConstruct.Jsii$DefaultNested classes/interfaces inherited from interface software.amazon.awscdk.IInspectable
IInspectable.Jsii$Default, IInspectable.Jsii$ProxyNested classes/interfaces inherited from interface software.amazon.awscdk.services.secretsmanager.ISecretRef
ISecretRef.Jsii$Default, ISecretRef.Jsii$ProxyNested classes/interfaces inherited from interface software.amazon.awscdk.ITaggable
ITaggable.Jsii$Default, ITaggable.Jsii$Proxy -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe CloudFormation resource type name for this resource class. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCfnSecret(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) protectedCfnSecret(software.amazon.jsii.JsiiObjectRef objRef) CfnSecret(software.constructs.Construct scope, String id, CfnSecretProps props) -
Method Summary
Modifier and TypeMethodDescriptionstatic ISecretReffromSecretId(software.constructs.Construct scope, String id, String secretId) Creates a new ISecretRef from a secretId.The ARN of the secret.The description of the secret.A structure that specifies how to generate a password to encrypt and store in the secret.The ARN, key ID, or alias of the AWS KMS key that Secrets Manager uses to encrypt the secret value in the secret.getName()The name of the new secret.A custom type that specifies aRegionand theKmsKeyIdfor a replica secret.A reference to a Secret resource.The text to encrypt and store in the secret.getTags()Tag Manager which manages the tags for this resource.A list of tags to attach to the secret.voidinspect(TreeInspector inspector) Examines the CloudFormation resource and discloses attributes.renderProperties(Map<String, Object> props) voidsetDescription(String value) The description of the secret.voidA structure that specifies how to generate a password to encrypt and store in the secret.voidA structure that specifies how to generate a password to encrypt and store in the secret.voidsetKmsKeyId(String value) The ARN, key ID, or alias of the AWS KMS key that Secrets Manager uses to encrypt the secret value in the secret.voidThe name of the new secret.voidsetReplicaRegions(List<Object> value) A custom type that specifies aRegionand theKmsKeyIdfor a replica secret.voidsetReplicaRegions(IResolvable value) A custom type that specifies aRegionand theKmsKeyIdfor a replica secret.voidsetSecretString(String value) The text to encrypt and store in the secret.voidsetTagsRaw(List<CfnTag> value) A list of tags to attach to the secret.Methods inherited from class software.amazon.awscdk.CfnResource
addDeletionOverride, addDependency, addDependsOn, addMetadata, addOverride, addPropertyDeletionOverride, addPropertyOverride, applyRemovalPolicy, applyRemovalPolicy, applyRemovalPolicy, getAtt, getAtt, getCfnOptions, getCfnResourceType, getMetadata, getUpdatedProperites, getUpdatedProperties, isCfnResource, obtainDependencies, obtainResourceDependencies, removeDependency, replaceDependency, shouldSynthesize, toString, validatePropertiesMethods inherited from class software.amazon.awscdk.CfnRefElement
getRefMethods inherited from class software.amazon.awscdk.CfnElement
getCreationStack, getLogicalId, getStack, isCfnElement, overrideLogicalIdMethods inherited from class software.constructs.Construct
getNode, isConstructMethods inherited from class software.amazon.jsii.JsiiObject
jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSetMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface software.constructs.IConstruct
getNodeMethods inherited from interface software.amazon.jsii.JsiiSerializable
$jsii$toJson
-
Field Details
-
CFN_RESOURCE_TYPE_NAME
The CloudFormation resource type name for this resource class.
-
-
Constructor Details
-
CfnSecret
protected CfnSecret(software.amazon.jsii.JsiiObjectRef objRef) -
CfnSecret
protected CfnSecret(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) -
CfnSecret
@Stability(Stable) public CfnSecret(@NotNull software.constructs.Construct scope, @NotNull String id, @Nullable CfnSecretProps props) - Parameters:
scope- Scope in which this resource is defined. This parameter is required.id- Construct identifier for this resource (unique in its scope). This parameter is required.props- Resource properties.
-
CfnSecret
@Stability(Stable) public CfnSecret(@NotNull software.constructs.Construct scope, @NotNull String id) - Parameters:
scope- Scope in which this resource is defined. This parameter is required.id- Construct identifier for this resource (unique in its scope). This parameter is required.
-
-
Method Details
-
fromSecretId
@Stability(Stable) @NotNull public static ISecretRef fromSecretId(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull String secretId) Creates a new ISecretRef from a secretId.- Parameters:
scope- This parameter is required.id- This parameter is required.secretId- This parameter is required.
-
inspect
Examines the CloudFormation resource and discloses attributes.- Specified by:
inspectin interfaceIInspectable- Parameters:
inspector- tree inspector to collect and process attributes. This parameter is required.
-
renderProperties
@Stability(Stable) @NotNull protected Map<String,Object> renderProperties(@NotNull Map<String, Object> props) - Overrides:
renderPropertiesin classCfnResource- Parameters:
props- This parameter is required.
-
getAttrId
The ARN of the secret. -
getCfnProperties
- Overrides:
getCfnPropertiesin classCfnResource
-
getSecretRef
A reference to a Secret resource.- Specified by:
getSecretRefin interfaceISecretRef
-
getTags
Tag Manager which manages the tags for this resource. -
getDescription
The description of the secret. -
setDescription
The description of the secret. -
getGenerateSecretString
A structure that specifies how to generate a password to encrypt and store in the secret.Returns union: either
IResolvableorCfnSecret.GenerateSecretStringProperty -
setGenerateSecretString
A structure that specifies how to generate a password to encrypt and store in the secret. -
setGenerateSecretString
@Stability(Stable) public void setGenerateSecretString(@Nullable CfnSecret.GenerateSecretStringProperty value) A structure that specifies how to generate a password to encrypt and store in the secret. -
getKmsKeyId
The ARN, key ID, or alias of the AWS KMS key that Secrets Manager uses to encrypt the secret value in the secret. -
setKmsKeyId
The ARN, key ID, or alias of the AWS KMS key that Secrets Manager uses to encrypt the secret value in the secret. -
getName
The name of the new secret. -
setName
The name of the new secret. -
getReplicaRegions
A custom type that specifies aRegionand theKmsKeyIdfor a replica secret.Returns union: either
IResolvableor Listinvalid input: '<'eitherIResolvableorCfnSecret.ReplicaRegionProperty> -
setReplicaRegions
A custom type that specifies aRegionand theKmsKeyIdfor a replica secret. -
setReplicaRegions
A custom type that specifies aRegionand theKmsKeyIdfor a replica secret. -
getSecretString
The text to encrypt and store in the secret. -
setSecretString
The text to encrypt and store in the secret. -
getTagsRaw
A list of tags to attach to the secret. -
setTagsRaw
A list of tags to attach to the secret.
-