CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-pulumi--aws

A Pulumi package for creating and managing Amazon Web Services (AWS) cloud resources with infrastructure-as-code.

Pending

Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

Overview
Eval results
Files

aurora.mddocs/database/

Amazon Aurora

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.

Package

import * as aws from "@pulumi/aws";
import * as rds from "@pulumi/aws/rds";

Key Resources

Cluster

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",
    },
});

Cluster Instance

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,
});

Common Patterns

Multi-AZ Aurora Cluster

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,
    })
);

Aurora Serverless v2

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,
});

Aurora Global Database

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] });

Aurora with Enhanced Monitoring

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,
});

Key Properties

Cluster Properties

  • engine - Database engine (aurora, aurora-mysql, aurora-postgresql)
  • engineVersion - Engine version
  • databaseName - Initial database name
  • masterUsername - Master user name
  • masterPassword - Master password
  • backupRetentionPeriod - Backup retention in days (1-35)
  • preferredBackupWindow - Daily backup time window
  • availabilityZones - List of AZs for the cluster
  • storageEncrypted - Enable encryption at rest
  • kmsKeyId - KMS key for encryption

Instance Properties

  • clusterIdentifier - Cluster identifier
  • instanceClass - Instance size (db.r6g.large, db.serverless, etc.)
  • engine - Database engine
  • publiclyAccessible - Enable public access
  • monitoringInterval - Enhanced monitoring interval (0, 1, 5, 10, 15, 30, 60)
  • monitoringRoleArn - IAM role for enhanced monitoring

Output Properties

  • id - Cluster/instance identifier
  • arn - ARN of the cluster/instance
  • endpoint - Writer endpoint for the cluster
  • readerEndpoint - Reader endpoint for read replicas
  • port - Database port

Use Cases

  • High-Performance Applications: Low-latency, high-throughput database
  • Multi-Region Apps: Global database for worldwide distribution
  • Scalable Workloads: Auto-scaling with Serverless v2
  • Read-Heavy Workloads: Multiple read replicas
  • Mission-Critical Systems: Multi-AZ high availability

Related Services

  • RDS - Standard RDS instances
  • DynamoDB - NoSQL database
  • Secrets Manager - Secure password storage
  • VPC - Network isolation

Install with Tessl CLI

npx tessl i tessl/npm-pulumi--aws@7.16.0

docs

index.md

quickstart.md

README.md

tile.json