com.pulumi.azure.mysql.FlexibleServer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of azure Show documentation
Show all versions of azure Show documentation
A Pulumi package for creating and managing Microsoft Azure cloud resources, based on the Terraform azurerm provider. We recommend using the [Azure Native provider](https://github.com/pulumi/pulumi-azure-native) to provision Azure infrastructure. Azure Native provides complete coverage of Azure resources and same-day access to new resources and resource updates.
// *** WARNING: this file was generated by pulumi-java-gen. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
package com.pulumi.azure.mysql;
import com.pulumi.azure.Utilities;
import com.pulumi.azure.mysql.FlexibleServerArgs;
import com.pulumi.azure.mysql.inputs.FlexibleServerState;
import com.pulumi.azure.mysql.outputs.FlexibleServerCustomerManagedKey;
import com.pulumi.azure.mysql.outputs.FlexibleServerHighAvailability;
import com.pulumi.azure.mysql.outputs.FlexibleServerIdentity;
import com.pulumi.azure.mysql.outputs.FlexibleServerMaintenanceWindow;
import com.pulumi.azure.mysql.outputs.FlexibleServerStorage;
import com.pulumi.core.Output;
import com.pulumi.core.annotations.Export;
import com.pulumi.core.annotations.ResourceType;
import com.pulumi.core.internal.Codegen;
import java.lang.Boolean;
import java.lang.Integer;
import java.lang.String;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import javax.annotation.Nullable;
/**
* Manages a MySQL Flexible Server.
*
* ## Example Usage
*
* <!--Start PulumiCodeChooser -->
*
* {@code
* package generated_program;
*
* import com.pulumi.Context;
* import com.pulumi.Pulumi;
* import com.pulumi.core.Output;
* import com.pulumi.azure.core.ResourceGroup;
* import com.pulumi.azure.core.ResourceGroupArgs;
* import com.pulumi.azure.network.VirtualNetwork;
* import com.pulumi.azure.network.VirtualNetworkArgs;
* import com.pulumi.azure.network.Subnet;
* import com.pulumi.azure.network.SubnetArgs;
* import com.pulumi.azure.network.inputs.SubnetDelegationArgs;
* import com.pulumi.azure.network.inputs.SubnetDelegationServiceDelegationArgs;
* import com.pulumi.azure.privatedns.Zone;
* import com.pulumi.azure.privatedns.ZoneArgs;
* import com.pulumi.azure.privatedns.ZoneVirtualNetworkLink;
* import com.pulumi.azure.privatedns.ZoneVirtualNetworkLinkArgs;
* import com.pulumi.azure.mysql.FlexibleServer;
* import com.pulumi.azure.mysql.FlexibleServerArgs;
* import com.pulumi.resources.CustomResourceOptions;
* import java.util.List;
* import java.util.ArrayList;
* import java.util.Map;
* import java.io.File;
* import java.nio.file.Files;
* import java.nio.file.Paths;
*
* public class App }{{@code
* public static void main(String[] args) }{{@code
* Pulumi.run(App::stack);
* }}{@code
*
* public static void stack(Context ctx) }{{@code
* var example = new ResourceGroup("example", ResourceGroupArgs.builder()
* .name("example-resources")
* .location("West Europe")
* .build());
*
* var exampleVirtualNetwork = new VirtualNetwork("exampleVirtualNetwork", VirtualNetworkArgs.builder()
* .name("example-vn")
* .location(example.location())
* .resourceGroupName(example.name())
* .addressSpaces("10.0.0.0/16")
* .build());
*
* var exampleSubnet = new Subnet("exampleSubnet", SubnetArgs.builder()
* .name("example-sn")
* .resourceGroupName(example.name())
* .virtualNetworkName(exampleVirtualNetwork.name())
* .addressPrefixes("10.0.2.0/24")
* .serviceEndpoints("Microsoft.Storage")
* .delegations(SubnetDelegationArgs.builder()
* .name("fs")
* .serviceDelegation(SubnetDelegationServiceDelegationArgs.builder()
* .name("Microsoft.DBforMySQL/flexibleServers")
* .actions("Microsoft.Network/virtualNetworks/subnets/join/action")
* .build())
* .build())
* .build());
*
* var exampleZone = new Zone("exampleZone", ZoneArgs.builder()
* .name("example.mysql.database.azure.com")
* .resourceGroupName(example.name())
* .build());
*
* var exampleZoneVirtualNetworkLink = new ZoneVirtualNetworkLink("exampleZoneVirtualNetworkLink", ZoneVirtualNetworkLinkArgs.builder()
* .name("exampleVnetZone.com")
* .privateDnsZoneName(exampleZone.name())
* .virtualNetworkId(exampleVirtualNetwork.id())
* .resourceGroupName(example.name())
* .build());
*
* var exampleFlexibleServer = new FlexibleServer("exampleFlexibleServer", FlexibleServerArgs.builder()
* .name("example-fs")
* .resourceGroupName(example.name())
* .location(example.location())
* .administratorLogin("psqladmin")
* .administratorPassword("H}{@literal @}{@code Sh1CoR3!")
* .backupRetentionDays(7)
* .delegatedSubnetId(exampleSubnet.id())
* .privateDnsZoneId(exampleZone.id())
* .skuName("GP_Standard_D2ds_v4")
* .build(), CustomResourceOptions.builder()
* .dependsOn(exampleZoneVirtualNetworkLink)
* .build());
*
* }}{@code
* }}{@code
* }
*
* <!--End PulumiCodeChooser -->
*
* ## Import
*
* MySQL Flexible Servers can be imported using the `resource id`, e.g.
*
* ```sh
* $ pulumi import azure:mysql/flexibleServer:FlexibleServer example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.DBforMySQL/flexibleServers/flexibleServer1
* ```
*
*/
@ResourceType(type="azure:mysql/flexibleServer:FlexibleServer")
public class FlexibleServer extends com.pulumi.resources.CustomResource {
/**
* The Administrator login for the MySQL Flexible Server. Required when `create_mode` is `Default`. Changing this forces a new MySQL Flexible Server to be created.
*
*/
@Export(name="administratorLogin", refs={String.class}, tree="[0]")
private Output administratorLogin;
/**
* @return The Administrator login for the MySQL Flexible Server. Required when `create_mode` is `Default`. Changing this forces a new MySQL Flexible Server to be created.
*
*/
public Output administratorLogin() {
return this.administratorLogin;
}
/**
* The Password associated with the `administrator_login` for the MySQL Flexible Server. Required when `create_mode` is `Default`.
*
*/
@Export(name="administratorPassword", refs={String.class}, tree="[0]")
private Output* @Nullable */ String> administratorPassword;
/**
* @return The Password associated with the `administrator_login` for the MySQL Flexible Server. Required when `create_mode` is `Default`.
*
*/
public Output> administratorPassword() {
return Codegen.optional(this.administratorPassword);
}
/**
* The backup retention days for the MySQL Flexible Server. Possible values are between `1` and `35` days. Defaults to `7`.
*
*/
@Export(name="backupRetentionDays", refs={Integer.class}, tree="[0]")
private Output* @Nullable */ Integer> backupRetentionDays;
/**
* @return The backup retention days for the MySQL Flexible Server. Possible values are between `1` and `35` days. Defaults to `7`.
*
*/
public Output> backupRetentionDays() {
return Codegen.optional(this.backupRetentionDays);
}
/**
* The creation mode which can be used to restore or replicate existing servers. Possible values are `Default`, `PointInTimeRestore`, `GeoRestore`, and `Replica`. Changing this forces a new MySQL Flexible Server to be created.
*
* > **NOTE:** Creating a `GeoRestore` server requires the source server with `geo_redundant_backup_enabled` enabled.
*
* > **NOTE:** When a server is first created it may not be immediately available for `geo restore` or `replica`. It may take a few minutes to several hours for the necessary metadata to be populated. Please see the [Geo Restore](https://learn.microsoft.com/azure/mysql/single-server/how-to-restore-server-portal#geo-restore) and the [Replica](https://learn.microsoft.com/azure/mysql/flexible-server/concepts-read-replicas#create-a-replica) for more information.
*
*/
@Export(name="createMode", refs={String.class}, tree="[0]")
private Output* @Nullable */ String> createMode;
/**
* @return The creation mode which can be used to restore or replicate existing servers. Possible values are `Default`, `PointInTimeRestore`, `GeoRestore`, and `Replica`. Changing this forces a new MySQL Flexible Server to be created.
*
* > **NOTE:** Creating a `GeoRestore` server requires the source server with `geo_redundant_backup_enabled` enabled.
*
* > **NOTE:** When a server is first created it may not be immediately available for `geo restore` or `replica`. It may take a few minutes to several hours for the necessary metadata to be populated. Please see the [Geo Restore](https://learn.microsoft.com/azure/mysql/single-server/how-to-restore-server-portal#geo-restore) and the [Replica](https://learn.microsoft.com/azure/mysql/flexible-server/concepts-read-replicas#create-a-replica) for more information.
*
*/
public Output> createMode() {
return Codegen.optional(this.createMode);
}
/**
* A `customer_managed_key` block as defined below.
*
* > **NOTE:** `identity` is required when `customer_managed_key` is specified.
*
*/
@Export(name="customerManagedKey", refs={FlexibleServerCustomerManagedKey.class}, tree="[0]")
private Output* @Nullable */ FlexibleServerCustomerManagedKey> customerManagedKey;
/**
* @return A `customer_managed_key` block as defined below.
*
* > **NOTE:** `identity` is required when `customer_managed_key` is specified.
*
*/
public Output> customerManagedKey() {
return Codegen.optional(this.customerManagedKey);
}
/**
* The ID of the virtual network subnet to create the MySQL Flexible Server. Changing this forces a new MySQL Flexible Server to be created.
*
*/
@Export(name="delegatedSubnetId", refs={String.class}, tree="[0]")
private Output* @Nullable */ String> delegatedSubnetId;
/**
* @return The ID of the virtual network subnet to create the MySQL Flexible Server. Changing this forces a new MySQL Flexible Server to be created.
*
*/
public Output> delegatedSubnetId() {
return Codegen.optional(this.delegatedSubnetId);
}
/**
* The fully qualified domain name of the MySQL Flexible Server.
*
*/
@Export(name="fqdn", refs={String.class}, tree="[0]")
private Output fqdn;
/**
* @return The fully qualified domain name of the MySQL Flexible Server.
*
*/
public Output fqdn() {
return this.fqdn;
}
/**
* Should geo redundant backup enabled? Defaults to `false`. Changing this forces a new MySQL Flexible Server to be created.
*
*/
@Export(name="geoRedundantBackupEnabled", refs={Boolean.class}, tree="[0]")
private Output* @Nullable */ Boolean> geoRedundantBackupEnabled;
/**
* @return Should geo redundant backup enabled? Defaults to `false`. Changing this forces a new MySQL Flexible Server to be created.
*
*/
public Output> geoRedundantBackupEnabled() {
return Codegen.optional(this.geoRedundantBackupEnabled);
}
/**
* A `high_availability` block as defined below.
*
*/
@Export(name="highAvailability", refs={FlexibleServerHighAvailability.class}, tree="[0]")
private Output* @Nullable */ FlexibleServerHighAvailability> highAvailability;
/**
* @return A `high_availability` block as defined below.
*
*/
public Output> highAvailability() {
return Codegen.optional(this.highAvailability);
}
/**
* An `identity` block as defined below.
*
*/
@Export(name="identity", refs={FlexibleServerIdentity.class}, tree="[0]")
private Output* @Nullable */ FlexibleServerIdentity> identity;
/**
* @return An `identity` block as defined below.
*
*/
public Output> identity() {
return Codegen.optional(this.identity);
}
/**
* The Azure Region where the MySQL Flexible Server should exist. Changing this forces a new MySQL Flexible Server to be created.
*
*/
@Export(name="location", refs={String.class}, tree="[0]")
private Output location;
/**
* @return The Azure Region where the MySQL Flexible Server should exist. Changing this forces a new MySQL Flexible Server to be created.
*
*/
public Output location() {
return this.location;
}
/**
* A `maintenance_window` block as defined below.
*
*/
@Export(name="maintenanceWindow", refs={FlexibleServerMaintenanceWindow.class}, tree="[0]")
private Output* @Nullable */ FlexibleServerMaintenanceWindow> maintenanceWindow;
/**
* @return A `maintenance_window` block as defined below.
*
*/
public Output> maintenanceWindow() {
return Codegen.optional(this.maintenanceWindow);
}
/**
* The name which should be used for this MySQL Flexible Server. Changing this forces a new MySQL Flexible Server to be created.
*
*/
@Export(name="name", refs={String.class}, tree="[0]")
private Output name;
/**
* @return The name which should be used for this MySQL Flexible Server. Changing this forces a new MySQL Flexible Server to be created.
*
*/
public Output name() {
return this.name;
}
/**
* The point in time to restore from `creation_source_server_id` when `create_mode` is `PointInTimeRestore`. Changing this forces a new MySQL Flexible Server to be created.
*
*/
@Export(name="pointInTimeRestoreTimeInUtc", refs={String.class}, tree="[0]")
private Output* @Nullable */ String> pointInTimeRestoreTimeInUtc;
/**
* @return The point in time to restore from `creation_source_server_id` when `create_mode` is `PointInTimeRestore`. Changing this forces a new MySQL Flexible Server to be created.
*
*/
public Output> pointInTimeRestoreTimeInUtc() {
return Codegen.optional(this.pointInTimeRestoreTimeInUtc);
}
/**
* 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 `private_dns_zone_id` is required when setting a `delegated_subnet_id`. The `azure.privatedns.Zone` should end with suffix `.mysql.database.azure.com`.
*
*/
@Export(name="privateDnsZoneId", refs={String.class}, tree="[0]")
private Output* @Nullable */ String> privateDnsZoneId;
/**
* @return 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 `private_dns_zone_id` is required when setting a `delegated_subnet_id`. The `azure.privatedns.Zone` should end with suffix `.mysql.database.azure.com`.
*
*/
public Output> privateDnsZoneId() {
return Codegen.optional(this.privateDnsZoneId);
}
/**
* Is the public network access enabled?
*
*/
@Export(name="publicNetworkAccessEnabled", refs={Boolean.class}, tree="[0]")
private Output publicNetworkAccessEnabled;
/**
* @return Is the public network access enabled?
*
*/
public Output publicNetworkAccessEnabled() {
return this.publicNetworkAccessEnabled;
}
/**
* The maximum number of replicas that a primary MySQL Flexible Server can have.
*
*/
@Export(name="replicaCapacity", refs={Integer.class}, tree="[0]")
private Output replicaCapacity;
/**
* @return The maximum number of replicas that a primary MySQL Flexible Server can have.
*
*/
public Output replicaCapacity() {
return this.replicaCapacity;
}
/**
* The replication role. Possible value is `None`.
*
* > **NOTE:** The `replication_role` cannot be set while creating and only can be updated from `Replica` to `None`.
*
*/
@Export(name="replicationRole", refs={String.class}, tree="[0]")
private Output replicationRole;
/**
* @return The replication role. Possible value is `None`.
*
* > **NOTE:** The `replication_role` cannot be set while creating and only can be updated from `Replica` to `None`.
*
*/
public Output replicationRole() {
return this.replicationRole;
}
/**
* The name of the Resource Group where the MySQL Flexible Server should exist. Changing this forces a new MySQL Flexible Server to be created.
*
*/
@Export(name="resourceGroupName", refs={String.class}, tree="[0]")
private Output resourceGroupName;
/**
* @return The name of the Resource Group where the MySQL Flexible Server should exist. Changing this forces a new MySQL Flexible Server to be created.
*
*/
public Output resourceGroupName() {
return this.resourceGroupName;
}
/**
* The SKU Name for the MySQL Flexible Server.
*
* > **NOTE:** `sku_name` should start with SKU tier `B (Burstable)`, `GP (General Purpose)`, `MO (Memory Optimized)` like `B_Standard_B1s`.
*
*/
@Export(name="skuName", refs={String.class}, tree="[0]")
private Output skuName;
/**
* @return The SKU Name for the MySQL Flexible Server.
*
* > **NOTE:** `sku_name` should start with SKU tier `B (Burstable)`, `GP (General Purpose)`, `MO (Memory Optimized)` like `B_Standard_B1s`.
*
*/
public Output skuName() {
return this.skuName;
}
/**
* The resource ID of the source MySQL Flexible Server to be restored. Required when `create_mode` is `PointInTimeRestore`, `GeoRestore`, and `Replica`. Changing this forces a new MySQL Flexible Server to be created.
*
*/
@Export(name="sourceServerId", refs={String.class}, tree="[0]")
private Output* @Nullable */ String> sourceServerId;
/**
* @return The resource ID of the source MySQL Flexible Server to be restored. Required when `create_mode` is `PointInTimeRestore`, `GeoRestore`, and `Replica`. Changing this forces a new MySQL Flexible Server to be created.
*
*/
public Output> sourceServerId() {
return Codegen.optional(this.sourceServerId);
}
/**
* A `storage` block as defined below.
*
*/
@Export(name="storage", refs={FlexibleServerStorage.class}, tree="[0]")
private Output storage;
/**
* @return A `storage` block as defined below.
*
*/
public Output storage() {
return this.storage;
}
/**
* A mapping of tags which should be assigned to the MySQL Flexible Server.
*
*/
@Export(name="tags", refs={Map.class,String.class}, tree="[0,1,1]")
private Output* @Nullable */ Map> tags;
/**
* @return A mapping of tags which should be assigned to the MySQL Flexible Server.
*
*/
public Output>> tags() {
return Codegen.optional(this.tags);
}
/**
* The version of the MySQL Flexible Server to use. Possible values are `5.7`, and `8.0.21`. Changing this forces a new MySQL Flexible Server to be created.
*
*/
@Export(name="version", refs={String.class}, tree="[0]")
private Output version;
/**
* @return The version of the MySQL Flexible Server to use. Possible values are `5.7`, and `8.0.21`. Changing this forces a new MySQL Flexible Server to be created.
*
*/
public Output version() {
return this.version;
}
@Export(name="zone", refs={String.class}, tree="[0]")
private Output* @Nullable */ String> zone;
public Output> zone() {
return Codegen.optional(this.zone);
}
/**
*
* @param name The _unique_ name of the resulting resource.
*/
public FlexibleServer(java.lang.String name) {
this(name, FlexibleServerArgs.Empty);
}
/**
*
* @param name The _unique_ name of the resulting resource.
* @param args The arguments to use to populate this resource's properties.
*/
public FlexibleServer(java.lang.String name, FlexibleServerArgs args) {
this(name, args, null);
}
/**
*
* @param name The _unique_ name of the resulting resource.
* @param args The arguments to use to populate this resource's properties.
* @param options A bag of options that control this resource's behavior.
*/
public FlexibleServer(java.lang.String name, FlexibleServerArgs args, @Nullable com.pulumi.resources.CustomResourceOptions options) {
super("azure:mysql/flexibleServer:FlexibleServer", name, makeArgs(args, options), makeResourceOptions(options, Codegen.empty()), false);
}
private FlexibleServer(java.lang.String name, Output id, @Nullable FlexibleServerState state, @Nullable com.pulumi.resources.CustomResourceOptions options) {
super("azure:mysql/flexibleServer:FlexibleServer", name, state, makeResourceOptions(options, id), false);
}
private static FlexibleServerArgs makeArgs(FlexibleServerArgs args, @Nullable com.pulumi.resources.CustomResourceOptions options) {
if (options != null && options.getUrn().isPresent()) {
return null;
}
return args == null ? FlexibleServerArgs.Empty : args;
}
private static com.pulumi.resources.CustomResourceOptions makeResourceOptions(@Nullable com.pulumi.resources.CustomResourceOptions options, @Nullable Output id) {
var defaultOptions = com.pulumi.resources.CustomResourceOptions.builder()
.version(Utilities.getVersion())
.additionalSecretOutputs(List.of(
"administratorPassword"
))
.build();
return com.pulumi.resources.CustomResourceOptions.merge(defaultOptions, options, id);
}
/**
* Get an existing Host resource's state with the given name, ID, and optional extra
* properties used to qualify the lookup.
*
* @param name The _unique_ name of the resulting resource.
* @param id The _unique_ provider ID of the resource to lookup.
* @param state
* @param options Optional settings to control the behavior of the CustomResource.
*/
public static FlexibleServer get(java.lang.String name, Output id, @Nullable FlexibleServerState state, @Nullable com.pulumi.resources.CustomResourceOptions options) {
return new FlexibleServer(name, id, state, options);
}
}