Does anyone have an example of a Global RDS using ...
# general
b
Does anyone have an example of a Global RDS using Aurora?
b
Is this available to do in AWS?
Ah I see how to do it
I can try and make this into an example tonight
b
Thanks @broad-dog-22463
b
I have it building a primary cluster and a secondary cluster
just want to get it adding other secondaries as well
Copy code
import {Config} from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const config = new Config();
const secondaryRegion = config.require("secondaryRegion");

const globalCluster = new aws.rds.GlobalCluster("global-cluster", {
    globalClusterIdentifier: "my-test-global-cluster",
    engine: "aurora",
    engineVersion: "5.6.10a",
});

let instanceEndpoints = new Map();

const cluster = new aws.rds.Cluster("primary-cluster", {
    globalClusterIdentifier: globalCluster.globalClusterIdentifier,
    engineMode: "global",
    engine: "aurora",
    engineVersion: "5.6.10a",
    masterUsername: "MyMasterUser",
    masterPassword: "MyPassword1234!",
    skipFinalSnapshot: true,
});

const clusterInstance = new aws.rds.ClusterInstance("primary-cluster-instance", {
    engine: "aurora",
    instanceClass: aws.rds.InstanceTypes.R5_Large,
    clusterIdentifier: cluster.clusterIdentifier,
});

// Get the primary cluster endpoint - this is used for writes
instanceEndpoints.set("primary", clusterInstance.endpoint);

const provider = new aws.Provider(`${secondaryRegion}-provider`, {
    region: secondaryRegion as aws.Region,
});

const secondaryCluster = new aws.rds.Cluster(`${secondaryRegion}-cluster`, {
    globalClusterIdentifier: globalCluster.globalClusterIdentifier,
    engineMode: "global",
    engine: "aurora",
    skipFinalSnapshot: true,
}, {
    provider: provider,
    dependsOn: [provider, cluster],
});

const secondaryClusterInstance = new aws.rds.ClusterInstance(`${secondaryRegion}-cluster-instance`, {
    engine: "aurora",
    instanceClass: aws.rds.InstanceTypes.R5_Large,
    clusterIdentifier: secondaryCluster.clusterIdentifier,
}, {
    provider: provider,
    dependsOn: [secondaryCluster],
});

// Get the secondary cluster endpoint
instanceEndpoints.set(`secondary-${secondaryRegion}`, secondaryClusterInstance.endpoint);

export const endpointUrls = instanceEndpoints.values();
AWS RDS Global Clusters only supports 1 other region apart from the primary
but that code will do it
b
Thanks @broad-dog-22463
@acceptable-army-69872 check this out
b
I need to male some tweaks as the ordering doesn’t allow easy deletion but that’s an aws issue
I’m going to put together a blog post and an example of how best to do this
But that will allow you to at least test your application
Ping me if you have any q’s
a
👍 👍 👍