リソースタイプ ALIYUN::RDS::Database を使用すると、RDS インスタンス内にデータベースを作成できます。
構文
{
"Type": "ALIYUN::RDS::Database",
"Properties": {
"CharacterSetName": String,
"DBInstanceId": String,
"DBDescription": String,
"DBName": String
}
}プロパティ
プロパティ | 型 | 必須 | 更新許可済み | 説明 | 制約条件 |
CharacterSetName | String | はい | いいえ | 文字セット。 | 有効な値:
|
DBInstanceId | String | はい | いいえ | インスタンス ID。 | なし |
DBDescription | String | いいえ | はい | データベースの説明。 | 説明は 2~256 文字である必要があります。先頭は英字または漢字で始める必要があり、 |
DBName | String | はい | いいえ | データベース名。 | 名前は 2~64 文字である必要があります。先頭は小文字で始まり、末尾は小文字または数字で終わる必要があります。使用可能な文字は、小文字、数字、アンダースコア (_)、ハイフン (-) です。 説明 データベース名は、同一インスタンス内で一意である必要があります。 |
戻り値
Fn::GetAtt
DBInstanceId:RDS インスタンスの ID。
DBName:データベース名。
例
シナリオ 1: 既存の RDS インスタンス向けにデータベースを作成する。
ROSTemplateFormatVersion: '2015-09-01'
Description:
zh-cn: Create a database for an existing RDS instance.
en: Create a database for an existing RDS instance.
Parameters:
RDSInstance:
AssociationProperty: ALIYUN::RDS::Instance::InstanceId
Type: String
Label:
zh-cn: RDS ID
en: RDS ID
DBName:
Type: String
Label:
zh-cn: DB Name
en: DB Name
Description:
zh-cn: The database name must be 2 to 64 characters in length. It must start with a lowercase letter and end with a lowercase letter or a digit. It can contain lowercase letters, digits, underscores (_), and hyphens (-).
en: The database name must be 2 to 64 characters in length. It must start with a lowercase letter and end with a lowercase letter or a digit. It can contain lowercase letters, digits, underscores (_), and hyphens (-).
Default: springboot_demo
Outputs: {}
Resources:
Database:
Type: ALIYUN::RDS::Database
Properties:
CharacterSetName: UTF8
DBInstanceId:
Ref: RDSInstance
DBName:
Ref: DBName
Metadata: {}
{
"ROSTemplateFormatVersion": "2015-09-01",
"Description": {
"zh-cn": "Create a database for an existing RDS instance.",
"en": "Create a database for an existing RDS instance."
},
"Parameters": {
"RDSInstance": {
"AssociationProperty": "ALIYUN::RDS::Instance::InstanceId",
"Type": "String",
"Label": {
"zh-cn": "RDS ID",
"en": "RDS ID"
}
},
"DBName": {
"Type": "String",
"Label": {
"zh-cn": "DB Name",
"en": "DB Name"
},
"Description": {
"zh-cn": "The database name must be 2 to 64 characters in length. It must start with a lowercase letter and end with a lowercase letter or a digit. It can contain lowercase letters, digits, underscores (_), and hyphens (-).",
"en": "The database name must be 2 to 64 characters in length. It must start with a lowercase letter and end with a lowercase letter or a digit. It can contain lowercase letters, digits, underscores (_), and hyphens (-)."
},
"Default": "springboot_demo"
}
},
"Outputs": {
},
"Resources": {
"Database": {
"Type": "ALIYUN::RDS::Database",
"Properties": {
"CharacterSetName": "UTF8",
"DBInstanceId": {
"Ref": "RDSInstance"
},
"DBName": {
"Ref": "DBName"
}
}
}
},
"Metadata": {
}
}シナリオ 2: 新しい RDS インスタンスとデータベースを作成する。
ROSTemplateFormatVersion: '2015-09-01'
Description:
zh-cn: Create a pay-as-you-go RDS Serverless MySQL instance and bind it to a database and a database account.
en: Create a pay-as-you-go RDS Serverless MySQL instance and bind it to a database and a database account.
Parameters:
VpcId:
AssociationProperty: ALIYUN::ECS::VPC::VPCId
Type: String
Description:
zh-cn: The ID of the VPC.
en: The ID of the VPC.
Label:
zh-cn: VPC ID
en: VPC ID
RdsAccountName:
Default: db_root
Type: String
Description:
zh-cn: The name of the MySQL administrator account.
en: The name of the MySQL administrator account.
Label:
zh-cn: Account Name
en: Account Name
ZoneId:
AssociationProperty: ALIYUN::ECS::Instance::ZoneId
Type: String
Label:
zh-cn: Primary Zone
en: Primary Zone
VSwitch:
AssociationProperty: ALIYUN::ECS::VSwitch::VSwitchId
AssociationPropertyMetadata:
VpcId: ${VpcId}
ZoneId: ${ZoneId}
Type: String
Description:
zh-cn: The ID of the vSwitch.
en: The ID of the vSwitch.
Label:
zh-cn: vSwitch ID
en: vSwitch ID
DBInstanceClass:
Default: mysql.n2.serverless.1c
AssociationProperty: ALIYUN::RDS::Instance::InstanceType
AssociationPropertyMetadata:
Engine: MySQL
EngineVersion: '8.0'
InstanceChargeType: Serverless
DBInstanceStorageType: cloud_essd
ZoneId: ${ZoneId}
Type: String
Label:
zh-cn: Instance Type
en: Instance Type
RdsAccountPassword:
Type: String
NoEcho: true
Description:
zh-cn: |-
The password must be 8 to 32 characters in length. It must contain at least three of the following character types: uppercase letters, lowercase letters, digits, and special characters. Supported special characters: !@#$&%^*()_+-=
en: |-
The password must be 8 to 32 characters in length. It must contain at least three of the following character types: uppercase letters, lowercase letters, digits, and special characters. Supported special characters: !@#$&%^*()_+-=
Label:
zh-cn: DB Account Password
en: DB Account Password
Outputs:
PublicConnectionString:
Value:
Fn::GetAtt:
- RDSInstance
- PublicConnectionString
InnerIPAddress:
Value:
Fn::GetAtt:
- RDSInstance
- InnerIPAddress
AccountName:
Value:
Fn::GetAtt:
- RdsAccount
- AccountName
PublicIPAddress:
Value:
Fn::GetAtt:
- RDSInstance
- PublicIPAddress
DBName:
Value:
Fn::GetAtt:
- Database
- DBName
InnerConnectionString:
Value:
Fn::GetAtt:
- RDSInstance
- InnerConnectionString
Resources:
RDSInstance:
Type: ALIYUN::RDS::DBInstance
Properties:
Category: serverless_basic
Engine: MySQL
DBInstanceStorage: 20
ServerlessConfig:
MinCapacity: 0.5
AutoPause: false
MaxCapacity: 8
SwitchForce: false
DBInstanceStorageType: cloud_essd
PayType: Serverless
ZoneId:
Ref: ZoneId
VpcId:
Ref: VpcId
VSwitchId:
Ref: VSwitch
EngineVersion: '8.0'
DBInstanceClass:
Ref: DBInstanceClass
SecurityIPList: 0.0.0.0/0
RdsAccount:
Type: ALIYUN::RDS::Account
Properties:
DBInstanceId:
Ref: RDSInstance
AccountPassword:
Ref: RdsAccountPassword
AccountType: Super
AccountName:
Ref: RdsAccountName
Database:
Type: ALIYUN::RDS::Database
Properties:
CharacterSetName: UTF8
DBInstanceId:
Ref: RDSInstance
DBName: springboot_demo
Metadata:
ALIYUN::ROS::Interface:
ParameterGroups:
- Parameters:
- VpcId
- ZoneId
- VSwitch
Label:
default:
zh-cn: Network Configuration
en: Network Configuration
- Parameters:
- DBInstanceClass
- RdsAccountName
- RdsAccountPassword
Label:
default:
zh-cn: RDS Configuration
en: RDS Configuration
{
"ROSTemplateFormatVersion": "2015-09-01",
"Description": {
"zh-cn": "Create a pay-as-you-go RDS Serverless MySQL instance and bind it to a database and a database account.",
"en": "Create a pay-as-you-go RDS Serverless MySQL instance and bind it to a database and a database account."
},
"Parameters": {
"VpcId": {
"AssociationProperty": "ALIYUN::ECS::VPC::VPCId",
"Type": "String",
"Description": {
"zh-cn": "The ID of the VPC.",
"en": "The ID of the VPC."
},
"Label": {
"zh-cn": "VPC ID",
"en": "VPC ID"
}
},
"RdsAccountName": {
"Default": "db_root",
"Type": "String",
"Description": {
"zh-cn": "The name of the MySQL administrator account.",
"en": "The name of the MySQL administrator account."
},
"Label": {
"zh-cn": "Account Name",
"en": "Account Name"
}
},
"ZoneId": {
"AssociationProperty": "ALIYUN::ECS::Instance::ZoneId",
"Type": "String",
"Label": {
"zh-cn": "Primary Zone",
"en": "Primary Zone"
}
},
"VSwitch": {
"AssociationProperty": "ALIYUN::ECS::VSwitch::VSwitchId",
"AssociationPropertyMetadata": {
"VpcId": "${VpcId}",
"ZoneId": "${ZoneId}"
},
"Type": "String",
"Description": {
"zh-cn": "The ID of the vSwitch.",
"en": "The ID of the vSwitch."
},
"Label": {
"zh-cn": "vSwitch ID",
"en": "vSwitch ID"
}
},
"DBInstanceClass": {
"Default": "mysql.n2.serverless.1c",
"AssociationProperty": "ALIYUN::RDS::Instance::InstanceType",
"AssociationPropertyMetadata": {
"Engine": "MySQL",
"EngineVersion": "8.0",
"InstanceChargeType": "Serverless",
"DBInstanceStorageType": "cloud_essd",
"ZoneId": "${ZoneId}"
},
"Type": "String",
"Label": {
"zh-cn": "Instance Type",
"en": "Instance Type"
}
},
"RdsAccountPassword": {
"Type": "String",
"NoEcho": true,
"Description": {
"zh-cn": "The password must be 8 to 32 characters in length. It must contain at least three of the following character types: uppercase letters, lowercase letters, digits, and special characters. Supported special characters: !@#$&%^*()_+-=",
"en": "The password must be 8 to 32 characters in length. It must contain at least three of the following character types: uppercase letters, lowercase letters, digits, and special characters. Supported special characters: !@#$&%^*()_+-="
},
"Label": {
"zh-cn": "DB Account Password",
"en": "DB Account Password"
}
}
},
"Outputs": {
"PublicConnectionString": {
"Value": {
"Fn::GetAtt": [
"RDSInstance",
"PublicConnectionString"
]
}
},
"InnerIPAddress": {
"Value": {
"Fn::GetAtt": [
"RDSInstance",
"InnerIPAddress"
]
}
},
"AccountName": {
"Value": {
"Fn::GetAtt": [
"RdsAccount",
"AccountName"
]
}
},
"PublicIPAddress": {
"Value": {
"Fn::GetAtt": [
"RDSInstance",
"PublicIPAddress"
]
}
},
"DBName": {
"Value": {
"Fn::GetAtt": [
"Database",
"DBName"
]
}
},
"InnerConnectionString": {
"Value": {
"Fn::GetAtt": [
"RDSInstance",
"InnerConnectionString"
]
}
}
},
"Resources": {
"RDSInstance": {
"Type": "ALIYUN::RDS::DBInstance",
"Properties": {
"Category": "serverless_basic",
"Engine": "MySQL",
"DBInstanceStorage": 20,
"ServerlessConfig": {
"MinCapacity": 0.5,
"AutoPause": false,
"MaxCapacity": 8,
"SwitchForce": false
},
"DBInstanceStorageType": "cloud_essd",
"PayType": "Serverless",
"ZoneId": {
"Ref": "ZoneId"
},
"VpcId": {
"Ref": "VpcId"
},
"VSwitchId": {
"Ref": "VSwitch"
},
"EngineVersion": "8.0",
"DBInstanceClass": {
"Ref": "DBInstanceClass"
},
"SecurityIPList": "0.0.0.0/0"
}
},
"RdsAccount": {
"Type": "ALIYUN::RDS::Account",
"Properties": {
"DBInstanceId": {
"Ref": "RDSInstance"
},
"AccountPassword": {
"Ref": "RdsAccountPassword"
},
"AccountType": "Super",
"AccountName": {
"Ref": "RdsAccountName"
}
}
},
"Database": {
"Type": "ALIYUN::RDS::Database",
"Properties": {
"CharacterSetName": "UTF8",
"DBInstanceId": {
"Ref": "RDSInstance"
},
"DBName": "springboot_demo"
}
}
},
"Metadata": {
"ALIYUN::ROS::Interface": {
"ParameterGroups": [
{
"Parameters": [
"VpcId",
"ZoneId",
"VSwitch"
],
"Label": {
"default": {
"zh-cn": "Network Configuration",
"en": "Network Configuration"
}
}
},
{
"Parameters": [
"DBInstanceClass",
"RdsAccountName",
"RdsAccountPassword"
],
"Label": {
"default": {
"zh-cn": "RDS Configuration",
"en": "RDS Configuration"
}
}
}
]
}
}
}その他の例については、「このリソースを使用する公開テンプレート」をご参照ください。