Interface DatabaseSecretProps

All Superinterfaces:
software.amazon.jsii.JsiiSerializable
All Known Implementing Classes:
DatabaseSecretProps.Jsii$Proxy

@Generated(value="jsii-pacmak/1.97.0 (build 729de35)", date="2024-04-18T17:54:23.449Z") @Stability(Stable) public interface DatabaseSecretProps extends software.amazon.jsii.JsiiSerializable
Construction properties for a DatabaseSecret.

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("QueryGetDemosRdsResolver", 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("MutationAddDemoRdsResolver", 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());
 
  • Method Details

    • getUsername

      @Stability(Stable) @NotNull String getUsername()
      The username.
    • getDbname

      @Stability(Stable) @Nullable default String getDbname()
      The database name, if not using the default one.

      Default: - whatever the secret generates after the attach method is run

    • getEncryptionKey

      @Stability(Stable) @Nullable default IKey getEncryptionKey()
      The KMS key to use to encrypt the secret.

      Default: default master key

    • getExcludeCharacters

      @Stability(Stable) @Nullable default String getExcludeCharacters()
      Characters to not include in the generated password.

      Default: " %+~`#$invalid input: '&'*()|[]{}:;invalid input: '<'>?!'/@\"\\"

    • getMasterSecret

      @Stability(Stable) @Nullable default ISecret getMasterSecret()
      The master secret which will be used to rotate this secret.

      Default: - no master secret information will be included

    • getReplaceOnPasswordCriteriaChanges

      @Stability(Stable) @Nullable default Boolean getReplaceOnPasswordCriteriaChanges()
      Whether to replace this secret when the criteria for the password change.

      This is achieved by overriding the logical id of the AWS::SecretsManager::Secret with a hash of the options that influence the password generation. This way a new secret will be created when the password is regenerated and the cluster or instance consuming this secret will have its credentials updated.

      Default: false

    • getReplicaRegions

      @Stability(Stable) @Nullable default List<ReplicaRegion> getReplicaRegions()
      A list of regions where to replicate this secret.

      Default: - Secret is not replicated

    • getSecretName

      @Stability(Stable) @Nullable default String getSecretName()
      A name for the secret.

      Default: - A name is generated by CloudFormation.

    • builder

      @Stability(Stable) static DatabaseSecretProps.Builder builder()
      Returns:
      a DatabaseSecretProps.Builder of DatabaseSecretProps