SecretStringValueBeta1

class aws_cdk.aws_secretsmanager.SecretStringValueBeta1(*args: Any, **kwargs)

Bases: object

(deprecated) An experimental class used to specify an initial secret value for a Secret.

The class wraps a simple string (or JSON representation) in order to provide some safety checks and warnings about the dangers of using plaintext strings as initial secret seed values via CDK/CloudFormation.

Deprecated:

Use cdk.SecretValue instead.

Stability:

deprecated

ExampleMetadata:

infused

Example:

# Creates a new IAM user, access and secret keys, and stores the secret access key in a Secret.
user = iam.User(self, "User")
access_key = iam.AccessKey(self, "AccessKey", user=user)
secret_value = secretsmanager.SecretStringValueBeta1.from_token(access_key.secret_access_key.to_string())
secretsmanager.Secret(self, "Secret",
    secret_string_beta1=secret_value
)

Methods

secret_value()

(deprecated) Returns the secret value.

Stability:

deprecated

Return type:

str

Static Methods

classmethod from_token(secret_value_from_token)

(deprecated) Creates a SecretValueValueBeta1 from a string value coming from a Token.

The intent is to enable creating secrets from references (e.g., Ref, Fn::GetAtt) from other resources. This might be the direct output of another Construct, or the output of a Custom Resource. This method throws if it determines the input is an unsafe plaintext string.

For example:

# Creates a new IAM user, access and secret keys, and stores the secret access key in a Secret.
user = iam.User(self, "User")
access_key = iam.AccessKey(self, "AccessKey", user=user)
secret_value = secretsmanager.SecretStringValueBeta1.from_token(access_key.secret_access_key.to_string())
secretsmanager.Secret(self, "Secret",
    secret_string_beta1=secret_value
)

The secret may also be embedded in a string representation of a JSON structure:

user = iam.User(self, "User")
access_key = iam.AccessKey(self, "AccessKey", user=user)
secret_value = secretsmanager.SecretStringValueBeta1.from_token(JSON.stringify({
    "username": user.user_name,
    "database": "foo",
    "password": access_key.secret_access_key.unsafe_unwrap()
}))

Note that the value being a Token does not guarantee safety. For example, a Lazy-evaluated string (e.g., Lazy.string({ produce: () => 'myInsecurePassword' }))) is a Token, but as the output is ultimately a plaintext string, and so insecure.

Parameters:

secret_value_from_token (str) – a secret value coming from a Construct attribute or Custom Resource output.

Stability:

deprecated

Return type:

SecretStringValueBeta1

classmethod from_unsafe_plaintext(secret_value)

(deprecated) Creates a SecretStringValueBeta1 from a plaintext value.

This approach is inherently unsafe, as the secret value may be visible in your source control repository and will also appear in plaintext in the resulting CloudFormation template, including in the AWS Console or APIs. Usage of this method is discouraged, especially for production workloads.

Parameters:

secret_value (str)

Stability:

deprecated

Return type:

SecretStringValueBeta1