Example Database Virtual Server creation Heat template
Creating_a_database_virtual_server.yaml
This is an example of a template for creating a DB Subnet Group, a DB Parameter Group, and a Database Virtual Server.
It creates the following configuration.
#
# This template creates a DB Subnet Group, a DB Parameter Group, and a Database Virtual Server.
#
heat_template_version: 2013-05-23
description: >
Create a database Virtual Server.
parameters:
DB_SUBNET_GROUP_NAME:
type: string
description: Name of the DB Subnet Group
default: SampleDbSubnetGroup01
DB_SECURITY_GROUP_ID:
type: string
description: ID of the Security Group to deploy the Database Virtual Server in
default: 935ce03a-73d2-475a-a21e-dff8ecb5gtsd
DB_SUBNET_ID_1:
type: string
description: Subnet ID 1 to register in the DB Subnet Group
default: 13ye9b10-85mb-4791-aced-c3a8bddc675e
DB_SUBNET_ID_2:
type: string
description: Subnet ID 2 to register in the DB Subnet Group
default: 196e758b-54ae-4f3c-9f00-ce8714dc072m
DB_PARAMETER_GROUP_NAME:
type: string
description: Name of the DB Parameter Group
default: SampleDbParameterGroup01
PARAMETER_GROUP_FAMILY:
type: string
description: Type of Parameter Group decided based on the Database engine and version
default: enterprisepostgres_v9.6
DB_INSTANCE_NAME:
type: string
description: Name of the Database Virtual Server
default: SampleDbInstance01
AZ:
type: string
description: Name of the Availability Zone
default: jp-west-2a
DB_VOLUME_SIZE:
type: string
description: Volume size of the Database Virtual Server
default: "30"
DB_STRUCTURE_NAME:
type: string
description: Database name
default: database01
DB_MASTER_USER_NAME:
type: string
description: Database administrator user name
default: root
DB_MASTER_PASSWORD:
type: string
description: Database administrator user password
hidden: true
default: rootroot
DB_USER_NAME:
type: string
description: Database system user name
hidden: true
default: user01
DB_USER_PASSWORD:
type: string
description: Database system user password
hidden: true
default: user01passwd
DB_PORT:
type: string
description: Number of the port used by the Database
default: 5432
MULTI_FLAG:
type: string
description: Specify "true" or "false" for the Multi-DB setting (Redundancy inside the same Availability Zone)
default: "true"
MULTI_AZ_FLAG:
type: string
description: Specify "true" or "false" for the Multi-AZ setting (Redundancy inside a different Availability Zone)
default: "false"
FLAVOR_ID:
type: string
description: Flavor ID of the Database Virtual Server
default: "1101"
resources:
DB_SUBNET_GROUP:
type: FCX::Database::DBSubnetGroup
properties:
name: { get_param: DB_SUBNET_GROUP_NAME }
subnet_ids: [{"subnet_id": { get_param: DB_SUBNET_ID_1 }}, { "subnet_id": { get_param: DB_SUBNET_ID_2 }}]
DB_PARAMETER_GROUP:
type: FCX::Database::DBParameterGroup
properties:
name: { get_param: DB_PARAMETER_GROUP_NAME }
parameter_group_family: { get_param: PARAMETER_GROUP_FAMILY }
DB_INSTANCE:
type: FCX::Database::DBInstance
properties:
name: {get_param: DB_INSTANCE_NAME }
flavor: { get_param: FLAVOR_ID }
size: { get_param: DB_VOLUME_SIZE }
disk_type: "M1"
availability_zone: { get_param: AZ }
subnet_group_id: { get_resource: DB_SUBNET_GROUP }
multi: { get_param: MULTI_FLAG }
multi_az: { get_param: MULTI_AZ_FLAG }
port: { get_param: DB_PORT }
publicly_accessible: false
security_group_ids: [{get_param: DB_SECURITY_GROUP_ID}]
parameter_group_id: { get_resource: DB_PARAMETER_GROUP }
backup_retention_period: 0
masteruser_name: { get_param: DB_MASTER_USER_NAME }
masteruser_password: { get_param: DB_MASTER_PASSWORD }
databases: ["name": { get_param: DB_STRUCTURE_NAME} ]
users: [{ "name": { get_param: DB_USER_NAME }, "password": { get_param: DB_USER_PASSWORD }, databases: [{ get_param: DB_STRUCTURE_NAME}] }]
outputs:
db_instance_internal_fqdn:
description: db_instance internal fqdn
value: { get_attr: [DB_INSTANCE, PRIVATEADDRESS] }
db_instance_internal_ip:
description: db_instance internal ip
value: { get_attr: [DB_INSTANCE, PRIVATEIP] }
db_instance_internal_sub_ip:
description: db_instance slave ip
value: { get_attr: [DB_INSTANCE, SUBPRIVATEIP] }