Skip to content

Resource: awsNeptuneGlobalCluster

Manages a Neptune Global Cluster. A global cluster consists of one primary region and up to five read-only secondary regions. You issue write operations directly to the primary cluster in the primary region and Amazon Neptune automatically replicates the data to the secondary regions using dedicated infrastructure.

More information about Neptune Global Clusters can be found in the Neptune User Guide.

Example Usage

New Neptune Global Cluster

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as aws from "./.gen/providers/aws";
const awsPrimary = new aws.provider.AwsProvider(this, "aws", {
  alias: "primary",
  region: "us-east-2",
});
const awsSecondary = new aws.provider.AwsProvider(this, "aws_1", {
  alias: "secondary",
  region: "us-east-1",
});
const awsNeptuneGlobalClusterExample =
  new aws.neptuneGlobalCluster.NeptuneGlobalCluster(this, "example", {
    engine: "neptune",
    engineVersion: "1.2.0.0",
    globalClusterIdentifier: "global-test",
  });
const awsNeptuneClusterPrimary = new aws.neptuneCluster.NeptuneCluster(
  this,
  "primary",
  {
    clusterIdentifier: "test-primary-cluster",
    engine: awsNeptuneGlobalClusterExample.engine,
    engineVersion: awsNeptuneGlobalClusterExample.engineVersion,
    globalClusterIdentifier: awsNeptuneGlobalClusterExample.id,
    neptuneSubnetGroupName: "default",
    provider: `\${${awsPrimary.fqn}}`,
  }
);
const awsNeptuneClusterSecondary = new aws.neptuneCluster.NeptuneCluster(
  this,
  "secondary",
  {
    clusterIdentifier: "test-secondary-cluster",
    engine: awsNeptuneGlobalClusterExample.engine,
    engineVersion: awsNeptuneGlobalClusterExample.engineVersion,
    globalClusterIdentifier: awsNeptuneGlobalClusterExample.id,
    neptuneSubnetGroupName: "default",
    provider: `\${${awsSecondary.fqn}}`,
  }
);
const awsNeptuneClusterInstancePrimary =
  new aws.neptuneClusterInstance.NeptuneClusterInstance(this, "primary_5", {
    clusterIdentifier: awsNeptuneClusterPrimary.id,
    engine: awsNeptuneGlobalClusterExample.engine,
    engineVersion: awsNeptuneGlobalClusterExample.engineVersion,
    identifier: "test-primary-cluster-instance",
    instanceClass: "db.r5.large",
    neptuneSubnetGroupName: "default",
    provider: `\${${awsPrimary.fqn}}`,
  });
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
awsNeptuneClusterInstancePrimary.overrideLogicalId("primary");
const awsNeptuneClusterInstanceSecondary =
  new aws.neptuneClusterInstance.NeptuneClusterInstance(this, "secondary_6", {
    clusterIdentifier: awsNeptuneClusterSecondary.id,
    depends_on: [`\${${awsNeptuneClusterInstancePrimary.fqn}}`],
    engine: awsNeptuneGlobalClusterExample.engine,
    engineVersion: awsNeptuneGlobalClusterExample.engineVersion,
    identifier: "test-secondary-cluster-instance",
    instanceClass: "db.r5.large",
    neptuneSubnetGroupName: "default",
    provider: `\${${awsSecondary.fqn}}`,
  });
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
awsNeptuneClusterInstanceSecondary.overrideLogicalId("secondary");

New Global Cluster From Existing DB Cluster

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as aws from "./.gen/providers/aws";
const awsNeptuneClusterExample = new aws.neptuneCluster.NeptuneCluster(
  this,
  "example",
  {}
);
awsNeptuneClusterExample.addOverride("lifecycle", [
  {
    ignore_changes: ["${global_cluster_identifier}"],
  },
]);
const awsNeptuneGlobalClusterExample =
  new aws.neptuneGlobalCluster.NeptuneGlobalCluster(this, "example_1", {
    globalClusterIdentifier: "example",
    sourceDbClusterIdentifier: awsNeptuneClusterExample.arn,
  });
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
awsNeptuneGlobalClusterExample.overrideLogicalId("example");

Argument Reference

The following arguments are supported:

  • globalClusterIdentifier - (Required, Forces new resources) The global cluster identifier.
  • deletionProtection - (Optional) If the Global Cluster should have deletion protection enabled. The database can't be deleted when this value is set to true. The default is false.
  • engine - (Optional, Forces new resources) Name of the database engine to be used for this DB cluster. Terraform will only perform drift detection if a configuration value is provided. Current Valid values: neptune. Conflicts with sourceDbClusterIdentifier.
  • engineVersion - (Optional) Engine version of the global database. Upgrading the engine version will result in all cluster members being immediately updated and will.
  • NOTE: Upgrading major versions is not supported.
  • sourceDbClusterIdentifier - (Optional) Amazon Resource Name (ARN) to use as the primary DB Cluster of the Global Cluster on creation. Terraform cannot perform drift detection of this value.
  • storageEncrypted - (Optional, Forces new resources) Specifies whether the DB cluster is encrypted. The default is false unless sourceDbClusterIdentifier is specified and encrypted. Terraform will only perform drift detection if a configuration value is provided.

Timeouts

The timeouts block allows you to specify timeouts for certain actions:

  • create - (Defaults to 5 mins) Used when creating the Global Cluster
  • update - (Defaults to 120 mins) Used when updating the Global Cluster members (time is per member)
  • delete - (Defaults to 5 mins) Used when deleting the Global Cluster members (time is per member)

Attributes Reference

In addition to all arguments above, the following attributes are exported:

  • arn - Global Cluster Amazon Resource Name (ARN)
  • globalClusterMembers - Set of objects containing Global Cluster members.
  • dbClusterArn - Amazon Resource Name (ARN) of member DB Cluster.
  • isWriter - Whether the member is the primary DB Cluster.
  • globalClusterResourceId - AWS Region-unique, immutable identifier for the global database cluster. This identifier is found in AWS CloudTrail log entries whenever the AWS KMS key for the DB cluster is accessed.
  • id - Neptune Global Cluster.

Import

awsNeptuneGlobalCluster can be imported by using the Global Cluster identifier, e.g.

$ terraform import aws_neptune_global_cluster.example example

Certain resource arguments, like sourceDbClusterIdentifier, do not have an API method for reading the information after creation. If the argument is set in the Terraform configuration on an imported resource, Terraform will always show a difference. To workaround this behavior, either omit the argument from the Terraform configuration or use ignoreChanges to hide the difference, e.g.

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as aws from "./.gen/providers/aws";
const awsNeptuneGlobalClusterExample =
  new aws.neptuneGlobalCluster.NeptuneGlobalCluster(this, "example", {});
awsNeptuneGlobalClusterExample.addOverride("lifecycle", [
  {
    ignore_changes: ["${source_db_cluster_identifier}"],
  },
]);