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

com.pulumi.gcp.redis.kotlin.Cluster.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.12.0.0
Show newest version
@file:Suppress("NAME_SHADOWING", "DEPRECATION")

package com.pulumi.gcp.redis.kotlin

import com.pulumi.core.Output
import com.pulumi.gcp.redis.kotlin.outputs.ClusterDiscoveryEndpoint
import com.pulumi.gcp.redis.kotlin.outputs.ClusterPscConfig
import com.pulumi.gcp.redis.kotlin.outputs.ClusterPscConnection
import com.pulumi.gcp.redis.kotlin.outputs.ClusterStateInfo
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.Double
import kotlin.Int
import kotlin.String
import kotlin.Suppress
import kotlin.Unit
import kotlin.collections.List
import kotlin.collections.Map
import com.pulumi.gcp.redis.kotlin.outputs.ClusterDiscoveryEndpoint.Companion.toKotlin as clusterDiscoveryEndpointToKotlin
import com.pulumi.gcp.redis.kotlin.outputs.ClusterPscConfig.Companion.toKotlin as clusterPscConfigToKotlin
import com.pulumi.gcp.redis.kotlin.outputs.ClusterPscConnection.Companion.toKotlin as clusterPscConnectionToKotlin
import com.pulumi.gcp.redis.kotlin.outputs.ClusterStateInfo.Companion.toKotlin as clusterStateInfoToKotlin

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

    public var args: ClusterArgs = ClusterArgs()

    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 ClusterArgsBuilder.() -> Unit) {
        val builder = ClusterArgsBuilder()
        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(): Cluster {
        val builtJavaResource = com.pulumi.gcp.redis.Cluster(
            this.name,
            this.args.toJava(),
            this.opts.toJava(),
        )
        return Cluster(builtJavaResource)
    }
}

/**
 * A Google Cloud Redis Cluster instance.
 * To get more information about Cluster, see:
 * * [API documentation](https://cloud.google.com/memorystore/docs/cluster/reference/rest/v1/projects.locations.clusters)
 * * How-to Guides
 *     * [Official Documentation](https://cloud.google.com/memorystore/docs/cluster/)
 * ## Example Usage
 * ### Redis Cluster Ha
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 * const producerNet = new gcp.compute.Network("producer_net", {
 *     name: "mynetwork",
 *     autoCreateSubnetworks: false,
 * });
 * const cluster_ha = new gcp.redis.Cluster("cluster-ha", {
 *     name: "ha-cluster",
 *     shardCount: 3,
 *     pscConfigs: [{
 *         network: producerNet.id,
 *     }],
 *     region: "us-central1",
 *     replicaCount: 1,
 *     nodeType: "REDIS_SHARED_CORE_NANO",
 *     transitEncryptionMode: "TRANSIT_ENCRYPTION_MODE_DISABLED",
 *     authorizationMode: "AUTH_MODE_DISABLED",
 *     redisConfigs: {
 *         "maxmemory-policy": "volatile-ttl",
 *     },
 * });
 * const producerSubnet = new gcp.compute.Subnetwork("producer_subnet", {
 *     name: "mysubnet",
 *     ipCidrRange: "10.0.0.248/29",
 *     region: "us-central1",
 *     network: producerNet.id,
 * });
 * const _default = new gcp.networkconnectivity.ServiceConnectionPolicy("default", {
 *     name: "mypolicy",
 *     location: "us-central1",
 *     serviceClass: "gcp-memorystore-redis",
 *     description: "my basic service connection policy",
 *     network: producerNet.id,
 *     pscConfig: {
 *         subnetworks: [producerSubnet.id],
 *     },
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_gcp as gcp
 * producer_net = gcp.compute.Network("producer_net",
 *     name="mynetwork",
 *     auto_create_subnetworks=False)
 * cluster_ha = gcp.redis.Cluster("cluster-ha",
 *     name="ha-cluster",
 *     shard_count=3,
 *     psc_configs=[gcp.redis.ClusterPscConfigArgs(
 *         network=producer_net.id,
 *     )],
 *     region="us-central1",
 *     replica_count=1,
 *     node_type="REDIS_SHARED_CORE_NANO",
 *     transit_encryption_mode="TRANSIT_ENCRYPTION_MODE_DISABLED",
 *     authorization_mode="AUTH_MODE_DISABLED",
 *     redis_configs={
 *         "maxmemory-policy": "volatile-ttl",
 *     })
 * producer_subnet = gcp.compute.Subnetwork("producer_subnet",
 *     name="mysubnet",
 *     ip_cidr_range="10.0.0.248/29",
 *     region="us-central1",
 *     network=producer_net.id)
 * default = gcp.networkconnectivity.ServiceConnectionPolicy("default",
 *     name="mypolicy",
 *     location="us-central1",
 *     service_class="gcp-memorystore-redis",
 *     description="my basic service connection policy",
 *     network=producer_net.id,
 *     psc_config=gcp.networkconnectivity.ServiceConnectionPolicyPscConfigArgs(
 *         subnetworks=[producer_subnet.id],
 *     ))
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Gcp = Pulumi.Gcp;
 * return await Deployment.RunAsync(() =>
 * {
 *     var producerNet = new Gcp.Compute.Network("producer_net", new()
 *     {
 *         Name = "mynetwork",
 *         AutoCreateSubnetworks = false,
 *     });
 *     var cluster_ha = new Gcp.Redis.Cluster("cluster-ha", new()
 *     {
 *         Name = "ha-cluster",
 *         ShardCount = 3,
 *         PscConfigs = new[]
 *         {
 *             new Gcp.Redis.Inputs.ClusterPscConfigArgs
 *             {
 *                 Network = producerNet.Id,
 *             },
 *         },
 *         Region = "us-central1",
 *         ReplicaCount = 1,
 *         NodeType = "REDIS_SHARED_CORE_NANO",
 *         TransitEncryptionMode = "TRANSIT_ENCRYPTION_MODE_DISABLED",
 *         AuthorizationMode = "AUTH_MODE_DISABLED",
 *         RedisConfigs =
 *         {
 *             { "maxmemory-policy", "volatile-ttl" },
 *         },
 *     });
 *     var producerSubnet = new Gcp.Compute.Subnetwork("producer_subnet", new()
 *     {
 *         Name = "mysubnet",
 *         IpCidrRange = "10.0.0.248/29",
 *         Region = "us-central1",
 *         Network = producerNet.Id,
 *     });
 *     var @default = new Gcp.NetworkConnectivity.ServiceConnectionPolicy("default", new()
 *     {
 *         Name = "mypolicy",
 *         Location = "us-central1",
 *         ServiceClass = "gcp-memorystore-redis",
 *         Description = "my basic service connection policy",
 *         Network = producerNet.Id,
 *         PscConfig = new Gcp.NetworkConnectivity.Inputs.ServiceConnectionPolicyPscConfigArgs
 *         {
 *             Subnetworks = new[]
 *             {
 *                 producerSubnet.Id,
 *             },
 *         },
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/compute"
 * 	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/networkconnectivity"
 * 	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/redis"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		producerNet, err := compute.NewNetwork(ctx, "producer_net", &compute.NetworkArgs{
 * 			Name:                  pulumi.String("mynetwork"),
 * 			AutoCreateSubnetworks: pulumi.Bool(false),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = redis.NewCluster(ctx, "cluster-ha", &redis.ClusterArgs{
 * 			Name:       pulumi.String("ha-cluster"),
 * 			ShardCount: pulumi.Int(3),
 * 			PscConfigs: redis.ClusterPscConfigArray{
 * 				&redis.ClusterPscConfigArgs{
 * 					Network: producerNet.ID(),
 * 				},
 * 			},
 * 			Region:                pulumi.String("us-central1"),
 * 			ReplicaCount:          pulumi.Int(1),
 * 			NodeType:              pulumi.String("REDIS_SHARED_CORE_NANO"),
 * 			TransitEncryptionMode: pulumi.String("TRANSIT_ENCRYPTION_MODE_DISABLED"),
 * 			AuthorizationMode:     pulumi.String("AUTH_MODE_DISABLED"),
 * 			RedisConfigs: pulumi.StringMap{
 * 				"maxmemory-policy": pulumi.String("volatile-ttl"),
 * 			},
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		producerSubnet, err := compute.NewSubnetwork(ctx, "producer_subnet", &compute.SubnetworkArgs{
 * 			Name:        pulumi.String("mysubnet"),
 * 			IpCidrRange: pulumi.String("10.0.0.248/29"),
 * 			Region:      pulumi.String("us-central1"),
 * 			Network:     producerNet.ID(),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = networkconnectivity.NewServiceConnectionPolicy(ctx, "default", &networkconnectivity.ServiceConnectionPolicyArgs{
 * 			Name:         pulumi.String("mypolicy"),
 * 			Location:     pulumi.String("us-central1"),
 * 			ServiceClass: pulumi.String("gcp-memorystore-redis"),
 * 			Description:  pulumi.String("my basic service connection policy"),
 * 			Network:      producerNet.ID(),
 * 			PscConfig: &networkconnectivity.ServiceConnectionPolicyPscConfigArgs{
 * 				Subnetworks: pulumi.StringArray{
 * 					producerSubnet.ID(),
 * 				},
 * 			},
 * 		})
 * 		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.redis.Cluster;
 * import com.pulumi.gcp.redis.ClusterArgs;
 * import com.pulumi.gcp.redis.inputs.ClusterPscConfigArgs;
 * import com.pulumi.gcp.compute.Subnetwork;
 * import com.pulumi.gcp.compute.SubnetworkArgs;
 * import com.pulumi.gcp.networkconnectivity.ServiceConnectionPolicy;
 * import com.pulumi.gcp.networkconnectivity.ServiceConnectionPolicyArgs;
 * import com.pulumi.gcp.networkconnectivity.inputs.ServiceConnectionPolicyPscConfigArgs;
 * 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 producerNet = new Network("producerNet", NetworkArgs.builder()
 *             .name("mynetwork")
 *             .autoCreateSubnetworks(false)
 *             .build());
 *         var cluster_ha = new Cluster("cluster-ha", ClusterArgs.builder()
 *             .name("ha-cluster")
 *             .shardCount(3)
 *             .pscConfigs(ClusterPscConfigArgs.builder()
 *                 .network(producerNet.id())
 *                 .build())
 *             .region("us-central1")
 *             .replicaCount(1)
 *             .nodeType("REDIS_SHARED_CORE_NANO")
 *             .transitEncryptionMode("TRANSIT_ENCRYPTION_MODE_DISABLED")
 *             .authorizationMode("AUTH_MODE_DISABLED")
 *             .redisConfigs(Map.of("maxmemory-policy", "volatile-ttl"))
 *             .build());
 *         var producerSubnet = new Subnetwork("producerSubnet", SubnetworkArgs.builder()
 *             .name("mysubnet")
 *             .ipCidrRange("10.0.0.248/29")
 *             .region("us-central1")
 *             .network(producerNet.id())
 *             .build());
 *         var default_ = new ServiceConnectionPolicy("default", ServiceConnectionPolicyArgs.builder()
 *             .name("mypolicy")
 *             .location("us-central1")
 *             .serviceClass("gcp-memorystore-redis")
 *             .description("my basic service connection policy")
 *             .network(producerNet.id())
 *             .pscConfig(ServiceConnectionPolicyPscConfigArgs.builder()
 *                 .subnetworks(producerSubnet.id())
 *                 .build())
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   cluster-ha:
 *     type: gcp:redis:Cluster
 *     properties:
 *       name: ha-cluster
 *       shardCount: 3
 *       pscConfigs:
 *         - network: ${producerNet.id}
 *       region: us-central1
 *       replicaCount: 1
 *       nodeType: REDIS_SHARED_CORE_NANO
 *       transitEncryptionMode: TRANSIT_ENCRYPTION_MODE_DISABLED
 *       authorizationMode: AUTH_MODE_DISABLED
 *       redisConfigs:
 *         maxmemory-policy: volatile-ttl
 *   default:
 *     type: gcp:networkconnectivity:ServiceConnectionPolicy
 *     properties:
 *       name: mypolicy
 *       location: us-central1
 *       serviceClass: gcp-memorystore-redis
 *       description: my basic service connection policy
 *       network: ${producerNet.id}
 *       pscConfig:
 *         subnetworks:
 *           - ${producerSubnet.id}
 *   producerSubnet:
 *     type: gcp:compute:Subnetwork
 *     name: producer_subnet
 *     properties:
 *       name: mysubnet
 *       ipCidrRange: 10.0.0.248/29
 *       region: us-central1
 *       network: ${producerNet.id}
 *   producerNet:
 *     type: gcp:compute:Network
 *     name: producer_net
 *     properties:
 *       name: mynetwork
 *       autoCreateSubnetworks: false
 * ```
 * 
 * ## Import
 * Cluster can be imported using any of these accepted formats:
 * * `projects/{{project}}/locations/{{region}}/clusters/{{name}}`
 * * `{{project}}/{{region}}/{{name}}`
 * * `{{region}}/{{name}}`
 * * `{{name}}`
 * When using the `pulumi import` command, Cluster can be imported using one of the formats above. For example:
 * ```sh
 * $ pulumi import gcp:redis/cluster:Cluster default projects/{{project}}/locations/{{region}}/clusters/{{name}}
 * ```
 * ```sh
 * $ pulumi import gcp:redis/cluster:Cluster default {{project}}/{{region}}/{{name}}
 * ```
 * ```sh
 * $ pulumi import gcp:redis/cluster:Cluster default {{region}}/{{name}}
 * ```
 * ```sh
 * $ pulumi import gcp:redis/cluster:Cluster default {{name}}
 * ```
 */
public class Cluster internal constructor(
    override val javaResource: com.pulumi.gcp.redis.Cluster,
) : KotlinCustomResource(javaResource, ClusterMapper) {
    /**
     * Optional. The authorization mode of the Redis cluster. If not provided, auth feature is disabled for the cluster.
     * Default value: "AUTH_MODE_DISABLED" Possible values: ["AUTH_MODE_UNSPECIFIED", "AUTH_MODE_IAM_AUTH",
     * "AUTH_MODE_DISABLED"]
     */
    public val authorizationMode: Output?
        get() = javaResource.authorizationMode().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * The timestamp associated with the cluster creation request. A timestamp in
     * RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional
     * digits. Examples: "2014-10-02T15:01:23Z" and "2014-10-02T15:01:23.045123456Z".
     */
    public val createTime: Output
        get() = javaResource.createTime().applyValue({ args0 -> args0 })

    /**
     * Output only. Endpoints created on each given network,
     * for Redis clients to connect to the cluster.
     * Currently only one endpoint is supported.
     * Structure is documented below.
     */
    public val discoveryEndpoints: Output>
        get() = javaResource.discoveryEndpoints().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.let({ args0 -> clusterDiscoveryEndpointToKotlin(args0) })
            })
        })

    /**
     * Unique name of the resource in this scope including project and location using the form:
     * projects/{projectId}/locations/{locationId}/clusters/{clusterId}
     */
    public val name: Output
        get() = javaResource.name().applyValue({ args0 -> args0 })

    /**
     * The nodeType for the Redis cluster. If not provided, REDIS_HIGHMEM_MEDIUM will be used as default Possible values:
     * ["REDIS_SHARED_CORE_NANO", "REDIS_HIGHMEM_MEDIUM", "REDIS_HIGHMEM_XLARGE", "REDIS_STANDARD_SMALL"]
     */
    public val nodeType: Output
        get() = javaResource.nodeType().applyValue({ args0 -> args0 })

    /**
     * Output only. Redis memory precise size in GB for the entire cluster.
     */
    public val preciseSizeGb: Output
        get() = javaResource.preciseSizeGb().applyValue({ args0 -> args0 })

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

    /**
     * Required. Each PscConfig configures the consumer network where two
     * network addresses will be designated to the cluster for client access.
     * Currently, only one PscConfig is supported.
     * Structure is documented below.
     */
    public val pscConfigs: Output>
        get() = javaResource.pscConfigs().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.let({ args0 ->
                    clusterPscConfigToKotlin(args0)
                })
            })
        })

    /**
     * Output only. PSC connections for discovery of the cluster topology and accessing the cluster.
     * Structure is documented below.
     */
    public val pscConnections: Output>
        get() = javaResource.pscConnections().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.let({ args0 -> clusterPscConnectionToKotlin(args0) })
            })
        })

    /**
     * Configure Redis Cluster behavior using a subset of native Redis configuration parameters. Please check Memorystore
     * documentation for the list of supported parameters:
     * https://cloud.google.com/memorystore/docs/cluster/supported-instance-configurations
     */
    public val redisConfigs: Output>?
        get() = javaResource.redisConfigs().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.map({ args0 ->
                    args0.key.to(args0.value)
                }).toMap()
            }).orElse(null)
        })

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

    /**
     * Optional. The number of replica nodes per shard.
     */
    public val replicaCount: Output?
        get() = javaResource.replicaCount().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * Required. Number of shards for the Redis cluster.
     */
    public val shardCount: Output
        get() = javaResource.shardCount().applyValue({ args0 -> args0 })

    /**
     * Output only. Redis memory size in GB for the entire cluster.
     */
    public val sizeGb: Output
        get() = javaResource.sizeGb().applyValue({ args0 -> args0 })

    /**
     * The current state of this cluster. Can be CREATING, READY, UPDATING, DELETING and SUSPENDED
     */
    public val state: Output
        get() = javaResource.state().applyValue({ args0 -> args0 })

    /**
     * Output only. Additional information about the current state of the cluster.
     * Structure is documented below.
     */
    public val stateInfos: Output>
        get() = javaResource.stateInfos().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.let({ args0 ->
                    clusterStateInfoToKotlin(args0)
                })
            })
        })

    /**
     * Optional. The in-transit encryption for the Redis cluster. If not provided, encryption is disabled for the cluster.
     * Default value: "TRANSIT_ENCRYPTION_MODE_DISABLED" Possible values: ["TRANSIT_ENCRYPTION_MODE_UNSPECIFIED",
     * "TRANSIT_ENCRYPTION_MODE_DISABLED", "TRANSIT_ENCRYPTION_MODE_SERVER_AUTHENTICATION"]
     */
    public val transitEncryptionMode: Output?
        get() = javaResource.transitEncryptionMode().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * System assigned, unique identifier for the cluster.
     */
    public val uid: Output
        get() = javaResource.uid().applyValue({ args0 -> args0 })
}

public object ClusterMapper : ResourceMapper {
    override fun supportsMappingOfType(javaResource: Resource): Boolean =
        com.pulumi.gcp.redis.Cluster::class == javaResource::class

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

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

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




© 2015 - 2025 Weber Informatics LLC | Privacy Policy