@pulumi/aws
Version:
A Pulumi package for creating and managing Amazon Web Services (AWS) cloud resources.
284 lines • 13.3 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, Object.assign(Object.assign({}, 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 ? state.applyImmediately : undefined;
resourceInputs["arn"] = state ? state.arn : undefined;
resourceInputs["availabilityZone"] = state ? state.availabilityZone : undefined;
resourceInputs["backupRetentionEnabled"] = state ? state.backupRetentionEnabled : undefined;
resourceInputs["blueprintId"] = state ? state.blueprintId : undefined;
resourceInputs["bundleId"] = state ? state.bundleId : undefined;
resourceInputs["caCertificateIdentifier"] = state ? state.caCertificateIdentifier : undefined;
resourceInputs["cpuCount"] = state ? state.cpuCount : undefined;
resourceInputs["createdAt"] = state ? state.createdAt : undefined;
resourceInputs["diskSize"] = state ? state.diskSize : undefined;
resourceInputs["engine"] = state ? state.engine : undefined;
resourceInputs["engineVersion"] = state ? state.engineVersion : undefined;
resourceInputs["finalSnapshotName"] = state ? state.finalSnapshotName : undefined;
resourceInputs["masterDatabaseName"] = state ? state.masterDatabaseName : undefined;
resourceInputs["masterEndpointAddress"] = state ? state.masterEndpointAddress : undefined;
resourceInputs["masterEndpointPort"] = state ? state.masterEndpointPort : undefined;
resourceInputs["masterPassword"] = state ? state.masterPassword : undefined;
resourceInputs["masterUsername"] = state ? state.masterUsername : undefined;
resourceInputs["preferredBackupWindow"] = state ? state.preferredBackupWindow : undefined;
resourceInputs["preferredMaintenanceWindow"] = state ? state.preferredMaintenanceWindow : undefined;
resourceInputs["publiclyAccessible"] = state ? state.publiclyAccessible : undefined;
resourceInputs["ramSize"] = state ? state.ramSize : undefined;
resourceInputs["region"] = state ? state.region : undefined;
resourceInputs["relationalDatabaseName"] = state ? state.relationalDatabaseName : undefined;
resourceInputs["secondaryAvailabilityZone"] = state ? state.secondaryAvailabilityZone : undefined;
resourceInputs["skipFinalSnapshot"] = state ? state.skipFinalSnapshot : undefined;
resourceInputs["supportCode"] = state ? state.supportCode : undefined;
resourceInputs["tags"] = state ? state.tags : undefined;
resourceInputs["tagsAll"] = state ? state.tagsAll : undefined;
}
else {
const args = argsOrState;
if ((!args || args.blueprintId === undefined) && !opts.urn) {
throw new Error("Missing required property 'blueprintId'");
}
if ((!args || args.bundleId === undefined) && !opts.urn) {
throw new Error("Missing required property 'bundleId'");
}
if ((!args || args.masterDatabaseName === undefined) && !opts.urn) {
throw new Error("Missing required property 'masterDatabaseName'");
}
if ((!args || args.masterPassword === undefined) && !opts.urn) {
throw new Error("Missing required property 'masterPassword'");
}
if ((!args || args.masterUsername === undefined) && !opts.urn) {
throw new Error("Missing required property 'masterUsername'");
}
if ((!args || args.relationalDatabaseName === undefined) && !opts.urn) {
throw new Error("Missing required property 'relationalDatabaseName'");
}
resourceInputs["applyImmediately"] = args ? args.applyImmediately : undefined;
resourceInputs["availabilityZone"] = args ? args.availabilityZone : undefined;
resourceInputs["backupRetentionEnabled"] = args ? args.backupRetentionEnabled : undefined;
resourceInputs["blueprintId"] = args ? args.blueprintId : undefined;
resourceInputs["bundleId"] = args ? args.bundleId : undefined;
resourceInputs["finalSnapshotName"] = args ? args.finalSnapshotName : undefined;
resourceInputs["masterDatabaseName"] = args ? args.masterDatabaseName : undefined;
resourceInputs["masterPassword"] = (args === null || args === void 0 ? void 0 : args.masterPassword) ? pulumi.secret(args.masterPassword) : undefined;
resourceInputs["masterUsername"] = args ? args.masterUsername : undefined;
resourceInputs["preferredBackupWindow"] = args ? args.preferredBackupWindow : undefined;
resourceInputs["preferredMaintenanceWindow"] = args ? args.preferredMaintenanceWindow : undefined;
resourceInputs["publiclyAccessible"] = args ? args.publiclyAccessible : undefined;
resourceInputs["region"] = args ? args.region : undefined;
resourceInputs["relationalDatabaseName"] = args ? args.relationalDatabaseName : undefined;
resourceInputs["skipFinalSnapshot"] = args ? args.skipFinalSnapshot : undefined;
resourceInputs["tags"] = args ? args.tags : undefined;
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