@pulumi/aws
Version:
A Pulumi package for creating and managing Amazon Web Services (AWS) cloud resources.
284 lines • 12.4 kB
JavaScript
;
// *** WARNING: this file was generated by pulumi-language-nodejs. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
Object.defineProperty(exports, "__esModule", { value: true });
exports.Database = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("../utilities");
/**
* Manages a Lightsail database. Use this resource to create and manage fully managed database instances with automated backups, monitoring, and maintenance in Lightsail.
*
* > **Note:** Lightsail is currently only supported in a limited number of AWS Regions, please see ["Regions and Availability Zones"](https://aws.amazon.com/about-aws/global-infrastructure/regional-product-services/) for more details
*
* ## Example Usage
*
* ### Basic MySQL Blueprint
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
*
* const example = new aws.lightsail.Database("example", {
* relationalDatabaseName: "example-database",
* availabilityZone: "us-east-1a",
* masterDatabaseName: "exampledb",
* masterPassword: "examplepassword123",
* masterUsername: "exampleuser",
* blueprintId: "mysql_8_0",
* bundleId: "micro_1_0",
* });
* ```
*
* ### Basic PostgreSQL Blueprint
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
*
* const example = new aws.lightsail.Database("example", {
* relationalDatabaseName: "example-database",
* availabilityZone: "us-east-1a",
* masterDatabaseName: "exampledb",
* masterPassword: "examplepassword123",
* masterUsername: "exampleuser",
* blueprintId: "postgres_12",
* bundleId: "micro_1_0",
* });
* ```
*
* ### Custom Backup and Maintenance Windows
*
* Below is an example that sets a custom backup and maintenance window. Times are specified in UTC. This example will allow daily backups to take place between 16:00 and 16:30 each day. This example also requires any maintenance tasks (anything that would cause an outage, including changing some attributes) to take place on Tuesdays between 17:00 and 17:30. An action taken against this database that would cause an outage will wait until this time window to make the requested changes.
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
*
* const example = new aws.lightsail.Database("example", {
* relationalDatabaseName: "example-database",
* availabilityZone: "us-east-1a",
* masterDatabaseName: "exampledb",
* masterPassword: "examplepassword123",
* masterUsername: "exampleuser",
* blueprintId: "postgres_12",
* bundleId: "micro_1_0",
* preferredBackupWindow: "16:00-16:30",
* preferredMaintenanceWindow: "Tue:17:00-Tue:17:30",
* });
* ```
*
* ### Final Snapshots
*
* To enable creating a final snapshot of your database on deletion, use the `finalSnapshotName` argument to provide a name to be used for the snapshot.
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
*
* const example = new aws.lightsail.Database("example", {
* relationalDatabaseName: "example-database",
* availabilityZone: "us-east-1a",
* masterDatabaseName: "exampledb",
* masterPassword: "examplepassword123",
* masterUsername: "exampleuser",
* blueprintId: "postgres_12",
* bundleId: "micro_1_0",
* preferredBackupWindow: "16:00-16:30",
* preferredMaintenanceWindow: "Tue:17:00-Tue:17:30",
* finalSnapshotName: "example-final-snapshot",
* });
* ```
*
* ### Apply Immediately
*
* To enable applying changes immediately instead of waiting for a maintenance window, use the `applyImmediately` argument.
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
*
* const example = new aws.lightsail.Database("example", {
* relationalDatabaseName: "example-database",
* availabilityZone: "us-east-1a",
* masterDatabaseName: "exampledb",
* masterPassword: "examplepassword123",
* masterUsername: "exampleuser",
* blueprintId: "postgres_12",
* bundleId: "micro_1_0",
* applyImmediately: true,
* });
* ```
*
* ## Blueprint IDs
*
* A list of all available Lightsail Blueprints for Relational Databases the [aws lightsail get-relational-database-blueprints](https://docs.aws.amazon.com/cli/latest/reference/lightsail/get-relational-database-blueprints.html) aws cli command.
*
* ### Examples
*
* - `mysql80`
* - `postgres12`
*
* ### Prefix
*
* A Blueprint ID starts with a prefix of the engine type.
*
* ### Suffix
*
* A Blueprint ID has a suffix of the engine version.
*
* ## Bundles
*
* A list of all available Lightsail Bundles for Relational Databases the [aws lightsail get-relational-database-bundles](https://docs.aws.amazon.com/cli/latest/reference/lightsail/get-relational-database-bundles.html) aws cli command.
*
* ### Examples
*
* - `small10`
* - `smallHa10`
* - `large10`
* - `largeHa10`
*
* ### Prefix
*
* A Bundle ID starts with one of the below size prefixes:
*
* - `micro_`
* - `small_`
* - `medium_`
* - `large_`
*
* ### Infixes (Optional for HA Database)
*
* A Bundle ID can have the following infix added in order to use the HA option of the selected bundle.
*
* - `ha_`
*
* ### Suffix
*
* A Bundle ID ends with one of the following suffix: `10`
*
* ## Import
*
* Using `pulumi import`, import Lightsail Databases using their name. For example:
*
* ```sh
* $ pulumi import aws:lightsail/database:Database example example-database
* ```
*/
class Database extends pulumi.CustomResource {
/**
* Get an existing Database resource's state with the given name, ID, and optional extra
* properties used to qualify the lookup.
*
* @param name The _unique_ name of the resulting resource.
* @param id The _unique_ provider ID of the resource to lookup.
* @param state Any extra arguments used during the lookup.
* @param opts Optional settings to control the behavior of the CustomResource.
*/
static get(name, id, state, opts) {
return new Database(name, state, { ...opts, id: id });
}
/**
* Returns true if the given object is an instance of Database. This is designed to work even
* when multiple copies of the Pulumi SDK have been loaded into the same process.
*/
static isInstance(obj) {
if (obj === undefined || obj === null) {
return false;
}
return obj['__pulumiType'] === Database.__pulumiType;
}
constructor(name, argsOrState, opts) {
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["applyImmediately"] = state?.applyImmediately;
resourceInputs["arn"] = state?.arn;
resourceInputs["availabilityZone"] = state?.availabilityZone;
resourceInputs["backupRetentionEnabled"] = state?.backupRetentionEnabled;
resourceInputs["blueprintId"] = state?.blueprintId;
resourceInputs["bundleId"] = state?.bundleId;
resourceInputs["caCertificateIdentifier"] = state?.caCertificateIdentifier;
resourceInputs["cpuCount"] = state?.cpuCount;
resourceInputs["createdAt"] = state?.createdAt;
resourceInputs["diskSize"] = state?.diskSize;
resourceInputs["engine"] = state?.engine;
resourceInputs["engineVersion"] = state?.engineVersion;
resourceInputs["finalSnapshotName"] = state?.finalSnapshotName;
resourceInputs["masterDatabaseName"] = state?.masterDatabaseName;
resourceInputs["masterEndpointAddress"] = state?.masterEndpointAddress;
resourceInputs["masterEndpointPort"] = state?.masterEndpointPort;
resourceInputs["masterPassword"] = state?.masterPassword;
resourceInputs["masterUsername"] = state?.masterUsername;
resourceInputs["preferredBackupWindow"] = state?.preferredBackupWindow;
resourceInputs["preferredMaintenanceWindow"] = state?.preferredMaintenanceWindow;
resourceInputs["publiclyAccessible"] = state?.publiclyAccessible;
resourceInputs["ramSize"] = state?.ramSize;
resourceInputs["region"] = state?.region;
resourceInputs["relationalDatabaseName"] = state?.relationalDatabaseName;
resourceInputs["secondaryAvailabilityZone"] = state?.secondaryAvailabilityZone;
resourceInputs["skipFinalSnapshot"] = state?.skipFinalSnapshot;
resourceInputs["supportCode"] = state?.supportCode;
resourceInputs["tags"] = state?.tags;
resourceInputs["tagsAll"] = state?.tagsAll;
}
else {
const args = argsOrState;
if (args?.blueprintId === undefined && !opts.urn) {
throw new Error("Missing required property 'blueprintId'");
}
if (args?.bundleId === undefined && !opts.urn) {
throw new Error("Missing required property 'bundleId'");
}
if (args?.masterDatabaseName === undefined && !opts.urn) {
throw new Error("Missing required property 'masterDatabaseName'");
}
if (args?.masterPassword === undefined && !opts.urn) {
throw new Error("Missing required property 'masterPassword'");
}
if (args?.masterUsername === undefined && !opts.urn) {
throw new Error("Missing required property 'masterUsername'");
}
if (args?.relationalDatabaseName === undefined && !opts.urn) {
throw new Error("Missing required property 'relationalDatabaseName'");
}
resourceInputs["applyImmediately"] = args?.applyImmediately;
resourceInputs["availabilityZone"] = args?.availabilityZone;
resourceInputs["backupRetentionEnabled"] = args?.backupRetentionEnabled;
resourceInputs["blueprintId"] = args?.blueprintId;
resourceInputs["bundleId"] = args?.bundleId;
resourceInputs["finalSnapshotName"] = args?.finalSnapshotName;
resourceInputs["masterDatabaseName"] = args?.masterDatabaseName;
resourceInputs["masterPassword"] = args?.masterPassword ? pulumi.secret(args.masterPassword) : undefined;
resourceInputs["masterUsername"] = args?.masterUsername;
resourceInputs["preferredBackupWindow"] = args?.preferredBackupWindow;
resourceInputs["preferredMaintenanceWindow"] = args?.preferredMaintenanceWindow;
resourceInputs["publiclyAccessible"] = args?.publiclyAccessible;
resourceInputs["region"] = args?.region;
resourceInputs["relationalDatabaseName"] = args?.relationalDatabaseName;
resourceInputs["skipFinalSnapshot"] = args?.skipFinalSnapshot;
resourceInputs["tags"] = args?.tags;
resourceInputs["arn"] = undefined /*out*/;
resourceInputs["caCertificateIdentifier"] = undefined /*out*/;
resourceInputs["cpuCount"] = undefined /*out*/;
resourceInputs["createdAt"] = undefined /*out*/;
resourceInputs["diskSize"] = undefined /*out*/;
resourceInputs["engine"] = undefined /*out*/;
resourceInputs["engineVersion"] = undefined /*out*/;
resourceInputs["masterEndpointAddress"] = undefined /*out*/;
resourceInputs["masterEndpointPort"] = undefined /*out*/;
resourceInputs["ramSize"] = undefined /*out*/;
resourceInputs["secondaryAvailabilityZone"] = undefined /*out*/;
resourceInputs["supportCode"] = undefined /*out*/;
resourceInputs["tagsAll"] = undefined /*out*/;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
const secretOpts = { additionalSecretOutputs: ["masterPassword"] };
opts = pulumi.mergeOptions(opts, secretOpts);
super(Database.__pulumiType, name, resourceInputs, opts);
}
}
exports.Database = Database;
/** @internal */
Database.__pulumiType = 'aws:lightsail/database:Database';
//# sourceMappingURL=database.js.map