Skip to content

walrus-catalog/terraform-alicloud-rds-mysql

Repository files navigation

Alibaba ApsaraDB RDS for MySQL Service

Terraform module which deploys MySQL service on Alibaba Cloud.

  • Support standalone(one read-write HA instance) and replication(one read-write HA instance and multiple read-only instances, for read write splitting).

Usage

module "mysql" {
  source = "..."

  infrastructure = {
    vpc_id        = "..."
    domain_suffix = "..."
  }

  architecture    = "replication"
  engine_version  = "8.0"          # https://www.alibabacloud.com/help/en/rds/developer-reference/api-rds-2014-08-15-createdbinstance
}

Examples

Contributing

Please read our contributing guide if you're interested in contributing to Walrus template.

Requirements

Name Version
terraform >= 1.0
alicloud >= 1.212.0
random >= 3.5.1

Providers

Name Version
alicloud >= 1.212.0
random >= 3.5.1

Modules

No modules.

Resources

Name Type
alicloud_db_connection.primary resource
alicloud_db_connection.secondary resource
alicloud_db_database.database resource
alicloud_db_instance.primary resource
alicloud_db_readonly_instance.secondary resource
alicloud_pvtz_zone_record.primary resource
alicloud_pvtz_zone_record.secondary resource
alicloud_rds_account.account resource
alicloud_vpc.default resource
alicloud_vswitch.default resource
random_password.password resource
random_string.name_suffix resource
alicloud_db_zones.selected data source
alicloud_kms_keys.selected data source
alicloud_pvtz_zones.selected data source
alicloud_vpcs.selected data source
alicloud_vswitches.selected data source

Inputs

Name Description Type Default Required
architecture Specify the deployment architecture, select from standalone or replication. string "standalone" no
context Receive contextual information. When Walrus deploys, Walrus will inject specific contextual information into this field.

Examples:
context:
project:
name: string
id: string
environment:
name: string
id: string
resource:
name: string
id: string
map(any) {} no
database Specify the database name. The database name must be 2-64 characters long and start with any lower letter, combined with number, or symbols: - _.
The database name cannot be MySQL forbidden keyword.
See https://www.alibabacloud.com/help/en/rds/developer-reference/api-rds-2014-08-15-createdatabase.
string "mydb" no
engine_parameters Specify the deployment engine parameters, select for https://www.alibabacloud.com/help/en/rds/developer-reference/api-rds-2014-08-15-describeparametertemplates.
list(object({
name = string
value = string
}))
[] no
engine_version Specify the deployment engine version, select from https://www.alibabacloud.com/help/en/rds/developer-reference/api-rds-2014-08-15-createdbinstance. string "8.0" no
infrastructure Specify the infrastructure information for deploying.

Examples:
infrastructure:
vpc_id: string,optional # the ID of the VPC where the MySQL service applies
kms_key_id: string,optional # the ID of the KMS key which to encrypt the MySQL data
domain_suffix: string,optional # a private DNS namespace of the PrivateZone where to register the applied MySQL service
publicly_accessible: bool # whether the MySQL service is publicly accessible
object({
vpc_id = optional(string)
kms_key_id = optional(string)
domain_suffix = optional(string)
publicly_accessible = optional(bool, false)
})
{
"publicly_accessible": false
}
no
password Specify the account password. The password must be 8-32 characters long and start with any letter, number, or symbols: ! # $ % ^ & * ( ) _ + - =.
If not specified, it will generate a random password.
See https://www.alibabacloud.com/help/en/rds/developer-reference/api-rds-2014-08-15-createaccount.
string null no
replication_readonly_replicas Specify the number of read-only replicas under the replication deployment. number 1 no
resources Specify the computing resources.
The computing resource design of Alibaba Cloud is very complex, it also needs to consider on the storage resource, please view the specification document for more information.

Examples:
resources:
class: string, optional # https://www.alibabacloud.com/help/en/rds/apsaradb-rds-for-mysql/primary-apsaradb-rds-for-mysql-instance-types, https://www.alibabacloud.com/help/en/rds/apsaradb-rds-for-mysql/primary-apsaradb-rds-for-mysql-instance-types-5
readonly_class: string, optional # https://www.alibabacloud.com/help/en/rds/apsaradb-rds-for-mysql/read-only-apsaradb-rds-for-mysql-instance-types, https://www.alibabacloud.com/help/en/rds/apsaradb-rds-for-mysql/read-only-apsaradb-rds-for-mysql-instance-types-5
object({
class = optional(string, "rds.mysql.s2.large")
readonly_class = optional(string)
})
{
"class": "rds.mysql.s2.large"
}
no
storage Specify the storage resources, select from local_ssd, cloud_ssd, cloud_essd, cloud_essd2 or cloud_essd3.
Choosing the storage resource is also related to the computing resource, please view the specification document for more information.

Examples:
storage:
class: string, optional # https://registry.terraform.io/providers/aliyun/alicloud/latest/docs/resources/db_instance#db_instance_storage_type
size: number, optional # in megabyte
object({
class = optional(string, "local_ssd")
size = optional(number, 20 * 1024)
})
{
"class": "local_ssd",
"size": 20480
}
no
username Specify the account username. The username must be 2-16 characters long and start with lower letter, combined with number, or symbol: _.
The username cannot be MySQL forbidden keyword and root.
See https://www.alibabacloud.com/help/en/rds/developer-reference/api-rds-2014-08-15-createaccount.
string "rdsuser" no

Outputs

Name Description
address The address, a string only has host, might be a comma separated string or a single string.
address_readonly The readonly address, a string only has host, might be a comma separated string or a single string.
connection The connection, a string combined host and port, might be a comma separated string or a single string.
connection_readonly The readonly connection, a string combined host and port, might be a comma separated string or a single string.
context The input context, a map, which is used for orchestration.
database The name of MySQL database to access.
password The password of the account to access the database.
port The port of the service.
refer The refer, a map, including hosts, ports and account, which is used for dependencies or collaborations.
username The username of the account to access the database.

License

Copyright (c) 2023 Seal, Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at LICENSE file for details.

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.