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

com.pulumi.azure.redis.kotlin.Cache.kt Maven / Gradle / Ivy

@file:Suppress("NAME_SHADOWING", "DEPRECATION")

package com.pulumi.azure.redis.kotlin

import com.pulumi.azure.redis.kotlin.outputs.CacheIdentity
import com.pulumi.azure.redis.kotlin.outputs.CachePatchSchedule
import com.pulumi.azure.redis.kotlin.outputs.CacheRedisConfiguration
import com.pulumi.core.Output
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.Deprecated
import kotlin.Int
import kotlin.String
import kotlin.Suppress
import kotlin.Unit
import kotlin.collections.List
import kotlin.collections.Map
import com.pulumi.azure.redis.kotlin.outputs.CacheIdentity.Companion.toKotlin as cacheIdentityToKotlin
import com.pulumi.azure.redis.kotlin.outputs.CachePatchSchedule.Companion.toKotlin as cachePatchScheduleToKotlin
import com.pulumi.azure.redis.kotlin.outputs.CacheRedisConfiguration.Companion.toKotlin as cacheRedisConfigurationToKotlin

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

    public var args: CacheArgs = CacheArgs()

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

/**
 * Manages a Redis Cache.
 * > **Note:** Redis version 4 is being retired and no longer supports creating new instances. Version 4 will be removed in a future release. [Redis Version 4 Retirement](https://learn.microsoft.com/azure/azure-cache-for-redis/cache-retired-features#important-upgrade-timelines)
 * ## Example Usage
 * This example provisions a Standard Redis Cache.
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as azure from "@pulumi/azure";
 * const example = new azure.core.ResourceGroup("example", {
 *     name: "example-resources",
 *     location: "West Europe",
 * });
 * // NOTE: the Name used for Redis needs to be globally unique
 * const exampleCache = new azure.redis.Cache("example", {
 *     name: "example-cache",
 *     location: example.location,
 *     resourceGroupName: example.name,
 *     capacity: 2,
 *     family: "C",
 *     skuName: "Standard",
 *     enableNonSslPort: false,
 *     minimumTlsVersion: "1.2",
 *     redisConfiguration: {},
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_azure as azure
 * example = azure.core.ResourceGroup("example",
 *     name="example-resources",
 *     location="West Europe")
 * # NOTE: the Name used for Redis needs to be globally unique
 * example_cache = azure.redis.Cache("example",
 *     name="example-cache",
 *     location=example.location,
 *     resource_group_name=example.name,
 *     capacity=2,
 *     family="C",
 *     sku_name="Standard",
 *     enable_non_ssl_port=False,
 *     minimum_tls_version="1.2",
 *     redis_configuration={})
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Azure = Pulumi.Azure;
 * return await Deployment.RunAsync(() =>
 * {
 *     var example = new Azure.Core.ResourceGroup("example", new()
 *     {
 *         Name = "example-resources",
 *         Location = "West Europe",
 *     });
 *     // NOTE: the Name used for Redis needs to be globally unique
 *     var exampleCache = new Azure.Redis.Cache("example", new()
 *     {
 *         Name = "example-cache",
 *         Location = example.Location,
 *         ResourceGroupName = example.Name,
 *         Capacity = 2,
 *         Family = "C",
 *         SkuName = "Standard",
 *         EnableNonSslPort = false,
 *         MinimumTlsVersion = "1.2",
 *         RedisConfiguration = null,
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/core"
 * 	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/redis"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		example, err := core.NewResourceGroup(ctx, "example", &core.ResourceGroupArgs{
 * 			Name:     pulumi.String("example-resources"),
 * 			Location: pulumi.String("West Europe"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		// NOTE: the Name used for Redis needs to be globally unique
 * 		_, err = redis.NewCache(ctx, "example", &redis.CacheArgs{
 * 			Name:               pulumi.String("example-cache"),
 * 			Location:           example.Location,
 * 			ResourceGroupName:  example.Name,
 * 			Capacity:           pulumi.Int(2),
 * 			Family:             pulumi.String("C"),
 * 			SkuName:            pulumi.String("Standard"),
 * 			EnableNonSslPort:   pulumi.Bool(false),
 * 			MinimumTlsVersion:  pulumi.String("1.2"),
 * 			RedisConfiguration: 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.azure.core.ResourceGroup;
 * import com.pulumi.azure.core.ResourceGroupArgs;
 * import com.pulumi.azure.redis.Cache;
 * import com.pulumi.azure.redis.CacheArgs;
 * import com.pulumi.azure.redis.inputs.CacheRedisConfigurationArgs;
 * 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 example = new ResourceGroup("example", ResourceGroupArgs.builder()
 *             .name("example-resources")
 *             .location("West Europe")
 *             .build());
 *         // NOTE: the Name used for Redis needs to be globally unique
 *         var exampleCache = new Cache("exampleCache", CacheArgs.builder()
 *             .name("example-cache")
 *             .location(example.location())
 *             .resourceGroupName(example.name())
 *             .capacity(2)
 *             .family("C")
 *             .skuName("Standard")
 *             .enableNonSslPort(false)
 *             .minimumTlsVersion("1.2")
 *             .redisConfiguration()
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   example:
 *     type: azure:core:ResourceGroup
 *     properties:
 *       name: example-resources
 *       location: West Europe
 *   # NOTE: the Name used for Redis needs to be globally unique
 *   exampleCache:
 *     type: azure:redis:Cache
 *     name: example
 *     properties:
 *       name: example-cache
 *       location: ${example.location}
 *       resourceGroupName: ${example.name}
 *       capacity: 2
 *       family: C
 *       skuName: Standard
 *       enableNonSslPort: false
 *       minimumTlsVersion: '1.2'
 *       redisConfiguration: {}
 * ```
 * 
 * ## Relevant Links
 * * [Azure Cache for Redis planning](https://docs.microsoft.com/azure/azure-cache-for-redis/cache-planning-faq)
 * * [Redis: Available Configuration Settings](https://redis.io/topics/config)
 * ## Import
 * Redis Cache's can be imported using the `resource id`, e.g.
 * ```sh
 * $ pulumi import azure:redis/cache:Cache cache1 /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.Cache/redis/cache1
 * ```
 */
public class Cache internal constructor(
    override val javaResource: com.pulumi.azure.redis.Cache,
) : KotlinCustomResource(javaResource, CacheMapper) {
    /**
     * The size of the Redis cache to deploy. Valid values for a SKU `family` of C (Basic/Standard) are `0, 1, 2, 3, 4, 5, 6`, and for P (Premium) `family` are `1, 2, 3, 4, 5`.
     */
    public val capacity: Output
        get() = javaResource.capacity().applyValue({ args0 -> args0 })

    /**
     * Enable the non-SSL port (6379) - disabled by default.
     */
    @Deprecated(
        message = """
  `enable_non_ssl_port` will be removed in favour of the property `non_ssl_port_enabled` in version
      4.0 of the AzureRM Provider.
  """,
    )
    public val enableNonSslPort: Output?
        get() = javaResource.enableNonSslPort().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * The SKU family/pricing group to use. Valid values are `C` (for Basic/Standard SKU family) and `P` (for `Premium`)
     */
    public val family: Output
        get() = javaResource.family().applyValue({ args0 -> args0 })

    /**
     * The Hostname of the Redis Instance
     */
    public val hostname: Output
        get() = javaResource.hostname().applyValue({ args0 -> args0 })

    /**
     * An `identity` block as defined below.
     */
    public val identity: Output?
        get() = javaResource.identity().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.let({ args0 ->
                    cacheIdentityToKotlin(args0)
                })
            }).orElse(null)
        })

    /**
     * The location of the resource group. Changing this forces a new resource to be created.
     */
    public val location: Output
        get() = javaResource.location().applyValue({ args0 -> args0 })

    /**
     * The minimum TLS version. Possible values are `1.0`, `1.1` and `1.2`. Defaults to `1.0`.
     */
    public val minimumTlsVersion: Output?
        get() = javaResource.minimumTlsVersion().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * The name of the Redis instance. Changing this forces a new resource to be created.
     */
    public val name: Output
        get() = javaResource.name().applyValue({ args0 -> args0 })

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

    /**
     * A list of `patch_schedule` blocks as defined below.
     */
    public val patchSchedules: Output>?
        get() = javaResource.patchSchedules().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.map({ args0 ->
                    args0.let({ args0 ->
                        cachePatchScheduleToKotlin(args0)
                    })
                })
            }).orElse(null)
        })

    /**
     * The non-SSL Port of the Redis Instance
     */
    public val port: Output
        get() = javaResource.port().applyValue({ args0 -> args0 })

    /**
     * The Primary Access Key for the Redis Instance
     */
    public val primaryAccessKey: Output
        get() = javaResource.primaryAccessKey().applyValue({ args0 -> args0 })

    /**
     * The primary connection string of the Redis Instance.
     */
    public val primaryConnectionString: Output
        get() = javaResource.primaryConnectionString().applyValue({ args0 -> args0 })

    /**
     * The Static IP Address to assign to the Redis Cache when hosted inside the Virtual Network. This argument implies the use of `subnet_id`. Changing this forces a new resource to be created.
     */
    public val privateStaticIpAddress: Output
        get() = javaResource.privateStaticIpAddress().applyValue({ args0 -> args0 })

    /**
     * Whether or not public network access is allowed for this Redis Cache. `true` means this resource could be accessed by both public and private endpoint. `false` means only private endpoint access is allowed. Defaults to `true`.
     */
    public val publicNetworkAccessEnabled: Output?
        get() = javaResource.publicNetworkAccessEnabled().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * A `redis_configuration` block as defined below - with some limitations by SKU - defaults/details are shown below.
     */
    public val redisConfiguration: Output
        get() = javaResource.redisConfiguration().applyValue({ args0 ->
            args0.let({ args0 ->
                cacheRedisConfigurationToKotlin(args0)
            })
        })

    /**
     * Redis version. Only major version needed. Valid values: `4`, `6`.
     */
    public val redisVersion: Output
        get() = javaResource.redisVersion().applyValue({ args0 -> args0 })

    /**
     * Amount of replicas to create per master for this Redis Cache.
     * > **Note:** Configuring the number of replicas per master is only available when using the Premium SKU and cannot be used in conjunction with shards.
     */
    public val replicasPerMaster: Output
        get() = javaResource.replicasPerMaster().applyValue({ args0 -> args0 })

    /**
     * Amount of replicas to create per primary for this Redis Cache. If both `replicas_per_primary` and `replicas_per_master` are set, they need to be equal.
     */
    public val replicasPerPrimary: Output
        get() = javaResource.replicasPerPrimary().applyValue({ args0 -> args0 })

    /**
     * The name of the resource group in which to create the Redis instance. Changing this forces a new resource to be created.
     */
    public val resourceGroupName: Output
        get() = javaResource.resourceGroupName().applyValue({ args0 -> args0 })

    /**
     * The Secondary Access Key for the Redis Instance
     */
    public val secondaryAccessKey: Output
        get() = javaResource.secondaryAccessKey().applyValue({ args0 -> args0 })

    /**
     * The secondary connection string of the Redis Instance.
     */
    public val secondaryConnectionString: Output
        get() = javaResource.secondaryConnectionString().applyValue({ args0 -> args0 })

    /**
     * *Only available when using the Premium SKU* The number of Shards to create on the Redis Cluster.
     */
    public val shardCount: Output?
        get() = javaResource.shardCount().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * The SKU of Redis to use. Possible values are `Basic`, `Standard` and `Premium`.
     * > **Note** Downgrading the SKU will force a new resource to be created.
     */
    public val skuName: Output
        get() = javaResource.skuName().applyValue({ args0 -> args0 })

    /**
     * The SSL Port of the Redis Instance
     */
    public val sslPort: Output
        get() = javaResource.sslPort().applyValue({ args0 -> args0 })

    /**
     * *Only available when using the Premium SKU* The ID of the Subnet within which the Redis Cache should be deployed. This Subnet must only contain Azure Cache for Redis instances without any other type of resources. Changing this forces a new resource to be created.
     */
    public val subnetId: Output?
        get() = javaResource.subnetId().applyValue({ args0 -> args0.map({ args0 -> args0 }).orElse(null) })

    /**
     * A mapping of tags to assign to the resource.
     */
    public val tags: Output>?
        get() = javaResource.tags().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.map({ args0 ->
                    args0.key.to(args0.value)
                }).toMap()
            }).orElse(null)
        })

    /**
     * A mapping of tenant settings to assign to the resource.
     */
    public val tenantSettings: Output>?
        get() = javaResource.tenantSettings().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.map({ args0 -> args0.key.to(args0.value) }).toMap()
            }).orElse(null)
        })

    /**
     * Specifies a list of Availability Zones in which this Redis Cache should be located. Changing this forces a new Redis Cache to be created.
     * > **Please Note**: Availability Zones are [in Preview and only supported in several regions at this time](https://docs.microsoft.com/azure/availability-zones/az-overview) - as such you must be opted into the Preview to use this functionality. You can [opt into the Availability Zones Preview in the Azure Portal](https://aka.ms/azenroll).
     */
    public val zones: Output>?
        get() = javaResource.zones().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.map({ args0 ->
                    args0
                })
            }).orElse(null)
        })
}

public object CacheMapper : ResourceMapper {
    override fun supportsMappingOfType(javaResource: Resource): Boolean =
        com.pulumi.azure.redis.Cache::class == javaResource::class

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

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy