GlobalCluster class
Manages an DocumentDB 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 DocumentDB automatically replicates the data to the secondary regions using dedicated infrastructure.
More information about DocumentDB Global Clusters can be found in the DocumentDB Developer Guide.
Example Usage
New DocumentDB Global Cluster
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const example = new aws.docdb.GlobalCluster("example", {
globalClusterIdentifier: "global-test",
engine: "docdb",
engineVersion: "4.0.0",
});
const primary = new aws.docdb.Cluster("primary", {
engine: example.engine,
engineVersion: example.engineVersion,
clusterIdentifier: "test-primary-cluster",
masterUsername: "username",
masterPassword: "somepass123",
globalClusterIdentifier: example.id,
dbSubnetGroupName: "default",
});
const primaryClusterInstance = new aws.docdb.ClusterInstance("primary", {
engine: example.engine,
identifier: "test-primary-cluster-instance",
clusterIdentifier: primary.id,
instanceClass: "db.r5.large",
});
const secondary = new aws.docdb.Cluster("secondary", {
engine: example.engine,
engineVersion: example.engineVersion,
clusterIdentifier: "test-secondary-cluster",
globalClusterIdentifier: example.id,
dbSubnetGroupName: "default",
}, {
dependsOn: [primary],
});
const secondaryClusterInstance = new aws.docdb.ClusterInstance("secondary", {
engine: example.engine,
identifier: "test-secondary-cluster-instance",
clusterIdentifier: secondary.id,
instanceClass: "db.r5.large",
}, {
dependsOn: [primaryClusterInstance],
});
import pulumi
import pulumi_aws as aws
example = aws.docdb.GlobalCluster("example",
global_cluster_identifier="global-test",
engine="docdb",
engine_version="4.0.0")
primary = aws.docdb.Cluster("primary",
engine=example.engine,
engine_version=example.engine_version,
cluster_identifier="test-primary-cluster",
master_username="username",
master_password="somepass123",
global_cluster_identifier=example.id,
db_subnet_group_name="default")
primary_cluster_instance = aws.docdb.ClusterInstance("primary",
engine=example.engine,
identifier="test-primary-cluster-instance",
cluster_identifier=primary.id,
instance_class="db.r5.large")
secondary = aws.docdb.Cluster("secondary",
engine=example.engine,
engine_version=example.engine_version,
cluster_identifier="test-secondary-cluster",
global_cluster_identifier=example.id,
db_subnet_group_name="default",
opts = pulumi.ResourceOptions(depends_on=[primary]))
secondary_cluster_instance = aws.docdb.ClusterInstance("secondary",
engine=example.engine,
identifier="test-secondary-cluster-instance",
cluster_identifier=secondary.id,
instance_class="db.r5.large",
opts = pulumi.ResourceOptions(depends_on=[primary_cluster_instance]))
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
return await Deployment.RunAsync(() =>
{
var example = new Aws.DocDB.GlobalCluster("example", new()
{
GlobalClusterIdentifier = "global-test",
Engine = "docdb",
EngineVersion = "4.0.0",
});
var primary = new Aws.DocDB.Cluster("primary", new()
{
Engine = example.Engine,
EngineVersion = example.EngineVersion,
ClusterIdentifier = "test-primary-cluster",
MasterUsername = "username",
MasterPassword = "somepass123",
GlobalClusterIdentifier = example.Id,
DbSubnetGroupName = "default",
});
var primaryClusterInstance = new Aws.DocDB.ClusterInstance("primary", new()
{
Engine = example.Engine,
Identifier = "test-primary-cluster-instance",
ClusterIdentifier = primary.Id,
InstanceClass = "db.r5.large",
});
var secondary = new Aws.DocDB.Cluster("secondary", new()
{
Engine = example.Engine,
EngineVersion = example.EngineVersion,
ClusterIdentifier = "test-secondary-cluster",
GlobalClusterIdentifier = example.Id,
DbSubnetGroupName = "default",
}, new CustomResourceOptions
{
DependsOn =
{
primary,
},
});
var secondaryClusterInstance = new Aws.DocDB.ClusterInstance("secondary", new()
{
Engine = example.Engine,
Identifier = "test-secondary-cluster-instance",
ClusterIdentifier = secondary.Id,
InstanceClass = "db.r5.large",
}, new CustomResourceOptions
{
DependsOn =
{
primaryClusterInstance,
},
});
});
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/docdb"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
example, err := docdb.NewGlobalCluster(ctx, "example", &docdb.GlobalClusterArgs{
GlobalClusterIdentifier: pulumi.String("global-test"),
Engine: pulumi.String("docdb"),
EngineVersion: pulumi.String("4.0.0"),
})
if err != nil {
return err
}
primary, err := docdb.NewCluster(ctx, "primary", &docdb.ClusterArgs{
Engine: example.Engine,
EngineVersion: example.EngineVersion,
ClusterIdentifier: pulumi.String("test-primary-cluster"),
MasterUsername: pulumi.String("username"),
MasterPassword: pulumi.String("somepass123"),
GlobalClusterIdentifier: example.ID().ToIDOutput().ToStringOutput(),
DbSubnetGroupName: pulumi.String("default"),
})
if err != nil {
return err
}
primaryClusterInstance, err := docdb.NewClusterInstance(ctx, "primary", &docdb.ClusterInstanceArgs{
Engine: example.Engine,
Identifier: pulumi.String("test-primary-cluster-instance"),
ClusterIdentifier: primary.ID().ToIDOutput().ToStringOutput(),
InstanceClass: pulumi.String("db.r5.large"),
})
if err != nil {
return err
}
secondary, err := docdb.NewCluster(ctx, "secondary", &docdb.ClusterArgs{
Engine: example.Engine,
EngineVersion: example.EngineVersion,
ClusterIdentifier: pulumi.String("test-secondary-cluster"),
GlobalClusterIdentifier: example.ID().ToIDOutput().ToStringOutput(),
DbSubnetGroupName: pulumi.String("default"),
}, pulumi.DependsOn([]pulumi.Resource{
primary,
}))
if err != nil {
return err
}
_, err = docdb.NewClusterInstance(ctx, "secondary", &docdb.ClusterInstanceArgs{
Engine: example.Engine,
Identifier: pulumi.String("test-secondary-cluster-instance"),
ClusterIdentifier: secondary.ID().ToIDOutput().ToStringOutput(),
InstanceClass: pulumi.String("db.r5.large"),
}, pulumi.DependsOn([]pulumi.Resource{
primaryClusterInstance,
}))
if err != nil {
return err
}
return nil
})
}
pulumi {
required_providers {
aws = {
source = "pulumi/aws"
}
}
}
resource "aws_docdb_globalcluster" "example" {
global_cluster_identifier = "global-test"
engine = "docdb"
engine_version = "4.0.0"
}
resource "aws_docdb_cluster" "primary" {
engine = aws_docdb_globalcluster.example.engine
engine_version = aws_docdb_globalcluster.example.engine_version
cluster_identifier = "test-primary-cluster"
master_username = "username"
master_password = "somepass123"
global_cluster_identifier = aws_docdb_globalcluster.example.id
db_subnet_group_name = "default"
}
resource "aws_docdb_clusterinstance" "primary" {
engine = aws_docdb_globalcluster.example.engine
identifier = "test-primary-cluster-instance"
cluster_identifier = aws_docdb_cluster.primary.id
instance_class = "db.r5.large"
}
resource "aws_docdb_cluster" "secondary" {
depends_on = [aws_docdb_cluster.primary]
engine = aws_docdb_globalcluster.example.engine
engine_version = aws_docdb_globalcluster.example.engine_version
cluster_identifier = "test-secondary-cluster"
global_cluster_identifier = aws_docdb_globalcluster.example.id
db_subnet_group_name = "default"
}
resource "aws_docdb_clusterinstance" "secondary" {
depends_on = [aws_docdb_clusterinstance.primary]
engine = aws_docdb_globalcluster.example.engine
identifier = "test-secondary-cluster-instance"
cluster_identifier = aws_docdb_cluster.secondary.id
instance_class = "db.r5.large"
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.docdb.GlobalCluster;
import com.pulumi.aws.docdb.GlobalClusterArgs;
import com.pulumi.aws.docdb.Cluster;
import com.pulumi.aws.docdb.ClusterArgs;
import com.pulumi.aws.docdb.ClusterInstance;
import com.pulumi.aws.docdb.ClusterInstanceArgs;
import com.pulumi.resources.CustomResourceOptions;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var example = new GlobalCluster("example", GlobalClusterArgs.builder()
.globalClusterIdentifier("global-test")
.engine("docdb")
.engineVersion("4.0.0")
.build());
var primary = new Cluster("primary", ClusterArgs.builder()
.engine(example.engine())
.engineVersion(example.engineVersion())
.clusterIdentifier("test-primary-cluster")
.masterUsername("username")
.masterPassword("somepass123")
.globalClusterIdentifier(example.id())
.dbSubnetGroupName("default")
.build());
var primaryClusterInstance = new ClusterInstance("primaryClusterInstance", ClusterInstanceArgs.builder()
.engine(example.engine())
.identifier("test-primary-cluster-instance")
.clusterIdentifier(primary.id())
.instanceClass("db.r5.large")
.build());
var secondary = new Cluster("secondary", ClusterArgs.builder()
.engine(example.engine())
.engineVersion(example.engineVersion())
.clusterIdentifier("test-secondary-cluster")
.globalClusterIdentifier(example.id())
.dbSubnetGroupName("default")
.build(), CustomResourceOptions.builder()
.dependsOn(primary)
.build());
var secondaryClusterInstance = new ClusterInstance("secondaryClusterInstance", ClusterInstanceArgs.builder()
.engine(example.engine())
.identifier("test-secondary-cluster-instance")
.clusterIdentifier(secondary.id())
.instanceClass("db.r5.large")
.build(), CustomResourceOptions.builder()
.dependsOn(primaryClusterInstance)
.build());
}
}
resources:
example:
type: aws:docdb:GlobalCluster
properties:
globalClusterIdentifier: global-test
engine: docdb
engineVersion: 4.0.0
primary:
type: aws:docdb:Cluster
properties:
engine: ${example.engine}
engineVersion: ${example.engineVersion}
clusterIdentifier: test-primary-cluster
masterUsername: username
masterPassword: somepass123
globalClusterIdentifier: ${example.id}
dbSubnetGroupName: default
primaryClusterInstance:
type: aws:docdb:ClusterInstance
name: primary
properties:
engine: ${example.engine}
identifier: test-primary-cluster-instance
clusterIdentifier: ${primary.id}
instanceClass: db.r5.large
secondary:
type: aws:docdb:Cluster
properties:
engine: ${example.engine}
engineVersion: ${example.engineVersion}
clusterIdentifier: test-secondary-cluster
globalClusterIdentifier: ${example.id}
dbSubnetGroupName: default
options:
dependsOn:
- ${primary}
secondaryClusterInstance:
type: aws:docdb:ClusterInstance
name: secondary
properties:
engine: ${example.engine}
identifier: test-secondary-cluster-instance
clusterIdentifier: ${secondary.id}
instanceClass: db.r5.large
options:
dependsOn:
- ${primaryClusterInstance}
New Global Cluster From Existing DB Cluster
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const example = new aws.docdb.Cluster("example", {}, {
ignoreChanges: ["globalClusterIdentifier"],
});
const exampleGlobalCluster = new aws.docdb.GlobalCluster("example", {
globalClusterIdentifier: "example",
sourceDbClusterIdentifier: example.arn,
});
import pulumi
import pulumi_aws as aws
example = aws.docdb.Cluster("example", opts = pulumi.ResourceOptions(ignore_changes=["globalClusterIdentifier"]))
example_global_cluster = aws.docdb.GlobalCluster("example",
global_cluster_identifier="example",
source_db_cluster_identifier=example.arn)
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
return await Deployment.RunAsync(() =>
{
var example = new Aws.DocDB.Cluster("example", new()
{
}, new CustomResourceOptions
{
IgnoreChanges =
{
"globalClusterIdentifier",
},
});
var exampleGlobalCluster = new Aws.DocDB.GlobalCluster("example", new()
{
GlobalClusterIdentifier = "example",
SourceDbClusterIdentifier = example.Arn,
});
});
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/docdb"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
example, err := docdb.NewCluster(ctx, "example", nil, pulumi.IgnoreChanges([]string{
"globalClusterIdentifier",
}))
if err != nil {
return err
}
_, err = docdb.NewGlobalCluster(ctx, "example", &docdb.GlobalClusterArgs{
GlobalClusterIdentifier: pulumi.String("example"),
SourceDbClusterIdentifier: example.Arn,
})
if err != nil {
return err
}
return nil
})
}
pulumi {
required_providers {
aws = {
source = "pulumi/aws"
}
}
}
resource "aws_docdb_cluster" "example" {
lifecycle {
ignore_changes = [globalClusterIdentifier]
}
}
resource "aws_docdb_globalcluster" "example" {
global_cluster_identifier = "example"
source_db_cluster_identifier = aws_docdb_cluster.example.arn
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.docdb.Cluster;
import com.pulumi.aws.docdb.ClusterArgs;
import com.pulumi.aws.docdb.GlobalCluster;
import com.pulumi.aws.docdb.GlobalClusterArgs;
import com.pulumi.resources.CustomResourceOptions;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var example = new Cluster("example", ClusterArgs.Empty, CustomResourceOptions.builder()
.ignoreChanges("globalClusterIdentifier")
.build());
var exampleGlobalCluster = new GlobalCluster("exampleGlobalCluster", GlobalClusterArgs.builder()
.globalClusterIdentifier("example")
.sourceDbClusterIdentifier(example.arn())
.build());
}
}
resources:
example:
type: aws:docdb:Cluster
options:
ignoreChanges:
- globalClusterIdentifier
exampleGlobalCluster:
type: aws:docdb:GlobalCluster
name: example
properties:
globalClusterIdentifier: example
sourceDbClusterIdentifier: ${example.arn}
Import
Using pulumi import, import aws.docdb.GlobalCluster using the Global Cluster identifier. For example:
$ pulumi import aws:docdb/globalCluster:GlobalCluster 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 Pulumi program on an imported resource, Pulumi will always show a difference. To workaround this behavior, either omit the argument from the Pulumi program or use ignoreChanges to hide the difference. For example:
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const example = new aws.docdb.GlobalCluster("example", {}, {
ignoreChanges: ["sourceDbClusterIdentifier"],
});
import pulumi
import pulumi_aws as aws
example = aws.docdb.GlobalCluster("example", opts = pulumi.ResourceOptions(ignore_changes=["sourceDbClusterIdentifier"]))
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
return await Deployment.RunAsync(() =>
{
var example = new Aws.DocDB.GlobalCluster("example", new()
{
}, new CustomResourceOptions
{
IgnoreChanges =
{
"sourceDbClusterIdentifier",
},
});
});
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/docdb"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := docdb.NewGlobalCluster(ctx, "example", nil, pulumi.IgnoreChanges([]string{
"sourceDbClusterIdentifier",
}))
if err != nil {
return err
}
return nil
})
}
pulumi {
required_providers {
aws = {
source = "pulumi/aws"
}
}
}
resource "aws_docdb_globalcluster" "example" {
lifecycle {
ignore_changes = [sourceDbClusterIdentifier]
}
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.docdb.GlobalCluster;
import com.pulumi.aws.docdb.GlobalClusterArgs;
import com.pulumi.resources.CustomResourceOptions;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var example = new GlobalCluster("example", GlobalClusterArgs.Empty, CustomResourceOptions.builder()
.ignoreChanges("sourceDbClusterIdentifier")
.build());
}
}
resources:
example:
type: aws:docdb:GlobalCluster
options:
ignoreChanges:
- sourceDbClusterIdentifier
Constructors
- GlobalCluster(String name, {GlobalClusterArgs? args, CustomResourceOptions? options})
-
Creates a new GlobalCluster.
nameThe Pulumi resource name.argsArguments used to configure this GlobalCluster. The set of arguments for GlobalCluster.optionsResource options controlling this resource's behavior. - GlobalCluster.reference(String urn)
- Creates a typed reference to an existing GlobalCluster resource.
Properties
-
arn
↔ Output<
String> -
Global Cluster ARN
latefinal
-
childResources
→ Set<
Resource> -
finalinherited
-
completionSources
↔ Map<
String, IOutputCompletionSource> -
latefinalinherited
-
databaseName
↔ Output<
String?> -
Name for an automatically created database on cluster creation.
latefinal
-
deletionProtection
↔ Output<
bool?> -
If the Global Cluster should have deletion protection enabled. The database can't be deleted when this value is set to
true. The default isfalse.latefinal -
engine
↔ Output<
String> -
Name of the database engine to be used for this DB cluster. The provider will only perform drift detection if a configuration value is provided. Current Valid values:
docdb. Defaults todocdb. Conflicts withsourceDbClusterIdentifier.latefinal -
engineVersion
↔ Output<
String> -
Engine version of the global database. Upgrading the engine version will result in all cluster members being immediately updated and will.
latefinal
-
globalClusterIdentifier
↔ Output<
String> -
The global cluster identifier.
latefinal
-
globalClusterMembers
↔ Output<
List< GlobalClusterGlobalClusterMember> > -
Set of objects containing Global Cluster members.
latefinal
-
globalClusterResourceId
↔ Output<
String> -
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.
latefinal
- hashCode → int
-
The hash code for this object.
no setterinherited
-
id
↔ Output<
String> -
getter/setter pairinherited
- isCustom → bool
-
Returns whether this resource is provider-managed.
no setterinherited
- isProtected → bool
-
Returns whether this resource is protected from deletion.
no setterinherited
- isRemote → bool
-
Whether this resource is registered as remote.
no setterinherited
- isResourceReference → bool
-
Whether this instance represents a resource value returned over RPC.
finalinherited
-
region
↔ Output<
String> -
Region where this resource will be managed. Defaults to the Region set in the provider configuration.
latefinal
-
resourceTransforms
→ List<
ResourceTransform> -
Inherited/explicit async transforms.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
sourceDbClusterIdentifier
↔ Output<
String> -
ARN to use as the primary DB Cluster of the Global Cluster on creation. Pulumi cannot perform drift detection of this value.
latefinal
-
status
↔ Output<
String> -
latefinal
-
storageEncrypted
↔ Output<
bool> -
Specifies whether the DB cluster is encrypted. The default is
falseunlesssourceDbClusterIdentifieris specified and encrypted. The provider will only perform drift detection if a configuration value is provided.latefinal -
transformations
→ List<
ResourceTransformation> -
Inherited/explicit legacy transformations.
no setterinherited
-
urn
↔ Output<
String> -
latefinalinherited
Methods
-
failId(
Object error) → void -
Completes this resource ID with an error when registration fails.
inherited
-
failOutputs(
Object error) → void -
Completes all output properties with
error.inherited -
failUrn(
Object error) → void -
Completes this resource URN with an error when registration fails.
inherited
-
getProvider(
String moduleMember) → ProviderResource? -
Returns provider for
moduleMember's package, if configured.inherited -
getResourceName(
) → String -
Returns this resource's logical name.
inherited
-
getResourceType(
) → String -
Returns this resource's Pulumi type token.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
registerOutput<
T> (String propertyName, {Object? decoder(Object?)?, bool isSecret = false}) → Output< T> -
Registers a dynamic output property for this resource.
inherited
-
resolveId(
String? value, {required bool isKnown}) → void -
Resolves the provider-assigned ID for this resource.
inherited
-
resolveOutputs(
Struct outputs) → void -
Resolves all output properties from a monitor response payload.
inherited
-
resolveUrn(
String value) → void -
Resolves this resource's URN once assigned by the engine.
inherited
-
serializeProperties(
Map< String, dynamic> properties) → Future<Struct> -
Serializes resource properties for RPC transmission.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
get(
String name, Input< String> id, {GlobalClusterState? state, CustomResourceOptions? options}) → GlobalCluster -
Gets an existing GlobalCluster resource's state with the given
nameandid.