azurermMysqlFlexibleServer
Manages a MySQL Flexible Server.
Example Usage
/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as azurerm from "./.gen/providers/azurerm";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: azurerm.
For a more precise conversion please use the --provider flag in convert.*/
new azurerm.provider.AzurermProvider(this, "azurerm", {
features: [{}],
});
const azurermResourceGroupExample = new azurerm.resourceGroup.ResourceGroup(
this,
"example",
{
location: "West Europe",
name: "example-resources",
}
);
const azurermVirtualNetworkExample = new azurerm.virtualNetwork.VirtualNetwork(
this,
"example_2",
{
address_space: ["10.0.0.0/16"],
location: azurermResourceGroupExample.location,
name: "example-vn",
resource_group_name: azurermResourceGroupExample.name,
}
);
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermVirtualNetworkExample.overrideLogicalId("example");
const azurermPrivateDnsZoneExample = new azurerm.privateDnsZone.PrivateDnsZone(
this,
"example_3",
{
name: "example.mysql.database.azure.com",
resource_group_name: azurermResourceGroupExample.name,
}
);
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermPrivateDnsZoneExample.overrideLogicalId("example");
const azurermPrivateDnsZoneVirtualNetworkLinkExample =
new azurerm.privateDnsZoneVirtualNetworkLink.PrivateDnsZoneVirtualNetworkLink(
this,
"example_4",
{
name: "exampleVnetZone.com",
private_dns_zone_name: azurermPrivateDnsZoneExample.name,
resource_group_name: azurermResourceGroupExample.name,
virtual_network_id: azurermVirtualNetworkExample.id,
}
);
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermPrivateDnsZoneVirtualNetworkLinkExample.overrideLogicalId("example");
const azurermSubnetExample = new azurerm.subnet.Subnet(this, "example_5", {
address_prefixes: ["10.0.2.0/24"],
delegation: [
{
name: "fs",
service_delegation: [
{
actions: ["Microsoft.Network/virtualNetworks/subnets/join/action"],
name: "Microsoft.DBforMySQL/flexibleServers",
},
],
},
],
name: "example-sn",
resource_group_name: azurermResourceGroupExample.name,
service_endpoints: ["Microsoft.Storage"],
virtual_network_name: azurermVirtualNetworkExample.name,
});
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermSubnetExample.overrideLogicalId("example");
const azurermMysqlFlexibleServerExample =
new azurerm.mysqlFlexibleServer.MysqlFlexibleServer(this, "example_6", {
administrator_login: "psqladmin",
administrator_password: "H@Sh1CoR3!",
backup_retention_days: 7,
delegated_subnet_id: azurermSubnetExample.id,
depends_on: [`\${${azurermPrivateDnsZoneVirtualNetworkLinkExample.fqn}}`],
location: azurermResourceGroupExample.location,
name: "example-fs",
private_dns_zone_id: azurermPrivateDnsZoneExample.id,
resource_group_name: azurermResourceGroupExample.name,
sku_name: "GP_Standard_D2ds_v4",
});
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermMysqlFlexibleServerExample.overrideLogicalId("example");
Arguments Reference
The following arguments are supported:
-
name
- (Required) The name which should be used for this MySQL Flexible Server. Changing this forces a new MySQL Flexible Server to be created. -
resourceGroupName
- (Required) The name of the Resource Group where the MySQL Flexible Server should exist. Changing this forces a new MySQL Flexible Server to be created. -
location
- (Required) The Azure Region where the MySQL Flexible Server should exist. Changing this forces a new MySQL Flexible Server to be created. -
administratorLogin
- (Optional) The Administrator login for the MySQL Flexible Server. Required whencreateMode
isdefault
. Changing this forces a new MySQL Flexible Server to be created. -
administratorPassword
- (Optional) The Password associated with theadministratorLogin
for the MySQL Flexible Server. Required whencreateMode
isdefault
. -
backupRetentionDays
- (Optional) The backup retention days for the MySQL Flexible Server. Possible values are between1
and35
days. Defaults to7
. -
createMode
- (Optional)The creation mode which can be used to restore or replicate existing servers. Possible values aredefault
,pointInTimeRestore
,geoRestore
, andreplica
. Changing this forces a new MySQL Flexible Server to be created.
\~> NOTE: Creating a geoRestore
server requires the source server with geoRedundantBackupEnabled
enabled.
\~> NOTE: The best practise is that it has to wait greater than 10 minutes to create the geoRestore
server once the source server is created.
-
customerManagedKey
- (Optional) AcustomerManagedKey
block as defined below. -
delegatedSubnetId
- (Optional) The ID of the virtual network subnet to create the MySQL Flexible Server. Changing this forces a new MySQL Flexible Server to be created. -
geoRedundantBackupEnabled
- (Optional) Should geo redundant backup enabled? Defaults tofalse
. Changing this forces a new MySQL Flexible Server to be created. -
highAvailability
- (Optional) AhighAvailability
block as defined below. -
identity
- (Optional) Anidentity
block as defined below. -
maintenanceWindow
- (Optional) AmaintenanceWindow
block as defined below. -
pointInTimeRestoreTimeInUtc
- (Optional) The point in time to restore fromcreationSourceServerId
whencreateMode
ispointInTimeRestore
. Changing this forces a new MySQL Flexible Server to be created. -
privateDnsZoneId
- (Optional) The ID of the private DNS zone to create the MySQL Flexible Server. Changing this forces a new MySQL Flexible Server to be created.
\~> NOTE: The privateDnsZoneId
is required when setting a delegatedSubnetId
. The azurermPrivateDnsZone
should end with suffix mysqlDatabaseAzureCom
.
replicationRole
- (Optional) The replication role. Possible value isnone
.
\~> NOTE: The replicationRole
cannot be set while creating and only can be updated from replica
to none
.
skuName
- (Optional) The SKU Name for the MySQL Flexible Server.
-> NOTE: skuName
should start with SKU tier b (burstable)
, gp (generalPurpose)
, mo (memoryOptimized)
like bStandardB1S
.
-
sourceServerId
- (Optional)The resource ID of the source MySQL Flexible Server to be restored. Required whencreateMode
ispointInTimeRestore
,geoRestore
, andreplica
. Changing this forces a new MySQL Flexible Server to be created. -
storage
- (Optional) Astorage
block as defined below. -
version
- (Optional) The version of the MySQL Flexible Server to use. Possible values are57
, and8021
. Changing this forces a new MySQL Flexible Server to be created. -
zone
- (Optional) Specifies the Availability Zone in which this MySQL Flexible Server should be located. Possible values are1
,2
and3
. -
tags
- (Optional) A mapping of tags which should be assigned to the MySQL Flexible Server.
A customerManagedKey
block supports the following:
-
keyVaultKeyId
- (Optional) The ID of the Key Vault Key. -
primaryUserAssignedIdentityId
- (Optional) Specifies the primary user managed identity id for a Customer Managed Key. Should be added withidentityIds
. -
geoBackupKeyVaultKeyId
- (Optional) The ID of the geo backup Key Vault Key. It can't cross region and need Customer Managed Key in same region as geo backup. -
geoBackupUserAssignedIdentityId
- (Optional) The geo backup user managed identity id for a Customer Managed Key. Should be added withidentityIds
. It can't cross region and need identity in same region as geo backup.
\~> NOTE: primaryUserAssignedIdentityId
or geoBackupUserAssignedIdentityId
is required when type
is set to userAssigned
or systemAssigned,UserAssigned
.
An identity
block supports the following:
-
type
- (Required) Specifies the type of Managed Service Identity that should be configured on this API Management Service. Should be set touserAssigned
,systemAssigned,UserAssigned
(to enable both). -
identityIds
- (Optional) A list of User Assigned Managed Identity IDs to be assigned to this API Management Service. Required if used together withcustomerManagedKey
block.
\~> NOTE: This is required when type
is set to userAssigned
or systemAssigned,UserAssigned
.
A highAvailability
block supports the following:
mode
- (Required) The high availability mode for the MySQL Flexible Server. Possibles values aresameZone
andzoneRedundant
.
\~> NOTE: storage0AutoGrowEnabled
must be enabled when highAvailability
is enabled. To change the highAvailability
for a MySQL Flexible Server created with highAvailability
disabled during creation, the resource has to be recreated.
standbyAvailabilityZone
- (Optional) Specifies the Availability Zone in which the standby Flexible Server should be located. Possible values are1
,2
and3
.
\~> NOTE: The standbyAvailabilityZone
will be omitted when mode is sameZone
, for the standbyAvailabilityZone
will be the same as zone
.
A maintenanceWindow
block supports the following:
-
dayOfWeek
- (Optional) The day of week for maintenance window. Defaults to0
. -
startHour
- (Optional) The start hour for maintenance window. Defaults to0
. -
startMinute
- (Optional) The start minute for maintenance window. Defaults to0
.
A storage
block supports the following:
-
autoGrowEnabled
- (Optional) Should Storage Auto Grow be enabled? Defaults totrue
. -
iops
- (Optional) The storage IOPS for the MySQL Flexible Server. Possible values are between360
and20000
. -
sizeGb
- (Optional) The max storage allowed for the MySQL Flexible Server. Possible values are between20
and16384
.
Attributes Reference
In addition to the Arguments listed above - the following Attributes are exported:
-
id
- The ID of the MySQL Flexible Server. -
fqdn
- The fully qualified domain name of the MySQL Flexible Server. -
publicNetworkAccessEnabled
- Is the public network access enabled? -
replicaCapacity
- The maximum number of replicas that a primary MySQL Flexible Server can have.
Timeouts
The timeouts
block allows you to specify timeouts for certain actions:
create
- (Defaults to 1 hour) Used when creating the MySQL Flexible Server.read
- (Defaults to 5 minutes) Used when retrieving the MySQL Flexible Server.update
- (Defaults to 1 hour) Used when updating the MySQL Flexible Server.delete
- (Defaults to 1 hour) Used when deleting the MySQL Flexible Server.
Import
MySQL Flexible Servers can be imported using the resourceId
, e.g.