Class CfnDBInstance

java.lang.Object
software.amazon.jsii.JsiiObject
software.constructs.Construct
All Implemented Interfaces:
IInspectable, ITaggable, software.amazon.jsii.JsiiSerializable, software.constructs.IConstruct, software.constructs.IDependable

@Generated(value="jsii-pacmak/1.98.0 (build 00b106d)", date="2024-05-08T21:35:10.089Z") @Stability(Stable) public class CfnDBInstance extends CfnResource implements IInspectable, ITaggable
The AWS::Neptune::DBInstance type creates an Amazon Neptune DB instance.

Updating DB Instances

You can set a deletion policy for your DB instance to control how AWS CloudFormation handles the instance when the stack is deleted. For Neptune DB instances, you can choose to retain the instance, to delete the instance, or to create a snapshot of the instance. The default AWS CloudFormation behavior depends on the DBClusterIdentifier property:

  • For AWS::Neptune::DBInstance resources that don't specify the DBClusterIdentifier property, AWS CloudFormation saves a snapshot of the DB instance.
  • For AWS::Neptune::DBInstance resources that do specify the DBClusterIdentifier property, AWS CloudFormation deletes the DB instance.

Deleting DB Instances

If a DB instance is deleted or replaced during an update, AWS CloudFormation deletes all automated snapshots. However, it retains manual DB snapshots. During an update that requires replacement, you can apply a stack policy to prevent DB instances from being replaced.

When properties labeled Update requires: Replacement are updated, AWS CloudFormation first creates a replacement DB instance, changes references from other dependent resources to point to the replacement DB instance, and finally deletes the old DB instance.

We highly recommend that you take a snapshot of the database before updating the stack. If you don't, you lose the data when AWS CloudFormation replaces your DB instance. To preserve your data, perform the following procedure:

  • Deactivate any applications that are using the DB instance so that there's no activity on the DB instance.
  • Create a snapshot of the DB instance.
  • If you want to restore your instance using a DB snapshot, modify the updated template with your DB instance changes and add the DBSnapshotIdentifier property with the ID of the DB snapshot that you want to use.
  • Update the stack.

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.neptune.*;
 CfnDBInstance cfnDBInstance = CfnDBInstance.Builder.create(this, "MyCfnDBInstance")
         .dbInstanceClass("dbInstanceClass")
         // the properties below are optional
         .allowMajorVersionUpgrade(false)
         .autoMinorVersionUpgrade(false)
         .availabilityZone("availabilityZone")
         .dbClusterIdentifier("dbClusterIdentifier")
         .dbInstanceIdentifier("dbInstanceIdentifier")
         .dbParameterGroupName("dbParameterGroupName")
         .dbSnapshotIdentifier("dbSnapshotIdentifier")
         .dbSubnetGroupName("dbSubnetGroupName")
         .preferredMaintenanceWindow("preferredMaintenanceWindow")
         .tags(List.of(CfnTag.builder()
                 .key("key")
                 .value("value")
                 .build()))
         .build();
 

See Also:
  • Field Details

    • CFN_RESOURCE_TYPE_NAME

      @Stability(Stable) public static final String CFN_RESOURCE_TYPE_NAME
      The CloudFormation resource type name for this resource class.
  • Constructor Details

    • CfnDBInstance

      protected CfnDBInstance(software.amazon.jsii.JsiiObjectRef objRef)
    • CfnDBInstance

      protected CfnDBInstance(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
    • CfnDBInstance

      @Stability(Stable) public CfnDBInstance(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull CfnDBInstanceProps 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. This parameter is required.
  • Method Details

    • inspect

      @Stability(Stable) public void inspect(@NotNull TreeInspector inspector)
      Examines the CloudFormation resource and discloses attributes.

      Specified by:
      inspect in interface IInspectable
      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:
      renderProperties in class CfnResource
      Parameters:
      props - This parameter is required.
    • getAttrEndpoint

      @Stability(Stable) @NotNull public String getAttrEndpoint()
      The connection endpoint for the database.

      For example: mystack-mydb-1apw1j4phylrk.cg034hpkmmjt.us-east-2.rds.amazonaws.com .

    • getAttrId

      @Stability(Stable) @NotNull public String getAttrId()
    • getAttrPort

      @Stability(Stable) @NotNull public String getAttrPort()
      The port number on which the database accepts connections.

      For example: 8182 .

    • getCfnProperties

      @Stability(Stable) @NotNull protected Map<String,Object> getCfnProperties()
      Overrides:
      getCfnProperties in class CfnResource
    • getTags

      @Stability(Stable) @NotNull public TagManager getTags()
      Tag Manager which manages the tags for this resource.
      Specified by:
      getTags in interface ITaggable
    • getDbInstanceClass

      @Stability(Stable) @NotNull public String getDbInstanceClass()
      Contains the name of the compute and memory capacity class of the DB instance.
    • setDbInstanceClass

      @Stability(Stable) public void setDbInstanceClass(@NotNull String value)
      Contains the name of the compute and memory capacity class of the DB instance.
    • getAllowMajorVersionUpgrade

      @Stability(Stable) @Nullable public Object getAllowMajorVersionUpgrade()
      Indicates that major version upgrades are allowed.
    • setAllowMajorVersionUpgrade

      @Stability(Stable) public void setAllowMajorVersionUpgrade(@Nullable Boolean value)
      Indicates that major version upgrades are allowed.
    • setAllowMajorVersionUpgrade

      @Stability(Stable) public void setAllowMajorVersionUpgrade(@Nullable IResolvable value)
      Indicates that major version upgrades are allowed.
    • getAutoMinorVersionUpgrade

      @Stability(Stable) @Nullable public Object getAutoMinorVersionUpgrade()
      Indicates that minor version patches are applied automatically.
    • setAutoMinorVersionUpgrade

      @Stability(Stable) public void setAutoMinorVersionUpgrade(@Nullable Boolean value)
      Indicates that minor version patches are applied automatically.
    • setAutoMinorVersionUpgrade

      @Stability(Stable) public void setAutoMinorVersionUpgrade(@Nullable IResolvable value)
      Indicates that minor version patches are applied automatically.
    • getAvailabilityZone

      @Stability(Stable) @Nullable public String getAvailabilityZone()
      Specifies the name of the Availability Zone the DB instance is located in.
    • setAvailabilityZone

      @Stability(Stable) public void setAvailabilityZone(@Nullable String value)
      Specifies the name of the Availability Zone the DB instance is located in.
    • getDbClusterIdentifier

      @Stability(Stable) @Nullable public String getDbClusterIdentifier()
      If the DB instance is a member of a DB cluster, contains the name of the DB cluster that the DB instance is a member of.
    • setDbClusterIdentifier

      @Stability(Stable) public void setDbClusterIdentifier(@Nullable String value)
      If the DB instance is a member of a DB cluster, contains the name of the DB cluster that the DB instance is a member of.
    • getDbInstanceIdentifier

      @Stability(Stable) @Nullable public String getDbInstanceIdentifier()
      Contains a user-supplied database identifier.
    • setDbInstanceIdentifier

      @Stability(Stable) public void setDbInstanceIdentifier(@Nullable String value)
      Contains a user-supplied database identifier.
    • getDbParameterGroupName

      @Stability(Stable) @Nullable public String getDbParameterGroupName()
      The name of an existing DB parameter group or a reference to an AWS::Neptune::DBParameterGroup resource created in the template.
    • setDbParameterGroupName

      @Stability(Stable) public void setDbParameterGroupName(@Nullable String value)
      The name of an existing DB parameter group or a reference to an AWS::Neptune::DBParameterGroup resource created in the template.
    • getDbSnapshotIdentifier

      @Stability(Stable) @Nullable public String getDbSnapshotIdentifier()
      This parameter is not supported.
    • setDbSnapshotIdentifier

      @Stability(Stable) public void setDbSnapshotIdentifier(@Nullable String value)
      This parameter is not supported.
    • getDbSubnetGroupName

      @Stability(Stable) @Nullable public String getDbSubnetGroupName()
      A DB subnet group to associate with the DB instance.
    • setDbSubnetGroupName

      @Stability(Stable) public void setDbSubnetGroupName(@Nullable String value)
      A DB subnet group to associate with the DB instance.
    • getPreferredMaintenanceWindow

      @Stability(Stable) @Nullable public String getPreferredMaintenanceWindow()
      Specifies the weekly time range during which system maintenance can occur, in Universal Coordinated Time (UTC).
    • setPreferredMaintenanceWindow

      @Stability(Stable) public void setPreferredMaintenanceWindow(@Nullable String value)
      Specifies the weekly time range during which system maintenance can occur, in Universal Coordinated Time (UTC).
    • getTagsRaw

      @Stability(Stable) @Nullable public List<CfnTag> getTagsRaw()
      An arbitrary set of tags (key-value pairs) for this DB instance.
    • setTagsRaw

      @Stability(Stable) public void setTagsRaw(@Nullable List<CfnTag> value)
      An arbitrary set of tags (key-value pairs) for this DB instance.