All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.pulumi.gcp.alloydb.kotlin.Instance.kt Maven / Gradle / Ivy

Go to download

Build cloud applications and infrastructure by combining the safety and reliability of infrastructure as code with the power of the Kotlin programming language.

There is a newer version: 8.13.1.0
Show newest version
@file:Suppress("NAME_SHADOWING", "DEPRECATION")

package com.pulumi.gcp.alloydb.kotlin

import com.pulumi.core.Output
import com.pulumi.gcp.alloydb.kotlin.outputs.InstanceClientConnectionConfig
import com.pulumi.gcp.alloydb.kotlin.outputs.InstanceMachineConfig
import com.pulumi.gcp.alloydb.kotlin.outputs.InstanceNetworkConfig
import com.pulumi.gcp.alloydb.kotlin.outputs.InstanceObservabilityConfig
import com.pulumi.gcp.alloydb.kotlin.outputs.InstancePscInstanceConfig
import com.pulumi.gcp.alloydb.kotlin.outputs.InstanceQueryInsightsConfig
import com.pulumi.gcp.alloydb.kotlin.outputs.InstanceReadPoolConfig
import com.pulumi.kotlin.KotlinCustomResource
import com.pulumi.kotlin.PulumiTagMarker
import com.pulumi.kotlin.ResourceMapper
import com.pulumi.kotlin.options.CustomResourceOptions
import com.pulumi.kotlin.options.CustomResourceOptionsBuilder
import com.pulumi.resources.Resource
import kotlin.Boolean
import kotlin.String
import kotlin.Suppress
import kotlin.Unit
import kotlin.collections.Map
import com.pulumi.gcp.alloydb.kotlin.outputs.InstanceClientConnectionConfig.Companion.toKotlin as instanceClientConnectionConfigToKotlin
import com.pulumi.gcp.alloydb.kotlin.outputs.InstanceMachineConfig.Companion.toKotlin as instanceMachineConfigToKotlin
import com.pulumi.gcp.alloydb.kotlin.outputs.InstanceNetworkConfig.Companion.toKotlin as instanceNetworkConfigToKotlin
import com.pulumi.gcp.alloydb.kotlin.outputs.InstanceObservabilityConfig.Companion.toKotlin as instanceObservabilityConfigToKotlin
import com.pulumi.gcp.alloydb.kotlin.outputs.InstancePscInstanceConfig.Companion.toKotlin as instancePscInstanceConfigToKotlin
import com.pulumi.gcp.alloydb.kotlin.outputs.InstanceQueryInsightsConfig.Companion.toKotlin as instanceQueryInsightsConfigToKotlin
import com.pulumi.gcp.alloydb.kotlin.outputs.InstanceReadPoolConfig.Companion.toKotlin as instanceReadPoolConfigToKotlin

/**
 * Builder for [Instance].
 */
@PulumiTagMarker
public class InstanceResourceBuilder internal constructor() {
    public var name: String? = null

    public var args: InstanceArgs = InstanceArgs()

    public var opts: CustomResourceOptions = CustomResourceOptions()

    /**
     * @param name The _unique_ name of the resulting resource.
     */
    public fun name(`value`: String) {
        this.name = value
    }

    /**
     * @param block The arguments to use to populate this resource's properties.
     */
    public suspend fun args(block: suspend InstanceArgsBuilder.() -> Unit) {
        val builder = InstanceArgsBuilder()
        block(builder)
        this.args = builder.build()
    }

    /**
     * @param block A bag of options that control this resource's behavior.
     */
    public suspend fun opts(block: suspend CustomResourceOptionsBuilder.() -> Unit) {
        this.opts = com.pulumi.kotlin.options.CustomResourceOptions.opts(block)
    }

    internal fun build(): Instance {
        val builtJavaResource = com.pulumi.gcp.alloydb.Instance(
            this.name,
            this.args.toJava(),
            this.opts.toJava(),
        )
        return Instance(builtJavaResource)
    }
}

/**
 * ## Example Usage
 * ### Alloydb Instance Basic
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 * const defaultNetwork = new gcp.compute.Network("default", {name: "alloydb-network"});
 * const defaultCluster = new gcp.alloydb.Cluster("default", {
 *     clusterId: "alloydb-cluster",
 *     location: "us-central1",
 *     networkConfig: {
 *         network: defaultNetwork.id,
 *     },
 *     initialUser: {
 *         password: "alloydb-cluster",
 *     },
 * });
 * const privateIpAlloc = new gcp.compute.GlobalAddress("private_ip_alloc", {
 *     name: "alloydb-cluster",
 *     addressType: "INTERNAL",
 *     purpose: "VPC_PEERING",
 *     prefixLength: 16,
 *     network: defaultNetwork.id,
 * });
 * const vpcConnection = new gcp.servicenetworking.Connection("vpc_connection", {
 *     network: defaultNetwork.id,
 *     service: "servicenetworking.googleapis.com",
 *     reservedPeeringRanges: [privateIpAlloc.name],
 * });
 * const _default = new gcp.alloydb.Instance("default", {
 *     cluster: defaultCluster.name,
 *     instanceId: "alloydb-instance",
 *     instanceType: "PRIMARY",
 *     machineConfig: {
 *         cpuCount: 2,
 *     },
 * }, {
 *     dependsOn: [vpcConnection],
 * });
 * const project = gcp.organizations.getProject({});
 * ```
 * ```python
 * import pulumi
 * import pulumi_gcp as gcp
 * default_network = gcp.compute.Network("default", name="alloydb-network")
 * default_cluster = gcp.alloydb.Cluster("default",
 *     cluster_id="alloydb-cluster",
 *     location="us-central1",
 *     network_config={
 *         "network": default_network.id,
 *     },
 *     initial_user={
 *         "password": "alloydb-cluster",
 *     })
 * private_ip_alloc = gcp.compute.GlobalAddress("private_ip_alloc",
 *     name="alloydb-cluster",
 *     address_type="INTERNAL",
 *     purpose="VPC_PEERING",
 *     prefix_length=16,
 *     network=default_network.id)
 * vpc_connection = gcp.servicenetworking.Connection("vpc_connection",
 *     network=default_network.id,
 *     service="servicenetworking.googleapis.com",
 *     reserved_peering_ranges=[private_ip_alloc.name])
 * default = gcp.alloydb.Instance("default",
 *     cluster=default_cluster.name,
 *     instance_id="alloydb-instance",
 *     instance_type="PRIMARY",
 *     machine_config={
 *         "cpu_count": 2,
 *     },
 *     opts = pulumi.ResourceOptions(depends_on=[vpc_connection]))
 * project = gcp.organizations.get_project()
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Gcp = Pulumi.Gcp;
 * return await Deployment.RunAsync(() =>
 * {
 *     var defaultNetwork = new Gcp.Compute.Network("default", new()
 *     {
 *         Name = "alloydb-network",
 *     });
 *     var defaultCluster = new Gcp.Alloydb.Cluster("default", new()
 *     {
 *         ClusterId = "alloydb-cluster",
 *         Location = "us-central1",
 *         NetworkConfig = new Gcp.Alloydb.Inputs.ClusterNetworkConfigArgs
 *         {
 *             Network = defaultNetwork.Id,
 *         },
 *         InitialUser = new Gcp.Alloydb.Inputs.ClusterInitialUserArgs
 *         {
 *             Password = "alloydb-cluster",
 *         },
 *     });
 *     var privateIpAlloc = new Gcp.Compute.GlobalAddress("private_ip_alloc", new()
 *     {
 *         Name = "alloydb-cluster",
 *         AddressType = "INTERNAL",
 *         Purpose = "VPC_PEERING",
 *         PrefixLength = 16,
 *         Network = defaultNetwork.Id,
 *     });
 *     var vpcConnection = new Gcp.ServiceNetworking.Connection("vpc_connection", new()
 *     {
 *         Network = defaultNetwork.Id,
 *         Service = "servicenetworking.googleapis.com",
 *         ReservedPeeringRanges = new[]
 *         {
 *             privateIpAlloc.Name,
 *         },
 *     });
 *     var @default = new Gcp.Alloydb.Instance("default", new()
 *     {
 *         Cluster = defaultCluster.Name,
 *         InstanceId = "alloydb-instance",
 *         InstanceType = "PRIMARY",
 *         MachineConfig = new Gcp.Alloydb.Inputs.InstanceMachineConfigArgs
 *         {
 *             CpuCount = 2,
 *         },
 *     }, new CustomResourceOptions
 *     {
 *         DependsOn =
 *         {
 *             vpcConnection,
 *         },
 *     });
 *     var project = Gcp.Organizations.GetProject.Invoke();
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/alloydb"
 * 	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/compute"
 * 	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/organizations"
 * 	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/servicenetworking"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		defaultNetwork, err := compute.NewNetwork(ctx, "default", &compute.NetworkArgs{
 * 			Name: pulumi.String("alloydb-network"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		defaultCluster, err := alloydb.NewCluster(ctx, "default", &alloydb.ClusterArgs{
 * 			ClusterId: pulumi.String("alloydb-cluster"),
 * 			Location:  pulumi.String("us-central1"),
 * 			NetworkConfig: &alloydb.ClusterNetworkConfigArgs{
 * 				Network: defaultNetwork.ID(),
 * 			},
 * 			InitialUser: &alloydb.ClusterInitialUserArgs{
 * 				Password: pulumi.String("alloydb-cluster"),
 * 			},
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		privateIpAlloc, err := compute.NewGlobalAddress(ctx, "private_ip_alloc", &compute.GlobalAddressArgs{
 * 			Name:         pulumi.String("alloydb-cluster"),
 * 			AddressType:  pulumi.String("INTERNAL"),
 * 			Purpose:      pulumi.String("VPC_PEERING"),
 * 			PrefixLength: pulumi.Int(16),
 * 			Network:      defaultNetwork.ID(),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		vpcConnection, err := servicenetworking.NewConnection(ctx, "vpc_connection", &servicenetworking.ConnectionArgs{
 * 			Network: defaultNetwork.ID(),
 * 			Service: pulumi.String("servicenetworking.googleapis.com"),
 * 			ReservedPeeringRanges: pulumi.StringArray{
 * 				privateIpAlloc.Name,
 * 			},
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = alloydb.NewInstance(ctx, "default", &alloydb.InstanceArgs{
 * 			Cluster:      defaultCluster.Name,
 * 			InstanceId:   pulumi.String("alloydb-instance"),
 * 			InstanceType: pulumi.String("PRIMARY"),
 * 			MachineConfig: &alloydb.InstanceMachineConfigArgs{
 * 				CpuCount: pulumi.Int(2),
 * 			},
 * 		}, pulumi.DependsOn([]pulumi.Resource{
 * 			vpcConnection,
 * 		}))
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = organizations.LookupProject(ctx, nil, nil)
 * 		if err != nil {
 * 			return err
 * 		}
 * 		return nil
 * 	})
 * }
 * ```
 * ```java
 * package generated_program;
 * import com.pulumi.Context;
 * import com.pulumi.Pulumi;
 * import com.pulumi.core.Output;
 * import com.pulumi.gcp.compute.Network;
 * import com.pulumi.gcp.compute.NetworkArgs;
 * import com.pulumi.gcp.alloydb.Cluster;
 * import com.pulumi.gcp.alloydb.ClusterArgs;
 * import com.pulumi.gcp.alloydb.inputs.ClusterNetworkConfigArgs;
 * import com.pulumi.gcp.alloydb.inputs.ClusterInitialUserArgs;
 * import com.pulumi.gcp.compute.GlobalAddress;
 * import com.pulumi.gcp.compute.GlobalAddressArgs;
 * import com.pulumi.gcp.servicenetworking.Connection;
 * import com.pulumi.gcp.servicenetworking.ConnectionArgs;
 * import com.pulumi.gcp.alloydb.Instance;
 * import com.pulumi.gcp.alloydb.InstanceArgs;
 * import com.pulumi.gcp.alloydb.inputs.InstanceMachineConfigArgs;
 * import com.pulumi.gcp.organizations.OrganizationsFunctions;
 * import com.pulumi.gcp.organizations.inputs.GetProjectArgs;
 * 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 {
 *     public static void main(String[] args) {
 *         Pulumi.run(App::stack);
 *     }
 *     public static void stack(Context ctx) {
 *         var defaultNetwork = new Network("defaultNetwork", NetworkArgs.builder()
 *             .name("alloydb-network")
 *             .build());
 *         var defaultCluster = new Cluster("defaultCluster", ClusterArgs.builder()
 *             .clusterId("alloydb-cluster")
 *             .location("us-central1")
 *             .networkConfig(ClusterNetworkConfigArgs.builder()
 *                 .network(defaultNetwork.id())
 *                 .build())
 *             .initialUser(ClusterInitialUserArgs.builder()
 *                 .password("alloydb-cluster")
 *                 .build())
 *             .build());
 *         var privateIpAlloc = new GlobalAddress("privateIpAlloc", GlobalAddressArgs.builder()
 *             .name("alloydb-cluster")
 *             .addressType("INTERNAL")
 *             .purpose("VPC_PEERING")
 *             .prefixLength(16)
 *             .network(defaultNetwork.id())
 *             .build());
 *         var vpcConnection = new Connection("vpcConnection", ConnectionArgs.builder()
 *             .network(defaultNetwork.id())
 *             .service("servicenetworking.googleapis.com")
 *             .reservedPeeringRanges(privateIpAlloc.name())
 *             .build());
 *         var default_ = new Instance("default", InstanceArgs.builder()
 *             .cluster(defaultCluster.name())
 *             .instanceId("alloydb-instance")
 *             .instanceType("PRIMARY")
 *             .machineConfig(InstanceMachineConfigArgs.builder()
 *                 .cpuCount(2)
 *                 .build())
 *             .build(), CustomResourceOptions.builder()
 *                 .dependsOn(vpcConnection)
 *                 .build());
 *         final var project = OrganizationsFunctions.getProject();
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   default:
 *     type: gcp:alloydb:Instance
 *     properties:
 *       cluster: ${defaultCluster.name}
 *       instanceId: alloydb-instance
 *       instanceType: PRIMARY
 *       machineConfig:
 *         cpuCount: 2
 *     options:
 *       dependson:
 *         - ${vpcConnection}
 *   defaultCluster:
 *     type: gcp:alloydb:Cluster
 *     name: default
 *     properties:
 *       clusterId: alloydb-cluster
 *       location: us-central1
 *       networkConfig:
 *         network: ${defaultNetwork.id}
 *       initialUser:
 *         password: alloydb-cluster
 *   defaultNetwork:
 *     type: gcp:compute:Network
 *     name: default
 *     properties:
 *       name: alloydb-network
 *   privateIpAlloc:
 *     type: gcp:compute:GlobalAddress
 *     name: private_ip_alloc
 *     properties:
 *       name: alloydb-cluster
 *       addressType: INTERNAL
 *       purpose: VPC_PEERING
 *       prefixLength: 16
 *       network: ${defaultNetwork.id}
 *   vpcConnection:
 *     type: gcp:servicenetworking:Connection
 *     name: vpc_connection
 *     properties:
 *       network: ${defaultNetwork.id}
 *       service: servicenetworking.googleapis.com
 *       reservedPeeringRanges:
 *         - ${privateIpAlloc.name}
 * variables:
 *   project:
 *     fn::invoke:
 *       Function: gcp:organizations:getProject
 *       Arguments: {}
 * ```
 * 
 * ### Alloydb Secondary Instance Basic
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 * const _default = new gcp.compute.Network("default", {name: "alloydb-secondary-network"});
 * const primary = new gcp.alloydb.Cluster("primary", {
 *     clusterId: "alloydb-primary-cluster",
 *     location: "us-central1",
 *     network: _default.id,
 * });
 * const privateIpAlloc = new gcp.compute.GlobalAddress("private_ip_alloc", {
 *     name: "alloydb-secondary-instance",
 *     addressType: "INTERNAL",
 *     purpose: "VPC_PEERING",
 *     prefixLength: 16,
 *     network: _default.id,
 * });
 * const vpcConnection = new gcp.servicenetworking.Connection("vpc_connection", {
 *     network: _default.id,
 *     service: "servicenetworking.googleapis.com",
 *     reservedPeeringRanges: [privateIpAlloc.name],
 * });
 * const primaryInstance = new gcp.alloydb.Instance("primary", {
 *     cluster: primary.name,
 *     instanceId: "alloydb-primary-instance",
 *     instanceType: "PRIMARY",
 *     machineConfig: {
 *         cpuCount: 2,
 *     },
 * }, {
 *     dependsOn: [vpcConnection],
 * });
 * const secondary = new gcp.alloydb.Cluster("secondary", {
 *     clusterId: "alloydb-secondary-cluster",
 *     location: "us-east1",
 *     network: _default.id,
 *     clusterType: "SECONDARY",
 *     continuousBackupConfig: {
 *         enabled: false,
 *     },
 *     secondaryConfig: {
 *         primaryClusterName: primary.name,
 *     },
 *     deletionPolicy: "FORCE",
 * }, {
 *     dependsOn: [primaryInstance],
 * });
 * const secondaryInstance = new gcp.alloydb.Instance("secondary", {
 *     cluster: secondary.name,
 *     instanceId: "alloydb-secondary-instance",
 *     instanceType: secondary.clusterType,
 *     machineConfig: {
 *         cpuCount: 2,
 *     },
 * }, {
 *     dependsOn: [vpcConnection],
 * });
 * const project = gcp.organizations.getProject({});
 * ```
 * ```python
 * import pulumi
 * import pulumi_gcp as gcp
 * default = gcp.compute.Network("default", name="alloydb-secondary-network")
 * primary = gcp.alloydb.Cluster("primary",
 *     cluster_id="alloydb-primary-cluster",
 *     location="us-central1",
 *     network=default.id)
 * private_ip_alloc = gcp.compute.GlobalAddress("private_ip_alloc",
 *     name="alloydb-secondary-instance",
 *     address_type="INTERNAL",
 *     purpose="VPC_PEERING",
 *     prefix_length=16,
 *     network=default.id)
 * vpc_connection = gcp.servicenetworking.Connection("vpc_connection",
 *     network=default.id,
 *     service="servicenetworking.googleapis.com",
 *     reserved_peering_ranges=[private_ip_alloc.name])
 * primary_instance = gcp.alloydb.Instance("primary",
 *     cluster=primary.name,
 *     instance_id="alloydb-primary-instance",
 *     instance_type="PRIMARY",
 *     machine_config={
 *         "cpu_count": 2,
 *     },
 *     opts = pulumi.ResourceOptions(depends_on=[vpc_connection]))
 * secondary = gcp.alloydb.Cluster("secondary",
 *     cluster_id="alloydb-secondary-cluster",
 *     location="us-east1",
 *     network=default.id,
 *     cluster_type="SECONDARY",
 *     continuous_backup_config={
 *         "enabled": False,
 *     },
 *     secondary_config={
 *         "primary_cluster_name": primary.name,
 *     },
 *     deletion_policy="FORCE",
 *     opts = pulumi.ResourceOptions(depends_on=[primary_instance]))
 * secondary_instance = gcp.alloydb.Instance("secondary",
 *     cluster=secondary.name,
 *     instance_id="alloydb-secondary-instance",
 *     instance_type=secondary.cluster_type,
 *     machine_config={
 *         "cpu_count": 2,
 *     },
 *     opts = pulumi.ResourceOptions(depends_on=[vpc_connection]))
 * project = gcp.organizations.get_project()
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Gcp = Pulumi.Gcp;
 * return await Deployment.RunAsync(() =>
 * {
 *     var @default = new Gcp.Compute.Network("default", new()
 *     {
 *         Name = "alloydb-secondary-network",
 *     });
 *     var primary = new Gcp.Alloydb.Cluster("primary", new()
 *     {
 *         ClusterId = "alloydb-primary-cluster",
 *         Location = "us-central1",
 *         Network = @default.Id,
 *     });
 *     var privateIpAlloc = new Gcp.Compute.GlobalAddress("private_ip_alloc", new()
 *     {
 *         Name = "alloydb-secondary-instance",
 *         AddressType = "INTERNAL",
 *         Purpose = "VPC_PEERING",
 *         PrefixLength = 16,
 *         Network = @default.Id,
 *     });
 *     var vpcConnection = new Gcp.ServiceNetworking.Connection("vpc_connection", new()
 *     {
 *         Network = @default.Id,
 *         Service = "servicenetworking.googleapis.com",
 *         ReservedPeeringRanges = new[]
 *         {
 *             privateIpAlloc.Name,
 *         },
 *     });
 *     var primaryInstance = new Gcp.Alloydb.Instance("primary", new()
 *     {
 *         Cluster = primary.Name,
 *         InstanceId = "alloydb-primary-instance",
 *         InstanceType = "PRIMARY",
 *         MachineConfig = new Gcp.Alloydb.Inputs.InstanceMachineConfigArgs
 *         {
 *             CpuCount = 2,
 *         },
 *     }, new CustomResourceOptions
 *     {
 *         DependsOn =
 *         {
 *             vpcConnection,
 *         },
 *     });
 *     var secondary = new Gcp.Alloydb.Cluster("secondary", new()
 *     {
 *         ClusterId = "alloydb-secondary-cluster",
 *         Location = "us-east1",
 *         Network = @default.Id,
 *         ClusterType = "SECONDARY",
 *         ContinuousBackupConfig = new Gcp.Alloydb.Inputs.ClusterContinuousBackupConfigArgs
 *         {
 *             Enabled = false,
 *         },
 *         SecondaryConfig = new Gcp.Alloydb.Inputs.ClusterSecondaryConfigArgs
 *         {
 *             PrimaryClusterName = primary.Name,
 *         },
 *         DeletionPolicy = "FORCE",
 *     }, new CustomResourceOptions
 *     {
 *         DependsOn =
 *         {
 *             primaryInstance,
 *         },
 *     });
 *     var secondaryInstance = new Gcp.Alloydb.Instance("secondary", new()
 *     {
 *         Cluster = secondary.Name,
 *         InstanceId = "alloydb-secondary-instance",
 *         InstanceType = secondary.ClusterType,
 *         MachineConfig = new Gcp.Alloydb.Inputs.InstanceMachineConfigArgs
 *         {
 *             CpuCount = 2,
 *         },
 *     }, new CustomResourceOptions
 *     {
 *         DependsOn =
 *         {
 *             vpcConnection,
 *         },
 *     });
 *     var project = Gcp.Organizations.GetProject.Invoke();
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/alloydb"
 * 	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/compute"
 * 	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/organizations"
 * 	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/servicenetworking"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		_, err := compute.NewNetwork(ctx, "default", &compute.NetworkArgs{
 * 			Name: pulumi.String("alloydb-secondary-network"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		primary, err := alloydb.NewCluster(ctx, "primary", &alloydb.ClusterArgs{
 * 			ClusterId: pulumi.String("alloydb-primary-cluster"),
 * 			Location:  pulumi.String("us-central1"),
 * 			Network:   _default.ID(),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		privateIpAlloc, err := compute.NewGlobalAddress(ctx, "private_ip_alloc", &compute.GlobalAddressArgs{
 * 			Name:         pulumi.String("alloydb-secondary-instance"),
 * 			AddressType:  pulumi.String("INTERNAL"),
 * 			Purpose:      pulumi.String("VPC_PEERING"),
 * 			PrefixLength: pulumi.Int(16),
 * 			Network:      _default.ID(),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		vpcConnection, err := servicenetworking.NewConnection(ctx, "vpc_connection", &servicenetworking.ConnectionArgs{
 * 			Network: _default.ID(),
 * 			Service: pulumi.String("servicenetworking.googleapis.com"),
 * 			ReservedPeeringRanges: pulumi.StringArray{
 * 				privateIpAlloc.Name,
 * 			},
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		primaryInstance, err := alloydb.NewInstance(ctx, "primary", &alloydb.InstanceArgs{
 * 			Cluster:      primary.Name,
 * 			InstanceId:   pulumi.String("alloydb-primary-instance"),
 * 			InstanceType: pulumi.String("PRIMARY"),
 * 			MachineConfig: &alloydb.InstanceMachineConfigArgs{
 * 				CpuCount: pulumi.Int(2),
 * 			},
 * 		}, pulumi.DependsOn([]pulumi.Resource{
 * 			vpcConnection,
 * 		}))
 * 		if err != nil {
 * 			return err
 * 		}
 * 		secondary, err := alloydb.NewCluster(ctx, "secondary", &alloydb.ClusterArgs{
 * 			ClusterId:   pulumi.String("alloydb-secondary-cluster"),
 * 			Location:    pulumi.String("us-east1"),
 * 			Network:     _default.ID(),
 * 			ClusterType: pulumi.String("SECONDARY"),
 * 			ContinuousBackupConfig: &alloydb.ClusterContinuousBackupConfigArgs{
 * 				Enabled: pulumi.Bool(false),
 * 			},
 * 			SecondaryConfig: &alloydb.ClusterSecondaryConfigArgs{
 * 				PrimaryClusterName: primary.Name,
 * 			},
 * 			DeletionPolicy: pulumi.String("FORCE"),
 * 		}, pulumi.DependsOn([]pulumi.Resource{
 * 			primaryInstance,
 * 		}))
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = alloydb.NewInstance(ctx, "secondary", &alloydb.InstanceArgs{
 * 			Cluster:      secondary.Name,
 * 			InstanceId:   pulumi.String("alloydb-secondary-instance"),
 * 			InstanceType: secondary.ClusterType,
 * 			MachineConfig: &alloydb.InstanceMachineConfigArgs{
 * 				CpuCount: pulumi.Int(2),
 * 			},
 * 		}, pulumi.DependsOn([]pulumi.Resource{
 * 			vpcConnection,
 * 		}))
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = organizations.LookupProject(ctx, nil, nil)
 * 		if err != nil {
 * 			return err
 * 		}
 * 		return nil
 * 	})
 * }
 * ```
 * ```java
 * package generated_program;
 * import com.pulumi.Context;
 * import com.pulumi.Pulumi;
 * import com.pulumi.core.Output;
 * import com.pulumi.gcp.compute.Network;
 * import com.pulumi.gcp.compute.NetworkArgs;
 * import com.pulumi.gcp.alloydb.Cluster;
 * import com.pulumi.gcp.alloydb.ClusterArgs;
 * import com.pulumi.gcp.compute.GlobalAddress;
 * import com.pulumi.gcp.compute.GlobalAddressArgs;
 * import com.pulumi.gcp.servicenetworking.Connection;
 * import com.pulumi.gcp.servicenetworking.ConnectionArgs;
 * import com.pulumi.gcp.alloydb.Instance;
 * import com.pulumi.gcp.alloydb.InstanceArgs;
 * import com.pulumi.gcp.alloydb.inputs.InstanceMachineConfigArgs;
 * import com.pulumi.gcp.alloydb.inputs.ClusterContinuousBackupConfigArgs;
 * import com.pulumi.gcp.alloydb.inputs.ClusterSecondaryConfigArgs;
 * import com.pulumi.gcp.organizations.OrganizationsFunctions;
 * import com.pulumi.gcp.organizations.inputs.GetProjectArgs;
 * 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 {
 *     public static void main(String[] args) {
 *         Pulumi.run(App::stack);
 *     }
 *     public static void stack(Context ctx) {
 *         var default_ = new Network("default", NetworkArgs.builder()
 *             .name("alloydb-secondary-network")
 *             .build());
 *         var primary = new Cluster("primary", ClusterArgs.builder()
 *             .clusterId("alloydb-primary-cluster")
 *             .location("us-central1")
 *             .network(default_.id())
 *             .build());
 *         var privateIpAlloc = new GlobalAddress("privateIpAlloc", GlobalAddressArgs.builder()
 *             .name("alloydb-secondary-instance")
 *             .addressType("INTERNAL")
 *             .purpose("VPC_PEERING")
 *             .prefixLength(16)
 *             .network(default_.id())
 *             .build());
 *         var vpcConnection = new Connection("vpcConnection", ConnectionArgs.builder()
 *             .network(default_.id())
 *             .service("servicenetworking.googleapis.com")
 *             .reservedPeeringRanges(privateIpAlloc.name())
 *             .build());
 *         var primaryInstance = new Instance("primaryInstance", InstanceArgs.builder()
 *             .cluster(primary.name())
 *             .instanceId("alloydb-primary-instance")
 *             .instanceType("PRIMARY")
 *             .machineConfig(InstanceMachineConfigArgs.builder()
 *                 .cpuCount(2)
 *                 .build())
 *             .build(), CustomResourceOptions.builder()
 *                 .dependsOn(vpcConnection)
 *                 .build());
 *         var secondary = new Cluster("secondary", ClusterArgs.builder()
 *             .clusterId("alloydb-secondary-cluster")
 *             .location("us-east1")
 *             .network(default_.id())
 *             .clusterType("SECONDARY")
 *             .continuousBackupConfig(ClusterContinuousBackupConfigArgs.builder()
 *                 .enabled(false)
 *                 .build())
 *             .secondaryConfig(ClusterSecondaryConfigArgs.builder()
 *                 .primaryClusterName(primary.name())
 *                 .build())
 *             .deletionPolicy("FORCE")
 *             .build(), CustomResourceOptions.builder()
 *                 .dependsOn(primaryInstance)
 *                 .build());
 *         var secondaryInstance = new Instance("secondaryInstance", InstanceArgs.builder()
 *             .cluster(secondary.name())
 *             .instanceId("alloydb-secondary-instance")
 *             .instanceType(secondary.clusterType())
 *             .machineConfig(InstanceMachineConfigArgs.builder()
 *                 .cpuCount(2)
 *                 .build())
 *             .build(), CustomResourceOptions.builder()
 *                 .dependsOn(vpcConnection)
 *                 .build());
 *         final var project = OrganizationsFunctions.getProject();
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   primary:
 *     type: gcp:alloydb:Cluster
 *     properties:
 *       clusterId: alloydb-primary-cluster
 *       location: us-central1
 *       network: ${default.id}
 *   primaryInstance:
 *     type: gcp:alloydb:Instance
 *     name: primary
 *     properties:
 *       cluster: ${primary.name}
 *       instanceId: alloydb-primary-instance
 *       instanceType: PRIMARY
 *       machineConfig:
 *         cpuCount: 2
 *     options:
 *       dependson:
 *         - ${vpcConnection}
 *   secondary:
 *     type: gcp:alloydb:Cluster
 *     properties:
 *       clusterId: alloydb-secondary-cluster
 *       location: us-east1
 *       network: ${default.id}
 *       clusterType: SECONDARY
 *       continuousBackupConfig:
 *         enabled: false
 *       secondaryConfig:
 *         primaryClusterName: ${primary.name}
 *       deletionPolicy: FORCE
 *     options:
 *       dependson:
 *         - ${primaryInstance}
 *   secondaryInstance:
 *     type: gcp:alloydb:Instance
 *     name: secondary
 *     properties:
 *       cluster: ${secondary.name}
 *       instanceId: alloydb-secondary-instance
 *       instanceType: ${secondary.clusterType}
 *       machineConfig:
 *         cpuCount: 2
 *     options:
 *       dependson:
 *         - ${vpcConnection}
 *   default:
 *     type: gcp:compute:Network
 *     properties:
 *       name: alloydb-secondary-network
 *   privateIpAlloc:
 *     type: gcp:compute:GlobalAddress
 *     name: private_ip_alloc
 *     properties:
 *       name: alloydb-secondary-instance
 *       addressType: INTERNAL
 *       purpose: VPC_PEERING
 *       prefixLength: 16
 *       network: ${default.id}
 *   vpcConnection:
 *     type: gcp:servicenetworking:Connection
 *     name: vpc_connection
 *     properties:
 *       network: ${default.id}
 *       service: servicenetworking.googleapis.com
 *       reservedPeeringRanges:
 *         - ${privateIpAlloc.name}
 * variables:
 *   project:
 *     fn::invoke:
 *       Function: gcp:organizations:getProject
 *       Arguments: {}
 * ```
 * 
 * ## Import
 * Instance can be imported using any of these accepted formats:
 * * `projects/{{project}}/locations/{{location}}/clusters/{{cluster}}/instances/{{instance_id}}`
 * * `{{project}}/{{location}}/{{cluster}}/{{instance_id}}`
 * * `{{location}}/{{cluster}}/{{instance_id}}`
 * When using the `pulumi import` command, Instance can be imported using one of the formats above. For example:
 * ```sh
 * $ pulumi import gcp:alloydb/instance:Instance default projects/{{project}}/locations/{{location}}/clusters/{{cluster}}/instances/{{instance_id}}
 * ```
 * ```sh
 * $ pulumi import gcp:alloydb/instance:Instance default {{project}}/{{location}}/{{cluster}}/{{instance_id}}
 * ```
 * ```sh
 * $ pulumi import gcp:alloydb/instance:Instance default {{location}}/{{cluster}}/{{instance_id}}
 * ```
 */
public class Instance internal constructor(
    override val javaResource: com.pulumi.gcp.alloydb.Instance,
) : KotlinCustomResource(javaResource, InstanceMapper) {
    /**
     * Annotations to allow client tools to store small amount of arbitrary data. This is distinct from labels.
     * **Note**: This field is non-authoritative, and will only manage the annotations present in your configuration.
     * Please refer to the field `effective_annotations` for all of the annotations present on the resource.
     */
    public val annotations: Output>?
        get() = javaResource.annotations().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.map({ args0 ->
                    args0.key.to(args0.value)
                }).toMap()
            }).orElse(null)
        })

    /**
     * 'Availability type of an Instance. Defaults to REGIONAL for both primary and read instances.
     * Note that primary and read instances can have different availability types.
     * Only READ_POOL instance supports ZONAL type. Users can't specify the zone for READ_POOL instance.
     * Zone is automatically chosen from the list of zones in the region specified.
     * Read pool of size 1 can only have zonal availability. Read pools with node count of 2 or more
     * can have regional availability (nodes are present in 2 or more zones in a region).'
     * Possible values are: `AVAILABILITY_TYPE_UNSPECIFIED`, `ZONAL`, `REGIONAL`.
     */
    public val availabilityType: Output
        get() = javaResource.availabilityType().applyValue({ args0 -> args0 })

    /**
     * Client connection specific configurations.
     * Structure is documented below.
     */
    public val clientConnectionConfig: Output
        get() = javaResource.clientConnectionConfig().applyValue({ args0 ->
            args0.let({ args0 ->
                instanceClientConnectionConfigToKotlin(args0)
            })
        })

    /**
     * Identifies the alloydb cluster. Must be in the format
     * 'projects/{project}/locations/{location}/clusters/{cluster_id}'
     */
    public val cluster: Output
        get() = javaResource.cluster().applyValue({ args0 -> args0 })

    /**
     * Time the Instance was created in UTC.
     */
    public val createTime: Output
        get() = javaResource.createTime().applyValue({ args0 -> args0 })

    /**
     * Database flags. Set at instance level. * They are copied from primary instance on read instance creation. * Read instances can set new or override existing flags that are relevant for reads, e.g. for enabling columnar cache on a read instance. Flags set on read instance may or may not be present on primary.
     */
    public val databaseFlags: Output>
        get() = javaResource.databaseFlags().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.key.to(args0.value)
            }).toMap()
        })

    /**
     * User-settable and human-readable display name for the Instance.
     */
    public val displayName: Output?
        get() = javaResource.displayName().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    public val effectiveAnnotations: Output>
        get() = javaResource.effectiveAnnotations().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.key.to(args0.value)
            }).toMap()
        })

    /**
     * All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Pulumi, other clients and services.
     */
    public val effectiveLabels: Output>
        get() = javaResource.effectiveLabels().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.key.to(args0.value)
            }).toMap()
        })

    /**
     * The Compute Engine zone that the instance should serve from, per https://cloud.google.com/compute/docs/regions-zones This can ONLY be specified for ZONAL instances. If present for a REGIONAL instance, an error will be thrown. If this is absent for a ZONAL instance, instance is created in a random zone with available capacity.
     */
    public val gceZone: Output?
        get() = javaResource.gceZone().applyValue({ args0 -> args0.map({ args0 -> args0 }).orElse(null) })

    /**
     * The ID of the alloydb instance.
     * - - -
     */
    public val instanceId: Output
        get() = javaResource.instanceId().applyValue({ args0 -> args0 })

    public val instanceType: Output
        get() = javaResource.instanceType().applyValue({ args0 -> args0 })

    /**
     * The IP address for the Instance. This is the connection endpoint for an end-user application.
     */
    public val ipAddress: Output
        get() = javaResource.ipAddress().applyValue({ args0 -> args0 })

    /**
     * User-defined labels for the alloydb instance.
     * **Note**: This field is non-authoritative, and will only manage the labels present in your configuration.
     * Please refer to the field `effective_labels` for all of the labels present on the resource.
     */
    public val labels: Output>?
        get() = javaResource.labels().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.map({ args0 ->
                    args0.key.to(args0.value)
                }).toMap()
            }).orElse(null)
        })

    /**
     * Configurations for the machines that host the underlying database engine.
     * Structure is documented below.
     */
    public val machineConfig: Output
        get() = javaResource.machineConfig().applyValue({ args0 ->
            args0.let({ args0 ->
                instanceMachineConfigToKotlin(args0)
            })
        })

    /**
     * The name of the instance resource.
     */
    public val name: Output
        get() = javaResource.name().applyValue({ args0 -> args0 })

    /**
     * Instance level network configuration.
     * Structure is documented below.
     */
    public val networkConfig: Output?
        get() = javaResource.networkConfig().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.let({ args0 -> instanceNetworkConfigToKotlin(args0) })
            }).orElse(null)
        })

    /**
     * Configuration for enhanced query insights.
     * Structure is documented below.
     */
    public val observabilityConfig: Output
        get() = javaResource.observabilityConfig().applyValue({ args0 ->
            args0.let({ args0 ->
                instanceObservabilityConfigToKotlin(args0)
            })
        })

    /**
     * Configuration for Private Service Connect (PSC) for the instance.
     * Structure is documented below.
     */
    public val pscInstanceConfig: Output?
        get() = javaResource.pscInstanceConfig().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.let({ args0 -> instancePscInstanceConfigToKotlin(args0) })
            }).orElse(null)
        })

    /**
     * The public IP addresses for the Instance. This is available ONLY when
     * networkConfig.enablePublicIp is set to true. This is the connection
     * endpoint for an end-user application.
     */
    public val publicIpAddress: Output
        get() = javaResource.publicIpAddress().applyValue({ args0 -> args0 })

    /**
     * The combination of labels configured directly on the resource
     * and default labels configured on the provider.
     */
    public val pulumiLabels: Output>
        get() = javaResource.pulumiLabels().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.key.to(args0.value)
            }).toMap()
        })

    /**
     * Configuration for query insights.
     * Structure is documented below.
     */
    public val queryInsightsConfig: Output
        get() = javaResource.queryInsightsConfig().applyValue({ args0 ->
            args0.let({ args0 ->
                instanceQueryInsightsConfigToKotlin(args0)
            })
        })

    /**
     * Read pool specific config. If the instance type is READ_POOL, this configuration must be provided.
     * Structure is documented below.
     */
    public val readPoolConfig: Output?
        get() = javaResource.readPoolConfig().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.let({ args0 -> instanceReadPoolConfigToKotlin(args0) })
            }).orElse(null)
        })

    /**
     * Set to true if the current state of Instance does not match the user's intended state, and the service is actively updating the resource to reconcile them. This can happen due to user-triggered updates or system actions like failover or maintenance.
     */
    public val reconciling: Output
        get() = javaResource.reconciling().applyValue({ args0 -> args0 })

    /**
     * The current state of the alloydb instance.
     */
    public val state: Output
        get() = javaResource.state().applyValue({ args0 -> args0 })

    /**
     * The system-generated UID of the resource.
     */
    public val uid: Output
        get() = javaResource.uid().applyValue({ args0 -> args0 })

    /**
     * Time the Instance was updated in UTC.
     */
    public val updateTime: Output
        get() = javaResource.updateTime().applyValue({ args0 -> args0 })
}

public object InstanceMapper : ResourceMapper {
    override fun supportsMappingOfType(javaResource: Resource): Boolean =
        com.pulumi.gcp.alloydb.Instance::class == javaResource::class

    override fun map(javaResource: Resource): Instance = Instance(
        javaResource as
            com.pulumi.gcp.alloydb.Instance,
    )
}

/**
 * @see [Instance].
 * @param name The _unique_ name of the resulting resource.
 * @param block Builder for [Instance].
 */
public suspend fun instance(name: String, block: suspend InstanceResourceBuilder.() -> Unit): Instance {
    val builder = InstanceResourceBuilder()
    builder.name(name)
    block(builder)
    return builder.build()
}

/**
 * @see [Instance].
 * @param name The _unique_ name of the resulting resource.
 */
public fun instance(name: String): Instance {
    val builder = InstanceResourceBuilder()
    builder.name(name)
    return builder.build()
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy