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

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

package com.pulumi.gcp.eventarc.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 [Channel].
 */
@PulumiTagMarker
public class ChannelResourceBuilder internal constructor() {
    public var name: String? = null

    public var args: ChannelArgs = ChannelArgs()

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

/**
 * The Eventarc Channel resource
 * ## Example Usage
 * ### Basic
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 * const testProject = gcp.organizations.getProject({
 *     projectId: "my-project-name",
 * });
 * const testKeyRing = gcp.kms.getKMSKeyRing({
 *     name: "keyring",
 *     location: "us-west1",
 * });
 * const key = testKeyRing.then(testKeyRing => gcp.kms.getKMSCryptoKey({
 *     name: "key",
 *     keyRing: testKeyRing.id,
 * }));
 * const key1Member = new gcp.kms.CryptoKeyIAMMember("key1_member", {
 *     cryptoKeyId: key1.id,
 *     role: "roles/cloudkms.cryptoKeyEncrypterDecrypter",
 *     member: testProject.then(testProject => `serviceAccount:service-${testProject.number}@gcp-sa-eventarc.iam.gserviceaccount.com`),
 * });
 * const primary = new gcp.eventarc.Channel("primary", {
 *     location: "us-west1",
 *     name: "channel",
 *     project: testProject.then(testProject => testProject.projectId),
 *     cryptoKeyName: key1.id,
 *     thirdPartyProvider: testProject.then(testProject => `projects/${testProject.projectId}/locations/us-west1/providers/datadog`),
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_gcp as gcp
 * test_project = gcp.organizations.get_project(project_id="my-project-name")
 * test_key_ring = gcp.kms.get_kms_key_ring(name="keyring",
 *     location="us-west1")
 * key = gcp.kms.get_kms_crypto_key(name="key",
 *     key_ring=test_key_ring.id)
 * key1_member = gcp.kms.CryptoKeyIAMMember("key1_member",
 *     crypto_key_id=key1["id"],
 *     role="roles/cloudkms.cryptoKeyEncrypterDecrypter",
 *     member=f"serviceAccount:service-{test_project.number}@gcp-sa-eventarc.iam.gserviceaccount.com")
 * primary = gcp.eventarc.Channel("primary",
 *     location="us-west1",
 *     name="channel",
 *     project=test_project.project_id,
 *     crypto_key_name=key1["id"],
 *     third_party_provider=f"projects/{test_project.project_id}/locations/us-west1/providers/datadog")
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Gcp = Pulumi.Gcp;
 * return await Deployment.RunAsync(() =>
 * {
 *     var testProject = Gcp.Organizations.GetProject.Invoke(new()
 *     {
 *         ProjectId = "my-project-name",
 *     });
 *     var testKeyRing = Gcp.Kms.GetKMSKeyRing.Invoke(new()
 *     {
 *         Name = "keyring",
 *         Location = "us-west1",
 *     });
 *     var key = Gcp.Kms.GetKMSCryptoKey.Invoke(new()
 *     {
 *         Name = "key",
 *         KeyRing = testKeyRing.Apply(getKMSKeyRingResult => getKMSKeyRingResult.Id),
 *     });
 *     var key1Member = new Gcp.Kms.CryptoKeyIAMMember("key1_member", new()
 *     {
 *         CryptoKeyId = key1.Id,
 *         Role = "roles/cloudkms.cryptoKeyEncrypterDecrypter",
 *         Member = $"serviceAccount:service-{testProject.Apply(getProjectResult => getProjectResult.Number)}@gcp-sa-eventarc.iam.gserviceaccount.com",
 *     });
 *     var primary = new Gcp.Eventarc.Channel("primary", new()
 *     {
 *         Location = "us-west1",
 *         Name = "channel",
 *         Project = testProject.Apply(getProjectResult => getProjectResult.ProjectId),
 *         CryptoKeyName = key1.Id,
 *         ThirdPartyProvider = $"projects/{testProject.Apply(getProjectResult => getProjectResult.ProjectId)}/locations/us-west1/providers/datadog",
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"fmt"
 * 	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/eventarc"
 * 	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/kms"
 * 	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/organizations"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		testProject, err := organizations.LookupProject(ctx, &organizations.LookupProjectArgs{
 * 			ProjectId: pulumi.StringRef("my-project-name"),
 * 		}, nil)
 * 		if err != nil {
 * 			return err
 * 		}
 * 		testKeyRing, err := kms.GetKMSKeyRing(ctx, &kms.GetKMSKeyRingArgs{
 * 			Name:     "keyring",
 * 			Location: "us-west1",
 * 		}, nil)
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = kms.GetKMSCryptoKey(ctx, &kms.GetKMSCryptoKeyArgs{
 * 			Name:    "key",
 * 			KeyRing: testKeyRing.Id,
 * 		}, nil)
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = kms.NewCryptoKeyIAMMember(ctx, "key1_member", &kms.CryptoKeyIAMMemberArgs{
 * 			CryptoKeyId: pulumi.Any(key1.Id),
 * 			Role:        pulumi.String("roles/cloudkms.cryptoKeyEncrypterDecrypter"),
 * 			Member:      pulumi.String(fmt.Sprintf("serviceAccount:service-%[email protected]", testProject.Number)),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = eventarc.NewChannel(ctx, "primary", &eventarc.ChannelArgs{
 * 			Location:           pulumi.String("us-west1"),
 * 			Name:               pulumi.String("channel"),
 * 			Project:            pulumi.String(testProject.ProjectId),
 * 			CryptoKeyName:      pulumi.Any(key1.Id),
 * 			ThirdPartyProvider: pulumi.String(fmt.Sprintf("projects/%v/locations/us-west1/providers/datadog", testProject.ProjectId)),
 * 		})
 * 		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.organizations.OrganizationsFunctions;
 * import com.pulumi.gcp.organizations.inputs.GetProjectArgs;
 * import com.pulumi.gcp.kms.KmsFunctions;
 * import com.pulumi.gcp.kms.inputs.GetKMSKeyRingArgs;
 * import com.pulumi.gcp.kms.inputs.GetKMSCryptoKeyArgs;
 * import com.pulumi.gcp.kms.CryptoKeyIAMMember;
 * import com.pulumi.gcp.kms.CryptoKeyIAMMemberArgs;
 * import com.pulumi.gcp.eventarc.Channel;
 * import com.pulumi.gcp.eventarc.ChannelArgs;
 * 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) {
 *         final var testProject = OrganizationsFunctions.getProject(GetProjectArgs.builder()
 *             .projectId("my-project-name")
 *             .build());
 *         final var testKeyRing = KmsFunctions.getKMSKeyRing(GetKMSKeyRingArgs.builder()
 *             .name("keyring")
 *             .location("us-west1")
 *             .build());
 *         final var key = KmsFunctions.getKMSCryptoKey(GetKMSCryptoKeyArgs.builder()
 *             .name("key")
 *             .keyRing(testKeyRing.applyValue(getKMSKeyRingResult -> getKMSKeyRingResult.id()))
 *             .build());
 *         var key1Member = new CryptoKeyIAMMember("key1Member", CryptoKeyIAMMemberArgs.builder()
 *             .cryptoKeyId(key1.id())
 *             .role("roles/cloudkms.cryptoKeyEncrypterDecrypter")
 *             .member(String.format("serviceAccount:service-%[email protected]", testProject.applyValue(getProjectResult -> getProjectResult.number())))
 *             .build());
 *         var primary = new Channel("primary", ChannelArgs.builder()
 *             .location("us-west1")
 *             .name("channel")
 *             .project(testProject.applyValue(getProjectResult -> getProjectResult.projectId()))
 *             .cryptoKeyName(key1.id())
 *             .thirdPartyProvider(String.format("projects/%s/locations/us-west1/providers/datadog", testProject.applyValue(getProjectResult -> getProjectResult.projectId())))
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   key1Member:
 *     type: gcp:kms:CryptoKeyIAMMember
 *     name: key1_member
 *     properties:
 *       cryptoKeyId: ${key1.id}
 *       role: roles/cloudkms.cryptoKeyEncrypterDecrypter
 *       member: serviceAccount:service-${testProject.number}@gcp-sa-eventarc.iam.gserviceaccount.com
 *   primary:
 *     type: gcp:eventarc:Channel
 *     properties:
 *       location: us-west1
 *       name: channel
 *       project: ${testProject.projectId}
 *       cryptoKeyName: ${key1.id}
 *       thirdPartyProvider: projects/${testProject.projectId}/locations/us-west1/providers/datadog
 * variables:
 *   testProject:
 *     fn::invoke:
 *       Function: gcp:organizations:getProject
 *       Arguments:
 *         projectId: my-project-name
 *   testKeyRing:
 *     fn::invoke:
 *       Function: gcp:kms:getKMSKeyRing
 *       Arguments:
 *         name: keyring
 *         location: us-west1
 *   key:
 *     fn::invoke:
 *       Function: gcp:kms:getKMSCryptoKey
 *       Arguments:
 *         name: key
 *         keyRing: ${testKeyRing.id}
 * ```
 * 
 * ## Import
 * Channel can be imported using any of these accepted formats:
 * * `projects/{{project}}/locations/{{location}}/channels/{{name}}`
 * * `{{project}}/{{location}}/{{name}}`
 * * `{{location}}/{{name}}`
 * When using the `pulumi import` command, Channel can be imported using one of the formats above. For example:
 * ```sh
 * $ pulumi import gcp:eventarc/channel:Channel default projects/{{project}}/locations/{{location}}/channels/{{name}}
 * ```
 * ```sh
 * $ pulumi import gcp:eventarc/channel:Channel default {{project}}/{{location}}/{{name}}
 * ```
 * ```sh
 * $ pulumi import gcp:eventarc/channel:Channel default {{location}}/{{name}}
 * ```
 */
public class Channel internal constructor(
    override val javaResource: com.pulumi.gcp.eventarc.Channel,
) : KotlinCustomResource(javaResource, ChannelMapper) {
    /**
     * Output only. The activation token for the channel. The token must be used by the provider to register the channel for publishing.
     */
    public val activationToken: Output
        get() = javaResource.activationToken().applyValue({ args0 -> args0 })

    /**
     * Output only. The creation time.
     */
    public val createTime: Output
        get() = javaResource.createTime().applyValue({ args0 -> args0 })

    /**
     * Optional. Resource name of a KMS crypto key (managed by the user) used to encrypt/decrypt their event data. It must match the pattern `projects/*/locations/*/keyRings/*/cryptoKeys/*`.
     * */*/*/*/
     */
    public val cryptoKeyName: Output?
        get() = javaResource.cryptoKeyName().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * The location for the resource
     */
    public val location: Output
        get() = javaResource.location().applyValue({ args0 -> args0 })

    /**
     * Required. The resource name of the channel. Must be unique within the location on the project.
     * - - -
     */
    public val name: Output
        get() = javaResource.name().applyValue({ args0 -> args0 })

    /**
     * The project for the resource
     */
    public val project: Output
        get() = javaResource.project().applyValue({ args0 -> args0 })

    /**
     * Output only. The name of the Pub/Sub topic created and managed by Eventarc system as a transport for the event delivery. Format: `projects/{project}/topics/{topic_id}`.
     */
    public val pubsubTopic: Output
        get() = javaResource.pubsubTopic().applyValue({ args0 -> args0 })

    /**
     * Output only. The state of a Channel. Possible values: STATE_UNSPECIFIED, PENDING, ACTIVE, INACTIVE
     */
    public val state: Output
        get() = javaResource.state().applyValue({ args0 -> args0 })

    /**
     * The name of the event provider (e.g. Eventarc SaaS partner) associated with the channel. This provider will be granted permissions to publish events to the channel. Format: `projects/{project}/locations/{location}/providers/{provider_id}`.
     */
    public val thirdPartyProvider: Output?
        get() = javaResource.thirdPartyProvider().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * Output only. Server assigned unique identifier for the channel. The value is a UUID4 string and guaranteed to remain unchanged until the resource is deleted.
     */
    public val uid: Output
        get() = javaResource.uid().applyValue({ args0 -> args0 })

    /**
     * Output only. The last-modified time.
     */
    public val updateTime: Output
        get() = javaResource.updateTime().applyValue({ args0 -> args0 })
}

public object ChannelMapper : ResourceMapper {
    override fun supportsMappingOfType(javaResource: Resource): Boolean =
        com.pulumi.gcp.eventarc.Channel::class == javaResource::class

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

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy