com.pulumi.gcp.servicenetworking.kotlin.Connection.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of pulumi-gcp-kotlin Show documentation
Show all versions of pulumi-gcp-kotlin Show documentation
Build cloud applications and infrastructure by combining the safety and reliability of infrastructure as code with the power of the Kotlin programming language.
@file:Suppress("NAME_SHADOWING", "DEPRECATION")
package com.pulumi.gcp.servicenetworking.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
import kotlin.collections.List
/**
* Builder for [Connection].
*/
@PulumiTagMarker
public class ConnectionResourceBuilder internal constructor() {
public var name: String? = null
public var args: ConnectionArgs = ConnectionArgs()
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 ConnectionArgsBuilder.() -> Unit) {
val builder = ConnectionArgsBuilder()
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(): Connection {
val builtJavaResource = com.pulumi.gcp.servicenetworking.Connection(
this.name,
this.args.toJava(),
this.opts.toJava(),
)
return Connection(builtJavaResource)
}
}
/**
* Manages a private VPC connection with a GCP service provider. For more information see
* [the official documentation](https://cloud.google.com/vpc/docs/configure-private-services-access#creating-connection)
* and
* [API](https://cloud.google.com/service-infrastructure/docs/service-networking/reference/rest/v1/services.connections).
* ## Example Usage
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
* // Create a VPC network
* const peeringNetwork = new gcp.compute.Network("peering_network", {name: "peering-network"});
* // Create an IP address
* const privateIpAlloc = new gcp.compute.GlobalAddress("private_ip_alloc", {
* name: "private-ip-alloc",
* purpose: "VPC_PEERING",
* addressType: "INTERNAL",
* prefixLength: 16,
* network: peeringNetwork.id,
* });
* // Create a private connection
* const _default = new gcp.servicenetworking.Connection("default", {
* network: peeringNetwork.id,
* service: "servicenetworking.googleapis.com",
* reservedPeeringRanges: [privateIpAlloc.name],
* });
* // (Optional) Import or export custom routes
* const peeringRoutes = new gcp.compute.NetworkPeeringRoutesConfig("peering_routes", {
* peering: _default.peering,
* network: peeringNetwork.name,
* importCustomRoutes: true,
* exportCustomRoutes: true,
* });
* ```
* ```python
* import pulumi
* import pulumi_gcp as gcp
* # Create a VPC network
* peering_network = gcp.compute.Network("peering_network", name="peering-network")
* # Create an IP address
* private_ip_alloc = gcp.compute.GlobalAddress("private_ip_alloc",
* name="private-ip-alloc",
* purpose="VPC_PEERING",
* address_type="INTERNAL",
* prefix_length=16,
* network=peering_network.id)
* # Create a private connection
* default = gcp.servicenetworking.Connection("default",
* network=peering_network.id,
* service="servicenetworking.googleapis.com",
* reserved_peering_ranges=[private_ip_alloc.name])
* # (Optional) Import or export custom routes
* peering_routes = gcp.compute.NetworkPeeringRoutesConfig("peering_routes",
* peering=default.peering,
* network=peering_network.name,
* import_custom_routes=True,
* export_custom_routes=True)
* ```
* ```csharp
* using System.Collections.Generic;
* using System.Linq;
* using Pulumi;
* using Gcp = Pulumi.Gcp;
* return await Deployment.RunAsync(() =>
* {
* // Create a VPC network
* var peeringNetwork = new Gcp.Compute.Network("peering_network", new()
* {
* Name = "peering-network",
* });
* // Create an IP address
* var privateIpAlloc = new Gcp.Compute.GlobalAddress("private_ip_alloc", new()
* {
* Name = "private-ip-alloc",
* Purpose = "VPC_PEERING",
* AddressType = "INTERNAL",
* PrefixLength = 16,
* Network = peeringNetwork.Id,
* });
* // Create a private connection
* var @default = new Gcp.ServiceNetworking.Connection("default", new()
* {
* Network = peeringNetwork.Id,
* Service = "servicenetworking.googleapis.com",
* ReservedPeeringRanges = new[]
* {
* privateIpAlloc.Name,
* },
* });
* // (Optional) Import or export custom routes
* var peeringRoutes = new Gcp.Compute.NetworkPeeringRoutesConfig("peering_routes", new()
* {
* Peering = @default.Peering,
* Network = peeringNetwork.Name,
* ImportCustomRoutes = true,
* ExportCustomRoutes = true,
* });
* });
* ```
* ```go
* package main
* import (
* "github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/compute"
* "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 {
* // Create a VPC network
* peeringNetwork, err := compute.NewNetwork(ctx, "peering_network", &compute.NetworkArgs{
* Name: pulumi.String("peering-network"),
* })
* if err != nil {
* return err
* }
* // Create an IP address
* privateIpAlloc, err := compute.NewGlobalAddress(ctx, "private_ip_alloc", &compute.GlobalAddressArgs{
* Name: pulumi.String("private-ip-alloc"),
* Purpose: pulumi.String("VPC_PEERING"),
* AddressType: pulumi.String("INTERNAL"),
* PrefixLength: pulumi.Int(16),
* Network: peeringNetwork.ID(),
* })
* if err != nil {
* return err
* }
* // Create a private connection
* _, err = servicenetworking.NewConnection(ctx, "default", &servicenetworking.ConnectionArgs{
* Network: peeringNetwork.ID(),
* Service: pulumi.String("servicenetworking.googleapis.com"),
* ReservedPeeringRanges: pulumi.StringArray{
* privateIpAlloc.Name,
* },
* })
* if err != nil {
* return err
* }
* // (Optional) Import or export custom routes
* _, err = compute.NewNetworkPeeringRoutesConfig(ctx, "peering_routes", &compute.NetworkPeeringRoutesConfigArgs{
* Peering: _default.Peering,
* Network: peeringNetwork.Name,
* ImportCustomRoutes: pulumi.Bool(true),
* ExportCustomRoutes: pulumi.Bool(true),
* })
* 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.compute.NetworkPeeringRoutesConfig;
* import com.pulumi.gcp.compute.NetworkPeeringRoutesConfigArgs;
* 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) {
* // Create a VPC network
* var peeringNetwork = new Network("peeringNetwork", NetworkArgs.builder()
* .name("peering-network")
* .build());
* // Create an IP address
* var privateIpAlloc = new GlobalAddress("privateIpAlloc", GlobalAddressArgs.builder()
* .name("private-ip-alloc")
* .purpose("VPC_PEERING")
* .addressType("INTERNAL")
* .prefixLength(16)
* .network(peeringNetwork.id())
* .build());
* // Create a private connection
* var default_ = new Connection("default", ConnectionArgs.builder()
* .network(peeringNetwork.id())
* .service("servicenetworking.googleapis.com")
* .reservedPeeringRanges(privateIpAlloc.name())
* .build());
* // (Optional) Import or export custom routes
* var peeringRoutes = new NetworkPeeringRoutesConfig("peeringRoutes", NetworkPeeringRoutesConfigArgs.builder()
* .peering(default_.peering())
* .network(peeringNetwork.name())
* .importCustomRoutes(true)
* .exportCustomRoutes(true)
* .build());
* }
* }
* ```
* ```yaml
* resources:
* # Create a VPC network
* peeringNetwork:
* type: gcp:compute:Network
* name: peering_network
* properties:
* name: peering-network
* # Create an IP address
* privateIpAlloc:
* type: gcp:compute:GlobalAddress
* name: private_ip_alloc
* properties:
* name: private-ip-alloc
* purpose: VPC_PEERING
* addressType: INTERNAL
* prefixLength: 16
* network: ${peeringNetwork.id}
* # Create a private connection
* default:
* type: gcp:servicenetworking:Connection
* properties:
* network: ${peeringNetwork.id}
* service: servicenetworking.googleapis.com
* reservedPeeringRanges:
* - ${privateIpAlloc.name}
* # (Optional) Import or export custom routes
* peeringRoutes:
* type: gcp:compute:NetworkPeeringRoutesConfig
* name: peering_routes
* properties:
* peering: ${default.peering}
* network: ${peeringNetwork.name}
* importCustomRoutes: true
* exportCustomRoutes: true
* ```
*
* ## Import
* ServiceNetworkingConnection can be imported using any of these accepted formats
* * `{{peering-network}}:{{service}}`
* * `projects/{{project}}/global/networks/{{peering-network}}:{{service}}`
* When using the `pulumi import` command, NAME_HERE can be imported using one of the formats above. For example:
* ```sh
* $ pulumi import gcp:servicenetworking/connection:Connection default {{peering-network}}:{{service}}
* ```
* ```sh
* $ pulumi import gcp:servicenetworking/connection:Connection default /projects/{{project}}/global/networks/{{peering-network}}:{{service}}
* ```
*/
public class Connection internal constructor(
override val javaResource: com.pulumi.gcp.servicenetworking.Connection,
) : KotlinCustomResource(javaResource, ConnectionMapper) {
public val deletionPolicy: Output?
get() = javaResource.deletionPolicy().applyValue({ args0 ->
args0.map({ args0 ->
args0
}).orElse(null)
})
/**
* Name of VPC network connected with service producers using VPC peering.
*/
public val network: Output
get() = javaResource.network().applyValue({ args0 -> args0 })
/**
* (Computed) The name of the VPC Network Peering connection that was created by the service producer.
*/
public val peering: Output
get() = javaResource.peering().applyValue({ args0 -> args0 })
/**
* Named IP address range(s) of PEERING type reserved for
* this service provider. Note that invoking this method with a different range when connection
* is already established will not reallocate already provisioned service producer subnetworks.
*/
public val reservedPeeringRanges: Output>
get() = javaResource.reservedPeeringRanges().applyValue({ args0 -> args0.map({ args0 -> args0 }) })
/**
* Provider peering service that is managing peering connectivity for a
* service provider organization. For Google services that support this functionality it is
* 'servicenetworking.googleapis.com'.
*/
public val service: Output
get() = javaResource.service().applyValue({ args0 -> args0 })
}
public object ConnectionMapper : ResourceMapper {
override fun supportsMappingOfType(javaResource: Resource): Boolean =
com.pulumi.gcp.servicenetworking.Connection::class == javaResource::class
override fun map(javaResource: Resource): Connection = Connection(
javaResource as
com.pulumi.gcp.servicenetworking.Connection,
)
}
/**
* @see [Connection].
* @param name The _unique_ name of the resulting resource.
* @param block Builder for [Connection].
*/
public suspend fun connection(name: String, block: suspend ConnectionResourceBuilder.() -> Unit): Connection {
val builder = ConnectionResourceBuilder()
builder.name(name)
block(builder)
return builder.build()
}
/**
* @see [Connection].
* @param name The _unique_ name of the resulting resource.
*/
public fun connection(name: String): Connection {
val builder = ConnectionResourceBuilder()
builder.name(name)
return builder.build()
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy