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

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

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

package com.pulumi.azure.redis.kotlin

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.String
import kotlin.Suppress
import kotlin.Unit

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

    public var args: LinkedServerArgs = LinkedServerArgs()

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

/**
 * Manages a Redis Linked Server (ie Geo Location)
 * ## Example Usage
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as azure from "@pulumi/azure";
 * const example_primary = new azure.core.ResourceGroup("example-primary", {
 *     name: "example-resources-primary",
 *     location: "East US",
 * });
 * const example_primaryCache = new azure.redis.Cache("example-primary", {
 *     name: "example-cache1",
 *     location: example_primary.location,
 *     resourceGroupName: example_primary.name,
 *     capacity: 1,
 *     family: "P",
 *     skuName: "Premium",
 *     enableNonSslPort: false,
 *     redisConfiguration: {
 *         maxmemoryReserved: 2,
 *         maxmemoryDelta: 2,
 *         maxmemoryPolicy: "allkeys-lru",
 *     },
 * });
 * const example_secondary = new azure.core.ResourceGroup("example-secondary", {
 *     name: "example-resources-secondary",
 *     location: "West US",
 * });
 * const example_secondaryCache = new azure.redis.Cache("example-secondary", {
 *     name: "example-cache2",
 *     location: example_secondary.location,
 *     resourceGroupName: example_secondary.name,
 *     capacity: 1,
 *     family: "P",
 *     skuName: "Premium",
 *     enableNonSslPort: false,
 *     redisConfiguration: {
 *         maxmemoryReserved: 2,
 *         maxmemoryDelta: 2,
 *         maxmemoryPolicy: "allkeys-lru",
 *     },
 * });
 * const example_link = new azure.redis.LinkedServer("example-link", {
 *     targetRedisCacheName: example_primaryCache.name,
 *     resourceGroupName: example_primaryCache.resourceGroupName,
 *     linkedRedisCacheId: example_secondaryCache.id,
 *     linkedRedisCacheLocation: example_secondaryCache.location,
 *     serverRole: "Secondary",
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_azure as azure
 * example_primary = azure.core.ResourceGroup("example-primary",
 *     name="example-resources-primary",
 *     location="East US")
 * example_primary_cache = azure.redis.Cache("example-primary",
 *     name="example-cache1",
 *     location=example_primary.location,
 *     resource_group_name=example_primary.name,
 *     capacity=1,
 *     family="P",
 *     sku_name="Premium",
 *     enable_non_ssl_port=False,
 *     redis_configuration={
 *         "maxmemory_reserved": 2,
 *         "maxmemory_delta": 2,
 *         "maxmemory_policy": "allkeys-lru",
 *     })
 * example_secondary = azure.core.ResourceGroup("example-secondary",
 *     name="example-resources-secondary",
 *     location="West US")
 * example_secondary_cache = azure.redis.Cache("example-secondary",
 *     name="example-cache2",
 *     location=example_secondary.location,
 *     resource_group_name=example_secondary.name,
 *     capacity=1,
 *     family="P",
 *     sku_name="Premium",
 *     enable_non_ssl_port=False,
 *     redis_configuration={
 *         "maxmemory_reserved": 2,
 *         "maxmemory_delta": 2,
 *         "maxmemory_policy": "allkeys-lru",
 *     })
 * example_link = azure.redis.LinkedServer("example-link",
 *     target_redis_cache_name=example_primary_cache.name,
 *     resource_group_name=example_primary_cache.resource_group_name,
 *     linked_redis_cache_id=example_secondary_cache.id,
 *     linked_redis_cache_location=example_secondary_cache.location,
 *     server_role="Secondary")
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Azure = Pulumi.Azure;
 * return await Deployment.RunAsync(() =>
 * {
 *     var example_primary = new Azure.Core.ResourceGroup("example-primary", new()
 *     {
 *         Name = "example-resources-primary",
 *         Location = "East US",
 *     });
 *     var example_primaryCache = new Azure.Redis.Cache("example-primary", new()
 *     {
 *         Name = "example-cache1",
 *         Location = example_primary.Location,
 *         ResourceGroupName = example_primary.Name,
 *         Capacity = 1,
 *         Family = "P",
 *         SkuName = "Premium",
 *         EnableNonSslPort = false,
 *         RedisConfiguration = new Azure.Redis.Inputs.CacheRedisConfigurationArgs
 *         {
 *             MaxmemoryReserved = 2,
 *             MaxmemoryDelta = 2,
 *             MaxmemoryPolicy = "allkeys-lru",
 *         },
 *     });
 *     var example_secondary = new Azure.Core.ResourceGroup("example-secondary", new()
 *     {
 *         Name = "example-resources-secondary",
 *         Location = "West US",
 *     });
 *     var example_secondaryCache = new Azure.Redis.Cache("example-secondary", new()
 *     {
 *         Name = "example-cache2",
 *         Location = example_secondary.Location,
 *         ResourceGroupName = example_secondary.Name,
 *         Capacity = 1,
 *         Family = "P",
 *         SkuName = "Premium",
 *         EnableNonSslPort = false,
 *         RedisConfiguration = new Azure.Redis.Inputs.CacheRedisConfigurationArgs
 *         {
 *             MaxmemoryReserved = 2,
 *             MaxmemoryDelta = 2,
 *             MaxmemoryPolicy = "allkeys-lru",
 *         },
 *     });
 *     var example_link = new Azure.Redis.LinkedServer("example-link", new()
 *     {
 *         TargetRedisCacheName = example_primaryCache.Name,
 *         ResourceGroupName = example_primaryCache.ResourceGroupName,
 *         LinkedRedisCacheId = example_secondaryCache.Id,
 *         LinkedRedisCacheLocation = example_secondaryCache.Location,
 *         ServerRole = "Secondary",
 *     });
 * });
 * ```
 * ```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 {
 * 		_, err := core.NewResourceGroup(ctx, "example-primary", &core.ResourceGroupArgs{
 * 			Name:     pulumi.String("example-resources-primary"),
 * 			Location: pulumi.String("East US"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = redis.NewCache(ctx, "example-primary", &redis.CacheArgs{
 * 			Name:              pulumi.String("example-cache1"),
 * 			Location:          example_primary.Location,
 * 			ResourceGroupName: example_primary.Name,
 * 			Capacity:          pulumi.Int(1),
 * 			Family:            pulumi.String("P"),
 * 			SkuName:           pulumi.String("Premium"),
 * 			EnableNonSslPort:  pulumi.Bool(false),
 * 			RedisConfiguration: &redis.CacheRedisConfigurationArgs{
 * 				MaxmemoryReserved: pulumi.Int(2),
 * 				MaxmemoryDelta:    pulumi.Int(2),
 * 				MaxmemoryPolicy:   pulumi.String("allkeys-lru"),
 * 			},
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = core.NewResourceGroup(ctx, "example-secondary", &core.ResourceGroupArgs{
 * 			Name:     pulumi.String("example-resources-secondary"),
 * 			Location: pulumi.String("West US"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = redis.NewCache(ctx, "example-secondary", &redis.CacheArgs{
 * 			Name:              pulumi.String("example-cache2"),
 * 			Location:          example_secondary.Location,
 * 			ResourceGroupName: example_secondary.Name,
 * 			Capacity:          pulumi.Int(1),
 * 			Family:            pulumi.String("P"),
 * 			SkuName:           pulumi.String("Premium"),
 * 			EnableNonSslPort:  pulumi.Bool(false),
 * 			RedisConfiguration: &redis.CacheRedisConfigurationArgs{
 * 				MaxmemoryReserved: pulumi.Int(2),
 * 				MaxmemoryDelta:    pulumi.Int(2),
 * 				MaxmemoryPolicy:   pulumi.String("allkeys-lru"),
 * 			},
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = redis.NewLinkedServer(ctx, "example-link", &redis.LinkedServerArgs{
 * 			TargetRedisCacheName:     example_primaryCache.Name,
 * 			ResourceGroupName:        example_primaryCache.ResourceGroupName,
 * 			LinkedRedisCacheId:       example_secondaryCache.ID(),
 * 			LinkedRedisCacheLocation: example_secondaryCache.Location,
 * 			ServerRole:               pulumi.String("Secondary"),
 * 		})
 * 		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 com.pulumi.azure.redis.LinkedServer;
 * import com.pulumi.azure.redis.LinkedServerArgs;
 * 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_primary = new ResourceGroup("example-primary", ResourceGroupArgs.builder()
 *             .name("example-resources-primary")
 *             .location("East US")
 *             .build());
 *         var example_primaryCache = new Cache("example-primaryCache", CacheArgs.builder()
 *             .name("example-cache1")
 *             .location(example_primary.location())
 *             .resourceGroupName(example_primary.name())
 *             .capacity(1)
 *             .family("P")
 *             .skuName("Premium")
 *             .enableNonSslPort(false)
 *             .redisConfiguration(CacheRedisConfigurationArgs.builder()
 *                 .maxmemoryReserved(2)
 *                 .maxmemoryDelta(2)
 *                 .maxmemoryPolicy("allkeys-lru")
 *                 .build())
 *             .build());
 *         var example_secondary = new ResourceGroup("example-secondary", ResourceGroupArgs.builder()
 *             .name("example-resources-secondary")
 *             .location("West US")
 *             .build());
 *         var example_secondaryCache = new Cache("example-secondaryCache", CacheArgs.builder()
 *             .name("example-cache2")
 *             .location(example_secondary.location())
 *             .resourceGroupName(example_secondary.name())
 *             .capacity(1)
 *             .family("P")
 *             .skuName("Premium")
 *             .enableNonSslPort(false)
 *             .redisConfiguration(CacheRedisConfigurationArgs.builder()
 *                 .maxmemoryReserved(2)
 *                 .maxmemoryDelta(2)
 *                 .maxmemoryPolicy("allkeys-lru")
 *                 .build())
 *             .build());
 *         var example_link = new LinkedServer("example-link", LinkedServerArgs.builder()
 *             .targetRedisCacheName(example_primaryCache.name())
 *             .resourceGroupName(example_primaryCache.resourceGroupName())
 *             .linkedRedisCacheId(example_secondaryCache.id())
 *             .linkedRedisCacheLocation(example_secondaryCache.location())
 *             .serverRole("Secondary")
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   example-primary:
 *     type: azure:core:ResourceGroup
 *     properties:
 *       name: example-resources-primary
 *       location: East US
 *   example-primaryCache:
 *     type: azure:redis:Cache
 *     name: example-primary
 *     properties:
 *       name: example-cache1
 *       location: ${["example-primary"].location}
 *       resourceGroupName: ${["example-primary"].name}
 *       capacity: 1
 *       family: P
 *       skuName: Premium
 *       enableNonSslPort: false
 *       redisConfiguration:
 *         maxmemoryReserved: 2
 *         maxmemoryDelta: 2
 *         maxmemoryPolicy: allkeys-lru
 *   example-secondary:
 *     type: azure:core:ResourceGroup
 *     properties:
 *       name: example-resources-secondary
 *       location: West US
 *   example-secondaryCache:
 *     type: azure:redis:Cache
 *     name: example-secondary
 *     properties:
 *       name: example-cache2
 *       location: ${["example-secondary"].location}
 *       resourceGroupName: ${["example-secondary"].name}
 *       capacity: 1
 *       family: P
 *       skuName: Premium
 *       enableNonSslPort: false
 *       redisConfiguration:
 *         maxmemoryReserved: 2
 *         maxmemoryDelta: 2
 *         maxmemoryPolicy: allkeys-lru
 *   example-link:
 *     type: azure:redis:LinkedServer
 *     properties:
 *       targetRedisCacheName: ${["example-primaryCache"].name}
 *       resourceGroupName: ${["example-primaryCache"].resourceGroupName}
 *       linkedRedisCacheId: ${["example-secondaryCache"].id}
 *       linkedRedisCacheLocation: ${["example-secondaryCache"].location}
 *       serverRole: Secondary
 * ```
 * 
 * ## Import
 * Redis can be imported using the `resource id`, e.g.
 * ```sh
 * $ pulumi import azure:redis/linkedServer:LinkedServer example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.Cache/redis/cache1/linkedServers/cache2
 * ```
 */
public class LinkedServer internal constructor(
    override val javaResource: com.pulumi.azure.redis.LinkedServer,
) : KotlinCustomResource(javaResource, LinkedServerMapper) {
    /**
     * The geo-replicated primary hostname for this linked server.
     */
    public val geoReplicatedPrimaryHostName: Output
        get() = javaResource.geoReplicatedPrimaryHostName().applyValue({ args0 -> args0 })

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

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

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

    /**
     * The name of the Resource Group where the Redis caches exists. Changing this forces a new Redis to be created.
     */
    public val resourceGroupName: Output
        get() = javaResource.resourceGroupName().applyValue({ args0 -> args0 })

    /**
     * The role of the linked Redis cache (eg "Secondary"). Changing this forces a new Redis to be created. Possible values are `Primary` and `Secondary`.
     */
    public val serverRole: Output
        get() = javaResource.serverRole().applyValue({ args0 -> args0 })

    /**
     * The name of Redis cache to link with. Changing this forces a new Redis to be created. (eg The primary role)
     */
    public val targetRedisCacheName: Output
        get() = javaResource.targetRedisCacheName().applyValue({ args0 -> args0 })
}

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

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

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy