@Generated(value="jsii-pacmak/1.67.0 (build 2c027f5)", date="2022-09-19T20:26:42.052Z") @Stability(value=Stable) public class Secret extends Resource implements ISecret
Example:
Stack stack;
User user = new User(stack, "User");
AccessKey accessKey = AccessKey.Builder.create(stack, "AccessKey").user(user).build();
Secret.Builder.create(stack, "Secret")
.secretObjectValue(Map.of(
"username", SecretValue.unsafePlainText(user.getUserName()),
"database", SecretValue.unsafePlainText("foo"),
"password", accessKey.getSecretAccessKey()))
.build();
| Modifier and Type | Class and Description |
|---|---|
static class |
Secret.Builder
A fluent builder for
Secret. |
software.amazon.jsii.JsiiObject.InitializationModeISecret.Jsii$Default, ISecret.Jsii$Proxy| Modifier | Constructor and Description |
|---|---|
|
Secret(software.constructs.Construct scope,
String id) |
|
Secret(software.constructs.Construct scope,
String id,
SecretProps props) |
protected |
Secret(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) |
protected |
Secret(software.amazon.jsii.JsiiObjectRef objRef) |
| Modifier and Type | Method and Description |
|---|---|
void |
addReplicaRegion(String region)
Adds a replica region for the secret.
|
void |
addReplicaRegion(String region,
IKey encryptionKey)
Adds a replica region for the secret.
|
RotationSchedule |
addRotationSchedule(String id,
RotationScheduleOptions options)
Adds a rotation schedule to the secret.
|
AddToResourcePolicyResult |
addToResourcePolicy(PolicyStatement statement)
Adds a statement to the IAM resource policy associated with this secret.
|
ISecret |
attach(ISecretAttachmentTarget target)
Attach a target to this secret.
|
void |
denyAccountRootDelete()
Denies the `DeleteSecret` action to all principals within the current account.
|
static ISecret |
fromSecretAttributes(software.constructs.Construct scope,
String id,
SecretAttributes attrs)
Import an existing secret into the Stack.
|
static ISecret |
fromSecretCompleteArn(software.constructs.Construct scope,
String id,
String secretCompleteArn)
Imports a secret by complete ARN.
|
static ISecret |
fromSecretNameV2(software.constructs.Construct scope,
String id,
String secretName)
Imports a secret by secret name.
|
static ISecret |
fromSecretPartialArn(software.constructs.Construct scope,
String id,
String secretPartialArn)
Imports a secret by partial ARN.
|
protected String |
getArnForPolicies()
Provides an identifier for this secret for use in IAM policies.
|
protected Boolean |
getAutoCreatePolicy() |
IKey |
getEncryptionKey()
The customer-managed encryption key that is used to encrypt this secret, if any.
|
String |
getExcludeCharacters()
The string of the characters that are excluded in this secret when it is generated.
|
String |
getSecretArn()
The ARN of the secret in AWS Secrets Manager.
|
String |
getSecretFullArn()
The full ARN of the secret in AWS Secrets Manager, which is the ARN including the Secrets Manager-supplied 6-character suffix.
|
String |
getSecretName()
The name of the secret.
|
SecretValue |
getSecretValue()
Retrieve the value of the stored secret as a `SecretValue`.
|
Grant |
grantRead(IGrantable grantee)
Grants reading the secret value to some role.
|
Grant |
grantRead(IGrantable grantee,
List<String> versionStages)
Grants reading the secret value to some role.
|
Grant |
grantWrite(IGrantable grantee)
Grants writing and updating the secret value to some role.
|
static Boolean |
isSecret(Object x)
Return whether the given object is a Secret.
|
SecretValue |
secretValueFromJson(String jsonField)
Interpret the secret as a JSON object and return a field's value from it as a `SecretValue`.
|
applyRemovalPolicy, generatePhysicalName, getEnv, getPhysicalName, getResourceArnAttribute, getResourceNameAttribute, getStack, isOwnedResource, isResourcejsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSetclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitapplyRemovalPolicy, getEnv, getStackprotected Secret(software.amazon.jsii.JsiiObjectRef objRef)
protected Secret(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
@Stability(value=Stable)
public Secret(@NotNull
software.constructs.Construct scope,
@NotNull
String id,
@Nullable
SecretProps props)
scope - This parameter is required.id - This parameter is required.props - @Stability(value=Stable)
public Secret(@NotNull
software.constructs.Construct scope,
@NotNull
String id)
scope - This parameter is required.id - This parameter is required.@Stability(value=Stable) @NotNull public static ISecret fromSecretAttributes(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull SecretAttributes attrs)
scope - the scope of the import. This parameter is required.id - the ID of the imported Secret in the construct tree. This parameter is required.attrs - the attributes of the imported secret. This parameter is required.@Stability(value=Stable) @NotNull public static ISecret fromSecretCompleteArn(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull String secretCompleteArn)
The complete ARN is the ARN with the Secrets Manager-supplied suffix.
scope - This parameter is required.id - This parameter is required.secretCompleteArn - This parameter is required.@Stability(value=Stable) @NotNull public static ISecret fromSecretNameV2(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull String secretName)
A secret with this name must exist in the same account & region.
Replaces the deprecated fromSecretName.
scope - This parameter is required.id - This parameter is required.secretName - This parameter is required.@Stability(value=Stable) @NotNull public static ISecret fromSecretPartialArn(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull String secretPartialArn)
The partial ARN is the ARN without the Secrets Manager-supplied suffix.
scope - This parameter is required.id - This parameter is required.secretPartialArn - This parameter is required.@Stability(value=Stable) @NotNull public static Boolean isSecret(@NotNull Object x)
x - This parameter is required.@Stability(value=Stable)
public void addReplicaRegion(@NotNull
String region,
@Nullable
IKey encryptionKey)
region - The name of the region. This parameter is required.encryptionKey - The customer-managed encryption key to use for encrypting the secret value.@Stability(value=Stable)
public void addReplicaRegion(@NotNull
String region)
region - The name of the region. This parameter is required.@Stability(value=Stable) @NotNull public RotationSchedule addRotationSchedule(@NotNull String id, @NotNull RotationScheduleOptions options)
addRotationSchedule in interface ISecretid - This parameter is required.options - This parameter is required.@Stability(value=Stable) @NotNull public AddToResourcePolicyResult addToResourcePolicy(@NotNull PolicyStatement statement)
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.
addToResourcePolicy in interface ISecretstatement - This parameter is required.@Stability(value=Stable) @NotNull public ISecret attach(@NotNull ISecretAttachmentTarget target)
@Stability(value=Stable) public void denyAccountRootDelete()
denyAccountRootDelete in interface ISecret@Stability(value=Stable) @NotNull public Grant grantRead(@NotNull IGrantable grantee, @Nullable List<String> versionStages)
@Stability(value=Stable) @NotNull public Grant grantRead(@NotNull IGrantable grantee)
@Stability(value=Stable) @NotNull public Grant grantWrite(@NotNull IGrantable grantee)
grantWrite in interface ISecretgrantee - This parameter is required.@Stability(value=Stable) @NotNull public SecretValue secretValueFromJson(@NotNull String jsonField)
secretValueFromJson in interface ISecretjsonField - This parameter is required.@Stability(value=Stable) @NotNull protected String getArnForPolicies()
If there is a full ARN, this is just the ARN; if we have a partial ARN -- due to either importing by secret name or partial ARN -- then we need to add a suffix to capture the full ARN's format.
@Stability(value=Stable) @NotNull protected Boolean getAutoCreatePolicy()
@Stability(value=Stable) @NotNull public String getSecretArn()
Will return the full ARN if available, otherwise a partial arn.
For secrets imported by the deprecated fromSecretName, it will return the secretName.
getSecretArn in interface ISecret@Stability(value=Stable) @NotNull public String getSecretName()
For "owned" secrets, this will be the full resource name (secret name + suffix), unless the '@aws-cdk/aws-secretsmanager:parseOwnedSecretName' feature flag is set.
getSecretName in interface ISecret@Stability(value=Stable) @NotNull public SecretValue getSecretValue()
getSecretValue in interface ISecret@Stability(value=Stable) @Nullable public IKey getEncryptionKey()
When not specified, the default KMS key for the account and region is being used.
getEncryptionKey in interface ISecret@Stability(value=Stable) @Nullable public String getExcludeCharacters()
@Stability(value=Stable) @Nullable public String getSecretFullArn()
This is equal to secretArn in most cases, but is undefined when a full ARN is not available (e.g., secrets imported by name).
getSecretFullArn in interface ISecretCopyright © 2022. All rights reserved.