Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
com.pulumi.gcp.memcache.kotlin.Instance.kt Maven / Gradle / Ivy
@file:Suppress("NAME_SHADOWING", "DEPRECATION")
package com.pulumi.gcp.memcache.kotlin
import com.pulumi.core.Output
import com.pulumi.gcp.memcache.kotlin.outputs.InstanceMaintenancePolicy
import com.pulumi.gcp.memcache.kotlin.outputs.InstanceMaintenanceSchedule
import com.pulumi.gcp.memcache.kotlin.outputs.InstanceMemcacheNode
import com.pulumi.gcp.memcache.kotlin.outputs.InstanceMemcacheParameters
import com.pulumi.gcp.memcache.kotlin.outputs.InstanceNodeConfig
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.Int
import kotlin.String
import kotlin.Suppress
import kotlin.Unit
import kotlin.collections.List
import kotlin.collections.Map
import com.pulumi.gcp.memcache.kotlin.outputs.InstanceMaintenancePolicy.Companion.toKotlin as instanceMaintenancePolicyToKotlin
import com.pulumi.gcp.memcache.kotlin.outputs.InstanceMaintenanceSchedule.Companion.toKotlin as instanceMaintenanceScheduleToKotlin
import com.pulumi.gcp.memcache.kotlin.outputs.InstanceMemcacheNode.Companion.toKotlin as instanceMemcacheNodeToKotlin
import com.pulumi.gcp.memcache.kotlin.outputs.InstanceMemcacheParameters.Companion.toKotlin as instanceMemcacheParametersToKotlin
import com.pulumi.gcp.memcache.kotlin.outputs.InstanceNodeConfig.Companion.toKotlin as instanceNodeConfigToKotlin
/**
* 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.memcache.Instance(
this.name,
this.args.toJava(),
this.opts.toJava(),
)
return Instance(builtJavaResource)
}
}
/**
* A Google Cloud Memcache instance.
* To get more information about Instance, see:
* * [API documentation](https://cloud.google.com/memorystore/docs/memcached/reference/rest/v1/projects.locations.instances)
* * How-to Guides
* * [Official Documentation](https://cloud.google.com/memcache/docs/creating-instances)
* ## Example Usage
* ### Memcache Instance Basic
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
* // This example assumes this network already exists.
* // The API creates a tenant network per network authorized for a
* // Memcache instance and that network is not deleted when the user-created
* // network (authorized_network) is deleted, so this prevents issues
* // with tenant network quota.
* // If this network hasn't been created and you are using this example in your
* // config, add an additional network resource or change
* // this from "data"to "resource"
* const memcacheNetwork = new gcp.compute.Network("memcache_network", {name: "test-network"});
* const serviceRange = new gcp.compute.GlobalAddress("service_range", {
* name: "address",
* purpose: "VPC_PEERING",
* addressType: "INTERNAL",
* prefixLength: 16,
* network: memcacheNetwork.id,
* });
* const privateServiceConnection = new gcp.servicenetworking.Connection("private_service_connection", {
* network: memcacheNetwork.id,
* service: "servicenetworking.googleapis.com",
* reservedPeeringRanges: [serviceRange.name],
* });
* const instance = new gcp.memcache.Instance("instance", {
* name: "test-instance",
* authorizedNetwork: privateServiceConnection.network,
* labels: {
* env: "test",
* },
* nodeConfig: {
* cpuCount: 1,
* memorySizeMb: 1024,
* },
* nodeCount: 1,
* memcacheVersion: "MEMCACHE_1_5",
* maintenancePolicy: {
* weeklyMaintenanceWindows: [{
* day: "SATURDAY",
* duration: "14400s",
* startTime: {
* hours: 0,
* minutes: 30,
* seconds: 0,
* nanos: 0,
* },
* }],
* },
* });
* ```
* ```python
* import pulumi
* import pulumi_gcp as gcp
* # This example assumes this network already exists.
* # The API creates a tenant network per network authorized for a
* # Memcache instance and that network is not deleted when the user-created
* # network (authorized_network) is deleted, so this prevents issues
* # with tenant network quota.
* # If this network hasn't been created and you are using this example in your
* # config, add an additional network resource or change
* # this from "data"to "resource"
* memcache_network = gcp.compute.Network("memcache_network", name="test-network")
* service_range = gcp.compute.GlobalAddress("service_range",
* name="address",
* purpose="VPC_PEERING",
* address_type="INTERNAL",
* prefix_length=16,
* network=memcache_network.id)
* private_service_connection = gcp.servicenetworking.Connection("private_service_connection",
* network=memcache_network.id,
* service="servicenetworking.googleapis.com",
* reserved_peering_ranges=[service_range.name])
* instance = gcp.memcache.Instance("instance",
* name="test-instance",
* authorized_network=private_service_connection.network,
* labels={
* "env": "test",
* },
* node_config={
* "cpu_count": 1,
* "memory_size_mb": 1024,
* },
* node_count=1,
* memcache_version="MEMCACHE_1_5",
* maintenance_policy={
* "weekly_maintenance_windows": [{
* "day": "SATURDAY",
* "duration": "14400s",
* "start_time": {
* "hours": 0,
* "minutes": 30,
* "seconds": 0,
* "nanos": 0,
* },
* }],
* })
* ```
* ```csharp
* using System.Collections.Generic;
* using System.Linq;
* using Pulumi;
* using Gcp = Pulumi.Gcp;
* return await Deployment.RunAsync(() =>
* {
* // This example assumes this network already exists.
* // The API creates a tenant network per network authorized for a
* // Memcache instance and that network is not deleted when the user-created
* // network (authorized_network) is deleted, so this prevents issues
* // with tenant network quota.
* // If this network hasn't been created and you are using this example in your
* // config, add an additional network resource or change
* // this from "data"to "resource"
* var memcacheNetwork = new Gcp.Compute.Network("memcache_network", new()
* {
* Name = "test-network",
* });
* var serviceRange = new Gcp.Compute.GlobalAddress("service_range", new()
* {
* Name = "address",
* Purpose = "VPC_PEERING",
* AddressType = "INTERNAL",
* PrefixLength = 16,
* Network = memcacheNetwork.Id,
* });
* var privateServiceConnection = new Gcp.ServiceNetworking.Connection("private_service_connection", new()
* {
* Network = memcacheNetwork.Id,
* Service = "servicenetworking.googleapis.com",
* ReservedPeeringRanges = new[]
* {
* serviceRange.Name,
* },
* });
* var instance = new Gcp.Memcache.Instance("instance", new()
* {
* Name = "test-instance",
* AuthorizedNetwork = privateServiceConnection.Network,
* Labels =
* {
* { "env", "test" },
* },
* NodeConfig = new Gcp.Memcache.Inputs.InstanceNodeConfigArgs
* {
* CpuCount = 1,
* MemorySizeMb = 1024,
* },
* NodeCount = 1,
* MemcacheVersion = "MEMCACHE_1_5",
* MaintenancePolicy = new Gcp.Memcache.Inputs.InstanceMaintenancePolicyArgs
* {
* WeeklyMaintenanceWindows = new[]
* {
* new Gcp.Memcache.Inputs.InstanceMaintenancePolicyWeeklyMaintenanceWindowArgs
* {
* Day = "SATURDAY",
* Duration = "14400s",
* StartTime = new Gcp.Memcache.Inputs.InstanceMaintenancePolicyWeeklyMaintenanceWindowStartTimeArgs
* {
* Hours = 0,
* Minutes = 30,
* Seconds = 0,
* Nanos = 0,
* },
* },
* },
* },
* });
* });
* ```
* ```go
* package main
* import (
* "github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/compute"
* "github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/memcache"
* "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 {
* // This example assumes this network already exists.
* // The API creates a tenant network per network authorized for a
* // Memcache instance and that network is not deleted when the user-created
* // network (authorized_network) is deleted, so this prevents issues
* // with tenant network quota.
* // If this network hasn't been created and you are using this example in your
* // config, add an additional network resource or change
* // this from "data"to "resource"
* memcacheNetwork, err := compute.NewNetwork(ctx, "memcache_network", &compute.NetworkArgs{
* Name: pulumi.String("test-network"),
* })
* if err != nil {
* return err
* }
* serviceRange, err := compute.NewGlobalAddress(ctx, "service_range", &compute.GlobalAddressArgs{
* Name: pulumi.String("address"),
* Purpose: pulumi.String("VPC_PEERING"),
* AddressType: pulumi.String("INTERNAL"),
* PrefixLength: pulumi.Int(16),
* Network: memcacheNetwork.ID(),
* })
* if err != nil {
* return err
* }
* privateServiceConnection, err := servicenetworking.NewConnection(ctx, "private_service_connection", &servicenetworking.ConnectionArgs{
* Network: memcacheNetwork.ID(),
* Service: pulumi.String("servicenetworking.googleapis.com"),
* ReservedPeeringRanges: pulumi.StringArray{
* serviceRange.Name,
* },
* })
* if err != nil {
* return err
* }
* _, err = memcache.NewInstance(ctx, "instance", &memcache.InstanceArgs{
* Name: pulumi.String("test-instance"),
* AuthorizedNetwork: privateServiceConnection.Network,
* Labels: pulumi.StringMap{
* "env": pulumi.String("test"),
* },
* NodeConfig: &memcache.InstanceNodeConfigArgs{
* CpuCount: pulumi.Int(1),
* MemorySizeMb: pulumi.Int(1024),
* },
* NodeCount: pulumi.Int(1),
* MemcacheVersion: pulumi.String("MEMCACHE_1_5"),
* MaintenancePolicy: &memcache.InstanceMaintenancePolicyArgs{
* WeeklyMaintenanceWindows: memcache.InstanceMaintenancePolicyWeeklyMaintenanceWindowArray{
* &memcache.InstanceMaintenancePolicyWeeklyMaintenanceWindowArgs{
* Day: pulumi.String("SATURDAY"),
* Duration: pulumi.String("14400s"),
* StartTime: &memcache.InstanceMaintenancePolicyWeeklyMaintenanceWindowStartTimeArgs{
* Hours: pulumi.Int(0),
* Minutes: pulumi.Int(30),
* Seconds: pulumi.Int(0),
* Nanos: pulumi.Int(0),
* },
* },
* },
* },
* })
* 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.compute.GlobalAddress;
* import com.pulumi.gcp.compute.GlobalAddressArgs;
* import com.pulumi.gcp.servicenetworking.Connection;
* import com.pulumi.gcp.servicenetworking.ConnectionArgs;
* import com.pulumi.gcp.memcache.Instance;
* import com.pulumi.gcp.memcache.InstanceArgs;
* import com.pulumi.gcp.memcache.inputs.InstanceNodeConfigArgs;
* import com.pulumi.gcp.memcache.inputs.InstanceMaintenancePolicyArgs;
* 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) {
* // This example assumes this network already exists.
* // The API creates a tenant network per network authorized for a
* // Memcache instance and that network is not deleted when the user-created
* // network (authorized_network) is deleted, so this prevents issues
* // with tenant network quota.
* // If this network hasn't been created and you are using this example in your
* // config, add an additional network resource or change
* // this from "data"to "resource"
* var memcacheNetwork = new Network("memcacheNetwork", NetworkArgs.builder()
* .name("test-network")
* .build());
* var serviceRange = new GlobalAddress("serviceRange", GlobalAddressArgs.builder()
* .name("address")
* .purpose("VPC_PEERING")
* .addressType("INTERNAL")
* .prefixLength(16)
* .network(memcacheNetwork.id())
* .build());
* var privateServiceConnection = new Connection("privateServiceConnection", ConnectionArgs.builder()
* .network(memcacheNetwork.id())
* .service("servicenetworking.googleapis.com")
* .reservedPeeringRanges(serviceRange.name())
* .build());
* var instance = new Instance("instance", InstanceArgs.builder()
* .name("test-instance")
* .authorizedNetwork(privateServiceConnection.network())
* .labels(Map.of("env", "test"))
* .nodeConfig(InstanceNodeConfigArgs.builder()
* .cpuCount(1)
* .memorySizeMb(1024)
* .build())
* .nodeCount(1)
* .memcacheVersion("MEMCACHE_1_5")
* .maintenancePolicy(InstanceMaintenancePolicyArgs.builder()
* .weeklyMaintenanceWindows(InstanceMaintenancePolicyWeeklyMaintenanceWindowArgs.builder()
* .day("SATURDAY")
* .duration("14400s")
* .startTime(InstanceMaintenancePolicyWeeklyMaintenanceWindowStartTimeArgs.builder()
* .hours(0)
* .minutes(30)
* .seconds(0)
* .nanos(0)
* .build())
* .build())
* .build())
* .build());
* }
* }
* ```
* ```yaml
* resources:
* # This example assumes this network already exists.
* # // The API creates a tenant network per network authorized for a
* # // Memcache instance and that network is not deleted when the user-created
* # // network (authorized_network) is deleted, so this prevents issues
* # // with tenant network quota.
* # // If this network hasn't been created and you are using this example in your
* # // config, add an additional network resource or change
* # // this from "data"to "resource"
* memcacheNetwork:
* type: gcp:compute:Network
* name: memcache_network
* properties:
* name: test-network
* serviceRange:
* type: gcp:compute:GlobalAddress
* name: service_range
* properties:
* name: address
* purpose: VPC_PEERING
* addressType: INTERNAL
* prefixLength: 16
* network: ${memcacheNetwork.id}
* privateServiceConnection:
* type: gcp:servicenetworking:Connection
* name: private_service_connection
* properties:
* network: ${memcacheNetwork.id}
* service: servicenetworking.googleapis.com
* reservedPeeringRanges:
* - ${serviceRange.name}
* instance:
* type: gcp:memcache:Instance
* properties:
* name: test-instance
* authorizedNetwork: ${privateServiceConnection.network}
* labels:
* env: test
* nodeConfig:
* cpuCount: 1
* memorySizeMb: 1024
* nodeCount: 1
* memcacheVersion: MEMCACHE_1_5
* maintenancePolicy:
* weeklyMaintenanceWindows:
* - day: SATURDAY
* duration: 14400s
* startTime:
* hours: 0
* minutes: 30
* seconds: 0
* nanos: 0
* ```
*
* ## Import
* Instance can be imported using any of these accepted formats:
* * `projects/{{project}}/locations/{{region}}/instances/{{name}}`
* * `{{project}}/{{region}}/{{name}}`
* * `{{region}}/{{name}}`
* * `{{name}}`
* When using the `pulumi import` command, Instance can be imported using one of the formats above. For example:
* ```sh
* $ pulumi import gcp:memcache/instance:Instance default projects/{{project}}/locations/{{region}}/instances/{{name}}
* ```
* ```sh
* $ pulumi import gcp:memcache/instance:Instance default {{project}}/{{region}}/{{name}}
* ```
* ```sh
* $ pulumi import gcp:memcache/instance:Instance default {{region}}/{{name}}
* ```
* ```sh
* $ pulumi import gcp:memcache/instance:Instance default {{name}}
* ```
*/
public class Instance internal constructor(
override val javaResource: com.pulumi.gcp.memcache.Instance,
) : KotlinCustomResource(javaResource, InstanceMapper) {
/**
* The full name of the GCE network to connect the instance to. If not provided, 'default' will be used.
*/
public val authorizedNetwork: Output
get() = javaResource.authorizedNetwork().applyValue({ args0 -> args0 })
/**
* Creation timestamp in RFC3339 text format.
*/
public val createTime: Output
get() = javaResource.createTime().applyValue({ args0 -> args0 })
/**
* Endpoint for Discovery API
*/
public val discoveryEndpoint: Output
get() = javaResource.discoveryEndpoint().applyValue({ args0 -> args0 })
/**
* A user-visible name for the instance.
*/
public val displayName: Output
get() = javaResource.displayName().applyValue({ args0 -> args0 })
/**
* 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()
})
/**
* Resource labels to represent user-provided metadata. **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)
})
/**
* Maintenance policy for an instance.
*/
public val maintenancePolicy: Output?
get() = javaResource.maintenancePolicy().applyValue({ args0 ->
args0.map({ args0 ->
args0.let({ args0 -> instanceMaintenancePolicyToKotlin(args0) })
}).orElse(null)
})
/**
* Output only. Published maintenance schedule.
* Structure is documented below.
*/
public val maintenanceSchedules: Output>
get() = javaResource.maintenanceSchedules().applyValue({ args0 ->
args0.map({ args0 ->
args0.let({ args0 -> instanceMaintenanceScheduleToKotlin(args0) })
})
})
/**
* The full version of memcached server running on this instance.
*/
public val memcacheFullVersion: Output
get() = javaResource.memcacheFullVersion().applyValue({ args0 -> args0 })
/**
* Additional information about the instance state, if available.
* Structure is documented below.
*/
public val memcacheNodes: Output>
get() = javaResource.memcacheNodes().applyValue({ args0 ->
args0.map({ args0 ->
args0.let({ args0 -> instanceMemcacheNodeToKotlin(args0) })
})
})
/**
* User-specified parameters for this memcache instance.
*/
public val memcacheParameters: Output?
get() = javaResource.memcacheParameters().applyValue({ args0 ->
args0.map({ args0 ->
args0.let({ args0 -> instanceMemcacheParametersToKotlin(args0) })
}).orElse(null)
})
/**
* The major version of Memcached software. If not provided, latest supported version will be used. Currently the latest
* supported major version is MEMCACHE_1_5. The minor version will be automatically determined by our system based on the
* latest supported minor version. Default value: "MEMCACHE_1_5" Possible values: ["MEMCACHE_1_5", "MEMCACHE_1_6_15"]
*/
public val memcacheVersion: Output?
get() = javaResource.memcacheVersion().applyValue({ args0 ->
args0.map({ args0 ->
args0
}).orElse(null)
})
/**
* The resource name of the instance.
*/
public val name: Output
get() = javaResource.name().applyValue({ args0 -> args0 })
/**
* Configuration for memcache nodes.
* Structure is documented below.
*/
public val nodeConfig: Output
get() = javaResource.nodeConfig().applyValue({ args0 ->
args0.let({ args0 ->
instanceNodeConfigToKotlin(args0)
})
})
/**
* Number of nodes in the memcache instance.
*/
public val nodeCount: Output
get() = javaResource.nodeCount().applyValue({ args0 -> args0 })
public val project: Output
get() = javaResource.project().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()
})
/**
* The region of the Memcache instance. If it is not provided, the provider region is used.
*/
public val region: Output
get() = javaResource.region().applyValue({ args0 -> args0 })
/**
* Contains the name of allocated IP address ranges associated with the private service access connection for example,
* "test-default" associated with IP range 10.0.0.0/29.
*/
public val reservedIpRangeIds: Output>?
get() = javaResource.reservedIpRangeIds().applyValue({ args0 ->
args0.map({ args0 ->
args0.map({ args0 -> args0 })
}).orElse(null)
})
/**
* Zones where memcache nodes should be provisioned. If not provided, all zones will be used.
*/
public val zones: Output>
get() = javaResource.zones().applyValue({ args0 -> args0.map({ args0 -> args0 }) })
}
public object InstanceMapper : ResourceMapper {
override fun supportsMappingOfType(javaResource: Resource): Boolean =
com.pulumi.gcp.memcache.Instance::class == javaResource::class
override fun map(javaResource: Resource): Instance = Instance(
javaResource as
com.pulumi.gcp.memcache.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()
}