Class Credentials
- All Implemented Interfaces:
software.amazon.jsii.JsiiSerializable
Example:
// Build a data source for AppSync to access the database. GraphqlApi api; // Create username and password secret for DB Cluster DatabaseSecret secret = DatabaseSecret.Builder.create(this, "AuroraSecret") .username("clusteradmin") .build(); // The VPC to place the cluster in Vpc vpc = new Vpc(this, "AuroraVpc"); // Create the serverless cluster, provide all values needed to customise the database. ServerlessCluster cluster = ServerlessCluster.Builder.create(this, "AuroraCluster") .engine(DatabaseClusterEngine.AURORA_MYSQL) .vpc(vpc) .credentials(Map.of("username", "clusteradmin")) .clusterIdentifier("db-endpoint-test") .defaultDatabaseName("demos") .build(); RdsDataSource rdsDS = api.addRdsDataSource("rds", cluster, secret, "demos"); // Set up a resolver for an RDS query. rdsDS.createResolver(BaseResolverProps.builder() .typeName("Query") .fieldName("getDemosRds") .requestMappingTemplate(MappingTemplate.fromString("\n {\n \"version\": \"2018-05-29\",\n \"statements\": [\n \"SELECT * FROM demos\"\n ]\n }\n ")) .responseMappingTemplate(MappingTemplate.fromString("\n $utils.toJson($utils.rds.toJsonObject($ctx.result)[0])\n ")) .build()); // Set up a resolver for an RDS mutation. rdsDS.createResolver(BaseResolverProps.builder() .typeName("Mutation") .fieldName("addDemoRds") .requestMappingTemplate(MappingTemplate.fromString("\n {\n \"version\": \"2018-05-29\",\n \"statements\": [\n \"INSERT INTO demos VALUES (:id, :version)\",\n \"SELECT * WHERE id = :id\"\n ],\n \"variableMap\": {\n \":id\": $util.toJson($util.autoId()),\n \":version\": $util.toJson($ctx.args.version)\n }\n }\n ")) .responseMappingTemplate(MappingTemplate.fromString("\n $utils.toJson($utils.rds.toJsonObject($ctx.result)[1][0])\n ")) .build());
-
Nested Class Summary
Nested classes/interfaces inherited from class software.amazon.jsii.JsiiObject
software.amazon.jsii.JsiiObject.InitializationMode
-
Constructor Summary
ModifierConstructorDescriptionprotected
protected
Credentials
(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) protected
Credentials
(software.amazon.jsii.JsiiObjectRef objRef) -
Method Summary
Modifier and TypeMethodDescriptionstatic Credentials
fromGeneratedSecret
(String username) Creates Credentials with a password generated and stored in Secrets Manager.static Credentials
fromGeneratedSecret
(String username, CredentialsBaseOptions options) Creates Credentials with a password generated and stored in Secrets Manager.static Credentials
fromPassword
(String username, SecretValue password) Creates Credentials from a password.static Credentials
fromSecret
(ISecret secret) Creates Credentials from an existing Secrets ManagerSecret
(orDatabaseSecret
).static Credentials
fromSecret
(ISecret secret, String username) Creates Credentials from an existing Secrets ManagerSecret
(orDatabaseSecret
).static Credentials
fromUsername
(String username) Creates Credentials for the given username, and optional password and key.static Credentials
fromUsername
(String username, CredentialsFromUsernameOptions options) Creates Credentials for the given username, and optional password and key.abstract IKey
KMS encryption key to encrypt the generated secret.abstract String
The characters to exclude from the generated password.abstract SecretValue
Password.abstract List<ReplicaRegion>
A list of regions where to replicate the generated secret.abstract ISecret
Secret used to instantiate this Login.abstract String
The name to use for the Secret if a new Secret is to be generated in SecretsManager for these Credentials.abstract String
Username.abstract Boolean
Whether the username should be referenced as a string and not as a dynamic reference to the username in the secret.Methods inherited from class software.amazon.jsii.JsiiObject
jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSet
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface software.amazon.jsii.JsiiSerializable
$jsii$toJson
-
Constructor Details
-
Credentials
protected Credentials(software.amazon.jsii.JsiiObjectRef objRef) -
Credentials
protected Credentials(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) -
Credentials
@Stability(Stable) protected Credentials()
-
-
Method Details
-
fromGeneratedSecret
@Stability(Stable) @NotNull public static Credentials fromGeneratedSecret(@NotNull String username, @Nullable CredentialsBaseOptions options) Creates Credentials with a password generated and stored in Secrets Manager.- Parameters:
username
- This parameter is required.options
-
-
fromGeneratedSecret
Creates Credentials with a password generated and stored in Secrets Manager.- Parameters:
username
- This parameter is required.
-
fromPassword
@Stability(Stable) @NotNull public static Credentials fromPassword(@NotNull String username, @NotNull SecretValue password) Creates Credentials from a password.Do not put passwords in your CDK code directly.
- Parameters:
username
- This parameter is required.password
- This parameter is required.
-
fromSecret
@Stability(Stable) @NotNull public static Credentials fromSecret(@NotNull ISecret secret, @Nullable String username) Creates Credentials from an existing Secrets ManagerSecret
(orDatabaseSecret
).The Secret must be a JSON string with a
username
andpassword
field:{ ... "username": <required: username>, "password": <required: password>, }
- Parameters:
secret
- The secret where the credentials are stored. This parameter is required.username
- The username defined in the secret.
-
fromSecret
Creates Credentials from an existing Secrets ManagerSecret
(orDatabaseSecret
).The Secret must be a JSON string with a
username
andpassword
field:{ ... "username": <required: username>, "password": <required: password>, }
- Parameters:
secret
- The secret where the credentials are stored. This parameter is required.
-
fromUsername
@Stability(Stable) @NotNull public static Credentials fromUsername(@NotNull String username, @Nullable CredentialsFromUsernameOptions options) Creates Credentials for the given username, and optional password and key.If no password is provided, one will be generated and stored in Secrets Manager.
- Parameters:
username
- This parameter is required.options
-
-
fromUsername
Creates Credentials for the given username, and optional password and key.If no password is provided, one will be generated and stored in Secrets Manager.
- Parameters:
username
- This parameter is required.
-
getUsername
Username. -
getEncryptionKey
KMS encryption key to encrypt the generated secret.Default: - default master key
-
getExcludeCharacters
The characters to exclude from the generated password.Only used if
invalid @link
password
Default: - the DatabaseSecret default exclude character set (" %+~`#$invalid input: '&'*()|[]{}:;invalid input: '<'>?!'/
-
getPassword
Password.Do not put passwords in your CDK code directly.
Default: - a Secrets Manager generated password
-
getReplicaRegions
A list of regions where to replicate the generated secret.Default: - Secret is not replicated
-
getSecret
Secret used to instantiate this Login.Default: - none
-
getSecretName
The name to use for the Secret if a new Secret is to be generated in SecretsManager for these Credentials.Default: - A name is generated by CloudFormation.
-
getUsernameAsString
Whether the username should be referenced as a string and not as a dynamic reference to the username in the secret.Default: false
-