A Pulumi package for creating and managing Amazon Web Services (AWS) cloud resources with infrastructure-as-code.
—
Quality
Pending
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Amazon Aurora is a MySQL and PostgreSQL-compatible relational database built for the cloud, combining the performance and availability of high-end commercial databases with the simplicity and cost-effectiveness of open source databases.
import * as aws from "@pulumi/aws";
import * as rds from "@pulumi/aws/rds";Aurora database cluster resource.
const cluster = new aws.rds.Cluster("aurora-cluster", {
engine: "aurora-postgresql",
engineVersion: "15.3",
databaseName: "mydb",
masterUsername: "admin",
masterPassword: dbPassword,
backupRetentionPeriod: 7,
preferredBackupWindow: "03:00-04:00",
skipFinalSnapshot: true,
tags: {
Environment: "production",
},
});Aurora cluster instance (node).
const instance = new aws.rds.ClusterInstance("aurora-instance", {
clusterIdentifier: cluster.id,
instanceClass: "db.r6g.large",
engine: cluster.engine,
engineVersion: cluster.engineVersion,
publiclyAccessible: false,
});const cluster = new aws.rds.Cluster("multi-az-cluster", {
engine: "aurora-mysql",
engineVersion: "8.0.mysql_aurora.3.04.0",
databaseName: "mydb",
masterUsername: "admin",
masterPassword: dbPassword,
backupRetentionPeriod: 14,
preferredBackupWindow: "03:00-04:00",
availabilityZones: ["us-west-2a", "us-west-2b", "us-west-2c"],
});
// Create multiple instances for high availability
const instances = ["primary", "replica1", "replica2"].map((name, i) =>
new aws.rds.ClusterInstance(`aurora-instance-${name}`, {
clusterIdentifier: cluster.id,
instanceClass: "db.r6g.xlarge",
engine: cluster.engine,
engineVersion: cluster.engineVersion,
publiclyAccessible: false,
})
);const cluster = new aws.rds.Cluster("serverless-cluster", {
engine: "aurora-postgresql",
engineMode: "provisioned",
engineVersion: "15.3",
databaseName: "mydb",
masterUsername: "admin",
masterPassword: dbPassword,
serverlessv2ScalingConfiguration: {
maxCapacity: 2.5,
minCapacity: 0.5,
},
});
const instance = new aws.rds.ClusterInstance("serverless-instance", {
clusterIdentifier: cluster.id,
instanceClass: "db.serverless",
engine: cluster.engine,
engineVersion: cluster.engineVersion,
});const globalCluster = new aws.rds.GlobalCluster("global", {
globalClusterIdentifier: "my-global-cluster",
engine: "aurora-postgresql",
engineVersion: "15.3",
databaseName: "mydb",
});
const primaryCluster = new aws.rds.Cluster("primary", {
engine: globalCluster.engine,
engineVersion: globalCluster.engineVersion,
databaseName: globalCluster.databaseName,
masterUsername: "admin",
masterPassword: dbPassword,
globalClusterIdentifier: globalCluster.id,
}, { provider: primaryProvider });
const secondaryCluster = new aws.rds.Cluster("secondary", {
engine: globalCluster.engine,
engineVersion: globalCluster.engineVersion,
globalClusterIdentifier: globalCluster.id,
}, { provider: secondaryProvider, dependsOn: [primaryCluster] });const monitoringRole = new aws.iam.Role("rds-monitoring", {
assumeRolePolicy: JSON.stringify({
Version: "2012-10-17",
Statement: [{
Action: "sts:AssumeRole",
Principal: {
Service: "monitoring.rds.amazonaws.com",
},
Effect: "Allow",
}],
}),
});
new aws.iam.RolePolicyAttachment("rds-monitoring-attachment", {
role: monitoringRole.name,
policyArn: "arn:aws:iam::aws:policy/service-role/AmazonRDSEnhancedMonitoringRole",
});
const cluster = new aws.rds.Cluster("monitored-cluster", {
engine: "aurora-postgresql",
engineVersion: "15.3",
masterUsername: "admin",
masterPassword: dbPassword,
enabledCloudwatchLogsExports: ["postgresql"],
});
const instance = new aws.rds.ClusterInstance("monitored-instance", {
clusterIdentifier: cluster.id,
instanceClass: "db.r6g.large",
engine: cluster.engine,
monitoringInterval: 60,
monitoringRoleArn: monitoringRole.arn,
});engine - Database engine (aurora, aurora-mysql, aurora-postgresql)engineVersion - Engine versiondatabaseName - Initial database namemasterUsername - Master user namemasterPassword - Master passwordbackupRetentionPeriod - Backup retention in days (1-35)preferredBackupWindow - Daily backup time windowavailabilityZones - List of AZs for the clusterstorageEncrypted - Enable encryption at restkmsKeyId - KMS key for encryptionclusterIdentifier - Cluster identifierinstanceClass - Instance size (db.r6g.large, db.serverless, etc.)engine - Database enginepubliclyAccessible - Enable public accessmonitoringInterval - Enhanced monitoring interval (0, 1, 5, 10, 15, 30, 60)monitoringRoleArn - IAM role for enhanced monitoringid - Cluster/instance identifierarn - ARN of the cluster/instanceendpoint - Writer endpoint for the clusterreaderEndpoint - Reader endpoint for read replicasport - Database portInstall with Tessl CLI
npx tessl i tessl/npm-pulumi--aws@7.16.0