Alibaba Cloud
Database
Provides a PolarDB database resource. A database deployed in a PolarDB cluster. A PolarDB cluster can own multiple databases.
NOTE: Available in v1.66.0+.
Example Usage
using Pulumi;
using AliCloud = Pulumi.AliCloud;
class MyStack : Stack
{
public MyStack()
{
var config = new Config();
var name = config.Get("name") ?? "polardbClusterconfig";
var creation = config.Get("creation") ?? "PolarDB";
var defaultZones = Output.Create(AliCloud.GetZones.InvokeAsync(new AliCloud.GetZonesArgs
{
AvailableResourceCreation = creation,
}));
var defaultNetwork = new AliCloud.Vpc.Network("defaultNetwork", new AliCloud.Vpc.NetworkArgs
{
CidrBlock = "172.16.0.0/16",
});
var defaultSwitch = new AliCloud.Vpc.Switch("defaultSwitch", new AliCloud.Vpc.SwitchArgs
{
VpcId = defaultNetwork.Id,
CidrBlock = "172.16.0.0/24",
ZoneId = defaultZones.Apply(defaultZones => defaultZones.Zones?[0]?.Id),
});
var cluster = new AliCloud.PolarDB.Cluster("cluster", new AliCloud.PolarDB.ClusterArgs
{
DbType = "MySQL",
DbVersion = "8.0",
PayType = "PostPaid",
DbNodeClass = "polar.mysql.x4.large",
VswitchId = defaultSwitch.Id,
Description = "testDB",
});
var defaultDatabase = new AliCloud.PolarDB.Database("defaultDatabase", new AliCloud.PolarDB.DatabaseArgs
{
DbClusterId = cluster.Id,
DbName = "tftestdatabase",
});
}
}
package main
import (
"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud"
"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/polardb"
"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/vpc"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi/config"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
cfg := config.New(ctx, "")
name := "polardbClusterconfig"
if param := cfg.Get("name"); param != "" {
name = param
}
creation := "PolarDB"
if param := cfg.Get("creation"); param != "" {
creation = param
}
defaultZones, err := alicloud.GetZones(ctx, &GetZonesArgs{
AvailableResourceCreation: pulumi.StringRef(creation),
}, nil)
if err != nil {
return err
}
defaultNetwork, err := vpc.NewNetwork(ctx, "defaultNetwork", &vpc.NetworkArgs{
CidrBlock: pulumi.String("172.16.0.0/16"),
})
if err != nil {
return err
}
defaultSwitch, err := vpc.NewSwitch(ctx, "defaultSwitch", &vpc.SwitchArgs{
VpcId: defaultNetwork.ID(),
CidrBlock: pulumi.String("172.16.0.0/24"),
ZoneId: pulumi.String(defaultZones.Zones[0].Id),
})
if err != nil {
return err
}
cluster, err := polardb.NewCluster(ctx, "cluster", &polardb.ClusterArgs{
DbType: pulumi.String("MySQL"),
DbVersion: pulumi.String("8.0"),
PayType: pulumi.String("PostPaid"),
DbNodeClass: pulumi.String("polar.mysql.x4.large"),
VswitchId: defaultSwitch.ID(),
Description: pulumi.String("testDB"),
})
if err != nil {
return err
}
_, err = polardb.NewDatabase(ctx, "defaultDatabase", &polardb.DatabaseArgs{
DbClusterId: cluster.ID(),
DbName: pulumi.String("tftestdatabase"),
})
if err != nil {
return err
}
return nil
})
}
Coming soon!
import pulumi
import pulumi_alicloud as alicloud
config = pulumi.Config()
name = config.get("name")
if name is None:
name = "polardbClusterconfig"
creation = config.get("creation")
if creation is None:
creation = "PolarDB"
default_zones = alicloud.get_zones(available_resource_creation=creation)
default_network = alicloud.vpc.Network("defaultNetwork", cidr_block="172.16.0.0/16")
default_switch = alicloud.vpc.Switch("defaultSwitch",
vpc_id=default_network.id,
cidr_block="172.16.0.0/24",
zone_id=default_zones.zones[0].id)
cluster = alicloud.polardb.Cluster("cluster",
db_type="MySQL",
db_version="8.0",
pay_type="PostPaid",
db_node_class="polar.mysql.x4.large",
vswitch_id=default_switch.id,
description="testDB")
default_database = alicloud.polardb.Database("defaultDatabase",
db_cluster_id=cluster.id,
db_name="tftestdatabase")
import * as pulumi from "@pulumi/pulumi";
import * as alicloud from "@pulumi/alicloud";
const config = new pulumi.Config();
const name = config.get("name") || "polardbClusterconfig";
const creation = config.get("creation") || "PolarDB";
const defaultZones = alicloud.getZones({
availableResourceCreation: creation,
});
const defaultNetwork = new alicloud.vpc.Network("defaultNetwork", {cidrBlock: "172.16.0.0/16"});
const defaultSwitch = new alicloud.vpc.Switch("defaultSwitch", {
vpcId: defaultNetwork.id,
cidrBlock: "172.16.0.0/24",
zoneId: defaultZones.then(defaultZones => defaultZones.zones?[0]?.id),
});
const cluster = new alicloud.polardb.Cluster("cluster", {
dbType: "MySQL",
dbVersion: "8.0",
payType: "PostPaid",
dbNodeClass: "polar.mysql.x4.large",
vswitchId: defaultSwitch.id,
description: "testDB",
});
const defaultDatabase = new alicloud.polardb.Database("defaultDatabase", {
dbClusterId: cluster.id,
dbName: "tftestdatabase",
});
Coming soon!
Create a Database Resource
new Database(name: string, args: DatabaseArgs, opts?: CustomResourceOptions);
@overload
def Database(resource_name: str,
opts: Optional[ResourceOptions] = None,
character_set_name: Optional[str] = None,
db_cluster_id: Optional[str] = None,
db_description: Optional[str] = None,
db_name: Optional[str] = None)
@overload
def Database(resource_name: str,
args: DatabaseArgs,
opts: Optional[ResourceOptions] = None)
func NewDatabase(ctx *Context, name string, args DatabaseArgs, opts ...ResourceOption) (*Database, error)
public Database(string name, DatabaseArgs args, CustomResourceOptions? opts = null)
public Database(String name, DatabaseArgs args)
public Database(String name, DatabaseArgs args, CustomResourceOptions options)
type: alicloud:polardb:Database
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args DatabaseArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- resource_name str
- The unique name of the resource.
- args DatabaseArgs
- The arguments to resource properties.
- opts ResourceOptions
- Bag of options to control resource's behavior.
- ctx Context
- Context object for the current deployment.
- name string
- The unique name of the resource.
- args DatabaseArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args DatabaseArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args DatabaseArgs
- The arguments to resource properties.
- options CustomResourceOptions
- Bag of options to control resource's behavior.
Database Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.
Inputs
The Database resource accepts the following input properties:
- Db
Cluster stringId The Id of cluster that can run database.
- Db
Name string Name of the database requiring a uniqueness check. It may consist of lower case letters, numbers, and underlines, and must start with a letterand have no more than 64 characters.
- Character
Set stringName Character set. The value range is limited to the following: [ utf8, gbk, latin1, utf8mb4, Chinese_PRC_CI_AS, Chinese_PRC_CS_AS, SQL_Latin1_General_CP1_CI_AS, SQL_Latin1_General_CP1_CS_AS, Chinese_PRC_BIN ], default is "utf8" (
utf8mb4
only supports versions 5.5 and 5.6).- Db
Description string Database description. It must start with a Chinese character or English letter, cannot start with "http://" or "https://". It can include Chinese and English characters, underlines (_), hyphens (-), and numbers. The length must be 2-256 characters.
- Db
Cluster stringId The Id of cluster that can run database.
- Db
Name string Name of the database requiring a uniqueness check. It may consist of lower case letters, numbers, and underlines, and must start with a letterand have no more than 64 characters.
- Character
Set stringName Character set. The value range is limited to the following: [ utf8, gbk, latin1, utf8mb4, Chinese_PRC_CI_AS, Chinese_PRC_CS_AS, SQL_Latin1_General_CP1_CI_AS, SQL_Latin1_General_CP1_CS_AS, Chinese_PRC_BIN ], default is "utf8" (
utf8mb4
only supports versions 5.5 and 5.6).- Db
Description string Database description. It must start with a Chinese character or English letter, cannot start with "http://" or "https://". It can include Chinese and English characters, underlines (_), hyphens (-), and numbers. The length must be 2-256 characters.
- db
Cluster StringId The Id of cluster that can run database.
- db
Name String Name of the database requiring a uniqueness check. It may consist of lower case letters, numbers, and underlines, and must start with a letterand have no more than 64 characters.
- character
Set StringName Character set. The value range is limited to the following: [ utf8, gbk, latin1, utf8mb4, Chinese_PRC_CI_AS, Chinese_PRC_CS_AS, SQL_Latin1_General_CP1_CI_AS, SQL_Latin1_General_CP1_CS_AS, Chinese_PRC_BIN ], default is "utf8" (
utf8mb4
only supports versions 5.5 and 5.6).- db
Description String Database description. It must start with a Chinese character or English letter, cannot start with "http://" or "https://". It can include Chinese and English characters, underlines (_), hyphens (-), and numbers. The length must be 2-256 characters.
- db
Cluster stringId The Id of cluster that can run database.
- db
Name string Name of the database requiring a uniqueness check. It may consist of lower case letters, numbers, and underlines, and must start with a letterand have no more than 64 characters.
- character
Set stringName Character set. The value range is limited to the following: [ utf8, gbk, latin1, utf8mb4, Chinese_PRC_CI_AS, Chinese_PRC_CS_AS, SQL_Latin1_General_CP1_CI_AS, SQL_Latin1_General_CP1_CS_AS, Chinese_PRC_BIN ], default is "utf8" (
utf8mb4
only supports versions 5.5 and 5.6).- db
Description string Database description. It must start with a Chinese character or English letter, cannot start with "http://" or "https://". It can include Chinese and English characters, underlines (_), hyphens (-), and numbers. The length must be 2-256 characters.
- db_
cluster_ strid The Id of cluster that can run database.
- db_
name str Name of the database requiring a uniqueness check. It may consist of lower case letters, numbers, and underlines, and must start with a letterand have no more than 64 characters.
- character_
set_ strname Character set. The value range is limited to the following: [ utf8, gbk, latin1, utf8mb4, Chinese_PRC_CI_AS, Chinese_PRC_CS_AS, SQL_Latin1_General_CP1_CI_AS, SQL_Latin1_General_CP1_CS_AS, Chinese_PRC_BIN ], default is "utf8" (
utf8mb4
only supports versions 5.5 and 5.6).- db_
description str Database description. It must start with a Chinese character or English letter, cannot start with "http://" or "https://". It can include Chinese and English characters, underlines (_), hyphens (-), and numbers. The length must be 2-256 characters.
- db
Cluster StringId The Id of cluster that can run database.
- db
Name String Name of the database requiring a uniqueness check. It may consist of lower case letters, numbers, and underlines, and must start with a letterand have no more than 64 characters.
- character
Set StringName Character set. The value range is limited to the following: [ utf8, gbk, latin1, utf8mb4, Chinese_PRC_CI_AS, Chinese_PRC_CS_AS, SQL_Latin1_General_CP1_CI_AS, SQL_Latin1_General_CP1_CS_AS, Chinese_PRC_BIN ], default is "utf8" (
utf8mb4
only supports versions 5.5 and 5.6).- db
Description String Database description. It must start with a Chinese character or English letter, cannot start with "http://" or "https://". It can include Chinese and English characters, underlines (_), hyphens (-), and numbers. The length must be 2-256 characters.
Outputs
All input properties are implicitly available as output properties. Additionally, the Database resource produces the following output properties:
- Id string
The provider-assigned unique ID for this managed resource.
- Id string
The provider-assigned unique ID for this managed resource.
- id String
The provider-assigned unique ID for this managed resource.
- id string
The provider-assigned unique ID for this managed resource.
- id str
The provider-assigned unique ID for this managed resource.
- id String
The provider-assigned unique ID for this managed resource.
Look up an Existing Database Resource
Get an existing Database resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.
public static get(name: string, id: Input<ID>, state?: DatabaseState, opts?: CustomResourceOptions): Database
@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
character_set_name: Optional[str] = None,
db_cluster_id: Optional[str] = None,
db_description: Optional[str] = None,
db_name: Optional[str] = None) -> Database
func GetDatabase(ctx *Context, name string, id IDInput, state *DatabaseState, opts ...ResourceOption) (*Database, error)
public static Database Get(string name, Input<string> id, DatabaseState? state, CustomResourceOptions? opts = null)
public static Database get(String name, Output<String> id, DatabaseState state, CustomResourceOptions options)
Resource lookup is not supported in YAML
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- resource_name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- Character
Set stringName Character set. The value range is limited to the following: [ utf8, gbk, latin1, utf8mb4, Chinese_PRC_CI_AS, Chinese_PRC_CS_AS, SQL_Latin1_General_CP1_CI_AS, SQL_Latin1_General_CP1_CS_AS, Chinese_PRC_BIN ], default is "utf8" (
utf8mb4
only supports versions 5.5 and 5.6).- Db
Cluster stringId The Id of cluster that can run database.
- Db
Description string Database description. It must start with a Chinese character or English letter, cannot start with "http://" or "https://". It can include Chinese and English characters, underlines (_), hyphens (-), and numbers. The length must be 2-256 characters.
- Db
Name string Name of the database requiring a uniqueness check. It may consist of lower case letters, numbers, and underlines, and must start with a letterand have no more than 64 characters.
- Character
Set stringName Character set. The value range is limited to the following: [ utf8, gbk, latin1, utf8mb4, Chinese_PRC_CI_AS, Chinese_PRC_CS_AS, SQL_Latin1_General_CP1_CI_AS, SQL_Latin1_General_CP1_CS_AS, Chinese_PRC_BIN ], default is "utf8" (
utf8mb4
only supports versions 5.5 and 5.6).- Db
Cluster stringId The Id of cluster that can run database.
- Db
Description string Database description. It must start with a Chinese character or English letter, cannot start with "http://" or "https://". It can include Chinese and English characters, underlines (_), hyphens (-), and numbers. The length must be 2-256 characters.
- Db
Name string Name of the database requiring a uniqueness check. It may consist of lower case letters, numbers, and underlines, and must start with a letterand have no more than 64 characters.
- character
Set StringName Character set. The value range is limited to the following: [ utf8, gbk, latin1, utf8mb4, Chinese_PRC_CI_AS, Chinese_PRC_CS_AS, SQL_Latin1_General_CP1_CI_AS, SQL_Latin1_General_CP1_CS_AS, Chinese_PRC_BIN ], default is "utf8" (
utf8mb4
only supports versions 5.5 and 5.6).- db
Cluster StringId The Id of cluster that can run database.
- db
Description String Database description. It must start with a Chinese character or English letter, cannot start with "http://" or "https://". It can include Chinese and English characters, underlines (_), hyphens (-), and numbers. The length must be 2-256 characters.
- db
Name String Name of the database requiring a uniqueness check. It may consist of lower case letters, numbers, and underlines, and must start with a letterand have no more than 64 characters.
- character
Set stringName Character set. The value range is limited to the following: [ utf8, gbk, latin1, utf8mb4, Chinese_PRC_CI_AS, Chinese_PRC_CS_AS, SQL_Latin1_General_CP1_CI_AS, SQL_Latin1_General_CP1_CS_AS, Chinese_PRC_BIN ], default is "utf8" (
utf8mb4
only supports versions 5.5 and 5.6).- db
Cluster stringId The Id of cluster that can run database.
- db
Description string Database description. It must start with a Chinese character or English letter, cannot start with "http://" or "https://". It can include Chinese and English characters, underlines (_), hyphens (-), and numbers. The length must be 2-256 characters.
- db
Name string Name of the database requiring a uniqueness check. It may consist of lower case letters, numbers, and underlines, and must start with a letterand have no more than 64 characters.
- character_
set_ strname Character set. The value range is limited to the following: [ utf8, gbk, latin1, utf8mb4, Chinese_PRC_CI_AS, Chinese_PRC_CS_AS, SQL_Latin1_General_CP1_CI_AS, SQL_Latin1_General_CP1_CS_AS, Chinese_PRC_BIN ], default is "utf8" (
utf8mb4
only supports versions 5.5 and 5.6).- db_
cluster_ strid The Id of cluster that can run database.
- db_
description str Database description. It must start with a Chinese character or English letter, cannot start with "http://" or "https://". It can include Chinese and English characters, underlines (_), hyphens (-), and numbers. The length must be 2-256 characters.
- db_
name str Name of the database requiring a uniqueness check. It may consist of lower case letters, numbers, and underlines, and must start with a letterand have no more than 64 characters.
- character
Set StringName Character set. The value range is limited to the following: [ utf8, gbk, latin1, utf8mb4, Chinese_PRC_CI_AS, Chinese_PRC_CS_AS, SQL_Latin1_General_CP1_CI_AS, SQL_Latin1_General_CP1_CS_AS, Chinese_PRC_BIN ], default is "utf8" (
utf8mb4
only supports versions 5.5 and 5.6).- db
Cluster StringId The Id of cluster that can run database.
- db
Description String Database description. It must start with a Chinese character or English letter, cannot start with "http://" or "https://". It can include Chinese and English characters, underlines (_), hyphens (-), and numbers. The length must be 2-256 characters.
- db
Name String Name of the database requiring a uniqueness check. It may consist of lower case letters, numbers, and underlines, and must start with a letterand have no more than 64 characters.
Import
PolarDB database can be imported using the id, e.g.
$ pulumi import alicloud:polardb/database:Database example "pc-12345:tf_database"
Package Details
- Repository
- https://github.com/pulumi/pulumi-alicloud
- License
- Apache-2.0
- Notes
This Pulumi package is based on the
alicloud
Terraform Provider.