UNPKG

@pulumi/aws

Version:

A Pulumi package for creating and managing Amazon Web Services (AWS) cloud resources.

490 lines • 25.5 kB
"use strict"; // *** 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.Instance = void 0; const pulumi = require("@pulumi/pulumi"); const utilities = require("../utilities"); /** * Provides an RDS instance resource. A DB instance is an isolated database * environment in the cloud. A DB instance can contain multiple user-created * databases. * * Changes to a DB instance can occur when you manually change a parameter, such as * `allocatedStorage`, and are reflected in the next maintenance window. Because * of this, this provider may report a difference in its planning phase because a * modification has not yet taken place. You can use the `applyImmediately` flag * to instruct the service to apply the change immediately (see documentation * below). * * When upgrading the major version of an engine, `allowMajorVersionUpgrade` must be set to `true`. * * > **Note:** using `applyImmediately` can result in a brief downtime as the server reboots. * See the AWS Docs on [RDS Instance Maintenance][instance-maintenance] for more information. * * > **Note:** All arguments including the username and password will be stored in the raw state as plain-text. * Read more about sensitive data instate. * * ## RDS Instance Class Types * * Amazon RDS supports instance classes for the following use cases: General-purpose, Memory-optimized, Burstable Performance, and Optimized-reads. * For more information please read the AWS RDS documentation about [DB Instance Class Types](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Concepts.DBInstanceClass.html) * * ## Low-Downtime Updates * * By default, RDS applies updates to DB Instances in-place, which can lead to service interruptions. * Low-downtime updates minimize service interruptions by performing the updates with an [RDS Blue/Green deployment][blue-green] and switching over the instances when complete. * * Low-downtime updates are only available for DB Instances using MySQL, MariaDB and PostgreSQL, * as other engines are not supported by RDS Blue/Green deployments. * They cannot be used with DB Instances with replicas. * * Backups must be enabled to use low-downtime updates. * * Enable low-downtime updates by setting `blue_green_update.enabled` to `true`. * * ## Example Usage * * ### Basic Usage * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const _default = new aws.rds.Instance("default", { * allocatedStorage: 10, * dbName: "mydb", * engine: "mysql", * engineVersion: "8.0", * instanceClass: aws.rds.InstanceType.T3_Micro, * username: "foo", * password: "foobarbaz", * parameterGroupName: "default.mysql8.0", * skipFinalSnapshot: true, * }); * ``` * * ### RDS Custom for Oracle Usage with Replica * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * // Lookup the available instance classes for the custom engine for the region being operated in * const custom_oracle = aws.rds.getOrderableDbInstance({ * engine: "custom-oracle-ee", * engineVersion: "19.c.ee.002", * licenseModel: "bring-your-own-license", * storageType: "gp3", * preferredInstanceClasses: [ * "db.r5.xlarge", * "db.r5.2xlarge", * "db.r5.4xlarge", * ], * }); * // The RDS instance resource requires an ARN. Look up the ARN of the KMS key associated with the CEV. * const byId = aws.kms.getKey({ * keyId: "example-ef278353ceba4a5a97de6784565b9f78", * }); * const _default = new aws.rds.Instance("default", { * allocatedStorage: 50, * autoMinorVersionUpgrade: false, * customIamInstanceProfile: "AWSRDSCustomInstanceProfile", * backupRetentionPeriod: 7, * dbSubnetGroupName: dbSubnetGroupName, * engine: custom_oracle.then(custom_oracle => custom_oracle.engine), * engineVersion: custom_oracle.then(custom_oracle => custom_oracle.engineVersion), * identifier: "ee-instance-demo", * instanceClass: custom_oracle.then(custom_oracle => custom_oracle.instanceClass).apply((x) => aws.rds.InstanceType[x]), * kmsKeyId: byId.then(byId => byId.arn), * licenseModel: custom_oracle.then(custom_oracle => custom_oracle.licenseModel), * multiAz: false, * password: "avoid-plaintext-passwords", * username: "test", * storageEncrypted: true, * }); * const test_replica = new aws.rds.Instance("test-replica", { * replicateSourceDb: _default.identifier, * replicaMode: "mounted", * autoMinorVersionUpgrade: false, * customIamInstanceProfile: "AWSRDSCustomInstanceProfile", * backupRetentionPeriod: 7, * identifier: "ee-instance-replica", * instanceClass: custom_oracle.then(custom_oracle => custom_oracle.instanceClass).apply((x) => aws.rds.InstanceType[x]), * kmsKeyId: byId.then(byId => byId.arn), * multiAz: false, * skipFinalSnapshot: true, * storageEncrypted: true, * }); * ``` * * ### RDS Custom for SQL Server * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * // Lookup the available instance classes for the custom engine for the region being operated in * const custom_sqlserver = aws.rds.getOrderableDbInstance({ * engine: "custom-sqlserver-se", * engineVersion: "15.00.4249.2.v1", * storageType: "gp3", * preferredInstanceClasses: [ * "db.r5.xlarge", * "db.r5.2xlarge", * "db.r5.4xlarge", * ], * }); * // The RDS instance resource requires an ARN. Look up the ARN of the KMS key. * const byId = aws.kms.getKey({ * keyId: "example-ef278353ceba4a5a97de6784565b9f78", * }); * const example = new aws.rds.Instance("example", { * allocatedStorage: 500, * autoMinorVersionUpgrade: false, * customIamInstanceProfile: "AWSRDSCustomSQLServerInstanceProfile", * backupRetentionPeriod: 7, * dbSubnetGroupName: dbSubnetGroupName, * engine: custom_sqlserver.then(custom_sqlserver => custom_sqlserver.engine), * engineVersion: custom_sqlserver.then(custom_sqlserver => custom_sqlserver.engineVersion), * identifier: "sql-instance-demo", * instanceClass: custom_sqlserver.then(custom_sqlserver => custom_sqlserver.instanceClass).apply((x) => aws.rds.InstanceType[x]), * kmsKeyId: byId.then(byId => byId.arn), * multiAz: false, * password: "avoid-plaintext-passwords", * storageEncrypted: true, * username: "test", * }); * ``` * * ### RDS Db2 Usage * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * // Lookup the default version for the engine. Db2 Standard Edition is `db2-se`, Db2 Advanced Edition is `db2-ae`. * const _default = aws.rds.getEngineVersion({ * engine: "db2-se", * }); * // Lookup the available instance classes for the engine in the region being operated in * const example = Promise.all([_default, _default]).then(([_default, _default1]) => aws.rds.getOrderableDbInstance({ * engine: _default.engine, * engineVersion: _default1.version, * licenseModel: "bring-your-own-license", * storageType: "gp3", * preferredInstanceClasses: [ * "db.t3.small", * "db.r6i.large", * "db.m6i.large", * ], * })); * // The RDS Db2 instance resource requires licensing information. Create a new parameter group using the default paramater group as a source, and set license information. * const exampleParameterGroup = new aws.rds.ParameterGroup("example", { * name: "db-db2-params", * family: _default.then(_default => _default.parameterGroupFamily), * parameters: [ * { * applyMethod: "immediate", * name: "rds.ibm_customer_id", * value: "0", * }, * { * applyMethod: "immediate", * name: "rds.ibm_site_id", * value: "0", * }, * ], * }); * // Create the RDS Db2 instance, use the data sources defined to set attributes * const exampleInstance = new aws.rds.Instance("example", { * allocatedStorage: 100, * backupRetentionPeriod: 7, * dbName: "test", * engine: example.then(example => example.engine), * engineVersion: example.then(example => example.engineVersion), * identifier: "db2-instance-demo", * instanceClass: example.then(example => example.instanceClass).apply((x) => aws.rds.InstanceType[x]), * parameterGroupName: exampleParameterGroup.name, * password: "avoid-plaintext-passwords", * username: "test", * }); * ``` * * ### Storage Autoscaling * * To enable Storage Autoscaling with instances that support the feature, define the `maxAllocatedStorage` argument higher than the `allocatedStorage` argument. This provider will automatically hide differences with the `allocatedStorage` argument value if autoscaling occurs. * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const example = new aws.rds.Instance("example", { * allocatedStorage: 50, * maxAllocatedStorage: 100, * }); * ``` * * ### Managed Master Passwords via Secrets Manager, default KMS Key * * > More information about RDS/Aurora Aurora integrates with Secrets Manager to manage master user passwords for your DB clusters can be found in the [RDS User Guide](https://aws.amazon.com/about-aws/whats-new/2022/12/amazon-rds-integration-aws-secrets-manager/) and [Aurora User Guide](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/rds-secrets-manager.html). * * You can specify the `manageMasterUserPassword` attribute to enable managing the master password with Secrets Manager. You can also update an existing cluster to use Secrets Manager by specify the `manageMasterUserPassword` attribute and removing the `password` attribute (removal is required). * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const _default = new aws.rds.Instance("default", { * allocatedStorage: 10, * dbName: "mydb", * engine: "mysql", * engineVersion: "8.0", * instanceClass: aws.rds.InstanceType.T3_Micro, * manageMasterUserPassword: true, * username: "foo", * parameterGroupName: "default.mysql8.0", * }); * ``` * * ### Managed Master Passwords via Secrets Manager, specific KMS Key * * > More information about RDS/Aurora Aurora integrates with Secrets Manager to manage master user passwords for your DB clusters can be found in the [RDS User Guide](https://aws.amazon.com/about-aws/whats-new/2022/12/amazon-rds-integration-aws-secrets-manager/) and [Aurora User Guide](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/rds-secrets-manager.html). * * You can specify the `masterUserSecretKmsKeyId` attribute to specify a specific KMS Key. * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const example = new aws.kms.Key("example", {description: "Example KMS Key"}); * const _default = new aws.rds.Instance("default", { * allocatedStorage: 10, * dbName: "mydb", * engine: "mysql", * engineVersion: "8.0", * instanceClass: aws.rds.InstanceType.T3_Micro, * manageMasterUserPassword: true, * masterUserSecretKmsKeyId: example.keyId, * username: "foo", * parameterGroupName: "default.mysql8.0", * }); * ``` * * ## Import * * Using `pulumi import`, import DB Instances using the `identifier`. For example: * * ```sh * $ pulumi import aws:rds/instance:Instance default mydb-rds-instance * ``` */ class Instance extends pulumi.CustomResource { /** * Get an existing Instance 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 Instance(name, state, { ...opts, id: id }); } /** * Returns true if the given object is an instance of Instance. 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'] === Instance.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["address"] = state?.address; resourceInputs["allocatedStorage"] = state?.allocatedStorage; resourceInputs["allowMajorVersionUpgrade"] = state?.allowMajorVersionUpgrade; resourceInputs["applyImmediately"] = state?.applyImmediately; resourceInputs["arn"] = state?.arn; resourceInputs["autoMinorVersionUpgrade"] = state?.autoMinorVersionUpgrade; resourceInputs["availabilityZone"] = state?.availabilityZone; resourceInputs["backupRetentionPeriod"] = state?.backupRetentionPeriod; resourceInputs["backupTarget"] = state?.backupTarget; resourceInputs["backupWindow"] = state?.backupWindow; resourceInputs["blueGreenUpdate"] = state?.blueGreenUpdate; resourceInputs["caCertIdentifier"] = state?.caCertIdentifier; resourceInputs["characterSetName"] = state?.characterSetName; resourceInputs["copyTagsToSnapshot"] = state?.copyTagsToSnapshot; resourceInputs["customIamInstanceProfile"] = state?.customIamInstanceProfile; resourceInputs["customerOwnedIpEnabled"] = state?.customerOwnedIpEnabled; resourceInputs["databaseInsightsMode"] = state?.databaseInsightsMode; resourceInputs["dbName"] = state?.dbName; resourceInputs["dbSubnetGroupName"] = state?.dbSubnetGroupName; resourceInputs["dedicatedLogVolume"] = state?.dedicatedLogVolume; resourceInputs["deleteAutomatedBackups"] = state?.deleteAutomatedBackups; resourceInputs["deletionProtection"] = state?.deletionProtection; resourceInputs["domain"] = state?.domain; resourceInputs["domainAuthSecretArn"] = state?.domainAuthSecretArn; resourceInputs["domainDnsIps"] = state?.domainDnsIps; resourceInputs["domainFqdn"] = state?.domainFqdn; resourceInputs["domainIamRoleName"] = state?.domainIamRoleName; resourceInputs["domainOu"] = state?.domainOu; resourceInputs["enabledCloudwatchLogsExports"] = state?.enabledCloudwatchLogsExports; resourceInputs["endpoint"] = state?.endpoint; resourceInputs["engine"] = state?.engine; resourceInputs["engineLifecycleSupport"] = state?.engineLifecycleSupport; resourceInputs["engineVersion"] = state?.engineVersion; resourceInputs["engineVersionActual"] = state?.engineVersionActual; resourceInputs["finalSnapshotIdentifier"] = state?.finalSnapshotIdentifier; resourceInputs["hostedZoneId"] = state?.hostedZoneId; resourceInputs["iamDatabaseAuthenticationEnabled"] = state?.iamDatabaseAuthenticationEnabled; resourceInputs["identifier"] = state?.identifier; resourceInputs["identifierPrefix"] = state?.identifierPrefix; resourceInputs["instanceClass"] = state?.instanceClass; resourceInputs["iops"] = state?.iops; resourceInputs["kmsKeyId"] = state?.kmsKeyId; resourceInputs["latestRestorableTime"] = state?.latestRestorableTime; resourceInputs["licenseModel"] = state?.licenseModel; resourceInputs["listenerEndpoints"] = state?.listenerEndpoints; resourceInputs["maintenanceWindow"] = state?.maintenanceWindow; resourceInputs["manageMasterUserPassword"] = state?.manageMasterUserPassword; resourceInputs["masterUserSecretKmsKeyId"] = state?.masterUserSecretKmsKeyId; resourceInputs["masterUserSecrets"] = state?.masterUserSecrets; resourceInputs["maxAllocatedStorage"] = state?.maxAllocatedStorage; resourceInputs["monitoringInterval"] = state?.monitoringInterval; resourceInputs["monitoringRoleArn"] = state?.monitoringRoleArn; resourceInputs["multiAz"] = state?.multiAz; resourceInputs["ncharCharacterSetName"] = state?.ncharCharacterSetName; resourceInputs["networkType"] = state?.networkType; resourceInputs["optionGroupName"] = state?.optionGroupName; resourceInputs["parameterGroupName"] = state?.parameterGroupName; resourceInputs["password"] = state?.password; resourceInputs["performanceInsightsEnabled"] = state?.performanceInsightsEnabled; resourceInputs["performanceInsightsKmsKeyId"] = state?.performanceInsightsKmsKeyId; resourceInputs["performanceInsightsRetentionPeriod"] = state?.performanceInsightsRetentionPeriod; resourceInputs["port"] = state?.port; resourceInputs["publiclyAccessible"] = state?.publiclyAccessible; resourceInputs["region"] = state?.region; resourceInputs["replicaMode"] = state?.replicaMode; resourceInputs["replicas"] = state?.replicas; resourceInputs["replicateSourceDb"] = state?.replicateSourceDb; resourceInputs["resourceId"] = state?.resourceId; resourceInputs["restoreToPointInTime"] = state?.restoreToPointInTime; resourceInputs["s3Import"] = state?.s3Import; resourceInputs["skipFinalSnapshot"] = state?.skipFinalSnapshot; resourceInputs["snapshotIdentifier"] = state?.snapshotIdentifier; resourceInputs["status"] = state?.status; resourceInputs["storageEncrypted"] = state?.storageEncrypted; resourceInputs["storageThroughput"] = state?.storageThroughput; resourceInputs["storageType"] = state?.storageType; resourceInputs["tags"] = state?.tags; resourceInputs["tagsAll"] = state?.tagsAll; resourceInputs["timezone"] = state?.timezone; resourceInputs["upgradeStorageConfig"] = state?.upgradeStorageConfig; resourceInputs["username"] = state?.username; resourceInputs["vpcSecurityGroupIds"] = state?.vpcSecurityGroupIds; } else { const args = argsOrState; if (args?.instanceClass === undefined && !opts.urn) { throw new Error("Missing required property 'instanceClass'"); } resourceInputs["allocatedStorage"] = args?.allocatedStorage; resourceInputs["allowMajorVersionUpgrade"] = args?.allowMajorVersionUpgrade; resourceInputs["applyImmediately"] = args?.applyImmediately; resourceInputs["autoMinorVersionUpgrade"] = args?.autoMinorVersionUpgrade; resourceInputs["availabilityZone"] = args?.availabilityZone; resourceInputs["backupRetentionPeriod"] = args?.backupRetentionPeriod; resourceInputs["backupTarget"] = args?.backupTarget; resourceInputs["backupWindow"] = args?.backupWindow; resourceInputs["blueGreenUpdate"] = args?.blueGreenUpdate; resourceInputs["caCertIdentifier"] = args?.caCertIdentifier; resourceInputs["characterSetName"] = args?.characterSetName; resourceInputs["copyTagsToSnapshot"] = args?.copyTagsToSnapshot; resourceInputs["customIamInstanceProfile"] = args?.customIamInstanceProfile; resourceInputs["customerOwnedIpEnabled"] = args?.customerOwnedIpEnabled; resourceInputs["databaseInsightsMode"] = args?.databaseInsightsMode; resourceInputs["dbName"] = args?.dbName; resourceInputs["dbSubnetGroupName"] = args?.dbSubnetGroupName; resourceInputs["dedicatedLogVolume"] = args?.dedicatedLogVolume; resourceInputs["deleteAutomatedBackups"] = args?.deleteAutomatedBackups; resourceInputs["deletionProtection"] = args?.deletionProtection; resourceInputs["domain"] = args?.domain; resourceInputs["domainAuthSecretArn"] = args?.domainAuthSecretArn; resourceInputs["domainDnsIps"] = args?.domainDnsIps; resourceInputs["domainFqdn"] = args?.domainFqdn; resourceInputs["domainIamRoleName"] = args?.domainIamRoleName; resourceInputs["domainOu"] = args?.domainOu; resourceInputs["enabledCloudwatchLogsExports"] = args?.enabledCloudwatchLogsExports; resourceInputs["engine"] = args?.engine; resourceInputs["engineLifecycleSupport"] = args?.engineLifecycleSupport; resourceInputs["engineVersion"] = args?.engineVersion; resourceInputs["finalSnapshotIdentifier"] = args?.finalSnapshotIdentifier; resourceInputs["iamDatabaseAuthenticationEnabled"] = args?.iamDatabaseAuthenticationEnabled; resourceInputs["identifier"] = args?.identifier; resourceInputs["identifierPrefix"] = args?.identifierPrefix; resourceInputs["instanceClass"] = args?.instanceClass; resourceInputs["iops"] = args?.iops; resourceInputs["kmsKeyId"] = args?.kmsKeyId; resourceInputs["licenseModel"] = args?.licenseModel; resourceInputs["maintenanceWindow"] = args?.maintenanceWindow; resourceInputs["manageMasterUserPassword"] = args?.manageMasterUserPassword; resourceInputs["masterUserSecretKmsKeyId"] = args?.masterUserSecretKmsKeyId; resourceInputs["maxAllocatedStorage"] = args?.maxAllocatedStorage; resourceInputs["monitoringInterval"] = args?.monitoringInterval; resourceInputs["monitoringRoleArn"] = args?.monitoringRoleArn; resourceInputs["multiAz"] = args?.multiAz; resourceInputs["ncharCharacterSetName"] = args?.ncharCharacterSetName; resourceInputs["networkType"] = args?.networkType; resourceInputs["optionGroupName"] = args?.optionGroupName; resourceInputs["parameterGroupName"] = args?.parameterGroupName; resourceInputs["password"] = args?.password ? pulumi.secret(args.password) : undefined; resourceInputs["performanceInsightsEnabled"] = args?.performanceInsightsEnabled; resourceInputs["performanceInsightsKmsKeyId"] = args?.performanceInsightsKmsKeyId; resourceInputs["performanceInsightsRetentionPeriod"] = args?.performanceInsightsRetentionPeriod; resourceInputs["port"] = args?.port; resourceInputs["publiclyAccessible"] = args?.publiclyAccessible; resourceInputs["region"] = args?.region; resourceInputs["replicaMode"] = args?.replicaMode; resourceInputs["replicateSourceDb"] = args?.replicateSourceDb; resourceInputs["restoreToPointInTime"] = args?.restoreToPointInTime; resourceInputs["s3Import"] = args?.s3Import; resourceInputs["skipFinalSnapshot"] = args?.skipFinalSnapshot; resourceInputs["snapshotIdentifier"] = args?.snapshotIdentifier; resourceInputs["storageEncrypted"] = args?.storageEncrypted; resourceInputs["storageThroughput"] = args?.storageThroughput; resourceInputs["storageType"] = args?.storageType; resourceInputs["tags"] = args?.tags; resourceInputs["timezone"] = args?.timezone; resourceInputs["upgradeStorageConfig"] = args?.upgradeStorageConfig; resourceInputs["username"] = args?.username; resourceInputs["vpcSecurityGroupIds"] = args?.vpcSecurityGroupIds; resourceInputs["address"] = undefined /*out*/; resourceInputs["arn"] = undefined /*out*/; resourceInputs["endpoint"] = undefined /*out*/; resourceInputs["engineVersionActual"] = undefined /*out*/; resourceInputs["hostedZoneId"] = undefined /*out*/; resourceInputs["latestRestorableTime"] = undefined /*out*/; resourceInputs["listenerEndpoints"] = undefined /*out*/; resourceInputs["masterUserSecrets"] = undefined /*out*/; resourceInputs["replicas"] = undefined /*out*/; resourceInputs["resourceId"] = undefined /*out*/; resourceInputs["status"] = undefined /*out*/; resourceInputs["tagsAll"] = undefined /*out*/; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); const secretOpts = { additionalSecretOutputs: ["password"] }; opts = pulumi.mergeOptions(opts, secretOpts); super(Instance.__pulumiType, name, resourceInputs, opts); } } exports.Instance = Instance; /** @internal */ Instance.__pulumiType = 'aws:rds/instance:Instance'; //# sourceMappingURL=instance.js.map