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

com.pulumi.gcp.logging.kotlin.OrganizationSink.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.logging.kotlin

import com.pulumi.core.Output
import com.pulumi.gcp.logging.kotlin.outputs.OrganizationSinkBigqueryOptions
import com.pulumi.gcp.logging.kotlin.outputs.OrganizationSinkExclusion
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
import com.pulumi.gcp.logging.kotlin.outputs.OrganizationSinkBigqueryOptions.Companion.toKotlin as organizationSinkBigqueryOptionsToKotlin
import com.pulumi.gcp.logging.kotlin.outputs.OrganizationSinkExclusion.Companion.toKotlin as organizationSinkExclusionToKotlin

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

    public var args: OrganizationSinkArgs = OrganizationSinkArgs()

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

/**
 * Manages a organization-level logging sink. For more information see:
 * * [API documentation](https://cloud.google.com/logging/docs/reference/v2/rest/v2/organizations.sinks)
 * * How-to Guides
 *     * [Exporting Logs](https://cloud.google.com/logging/docs/export)
 * ## Example Usage
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 * const log_bucket = new gcp.storage.Bucket("log-bucket", {
 *     name: "organization-logging-bucket",
 *     location: "US",
 * });
 * const my_sink = new gcp.logging.OrganizationSink("my-sink", {
 *     name: "my-sink",
 *     description: "some explanation on what this is",
 *     orgId: "123456789",
 *     destination: pulumi.interpolate`storage.googleapis.com/${log_bucket.name}`,
 *     filter: "resource.type = gce_instance AND severity >= WARNING",
 * });
 * const log_writer = new gcp.projects.IAMMember("log-writer", {
 *     project: "your-project-id",
 *     role: "roles/storage.objectCreator",
 *     member: my_sink.writerIdentity,
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_gcp as gcp
 * log_bucket = gcp.storage.Bucket("log-bucket",
 *     name="organization-logging-bucket",
 *     location="US")
 * my_sink = gcp.logging.OrganizationSink("my-sink",
 *     name="my-sink",
 *     description="some explanation on what this is",
 *     org_id="123456789",
 *     destination=log_bucket.name.apply(lambda name: f"storage.googleapis.com/{name}"),
 *     filter="resource.type = gce_instance AND severity >= WARNING")
 * log_writer = gcp.projects.IAMMember("log-writer",
 *     project="your-project-id",
 *     role="roles/storage.objectCreator",
 *     member=my_sink.writer_identity)
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Gcp = Pulumi.Gcp;
 * return await Deployment.RunAsync(() =>
 * {
 *     var log_bucket = new Gcp.Storage.Bucket("log-bucket", new()
 *     {
 *         Name = "organization-logging-bucket",
 *         Location = "US",
 *     });
 *     var my_sink = new Gcp.Logging.OrganizationSink("my-sink", new()
 *     {
 *         Name = "my-sink",
 *         Description = "some explanation on what this is",
 *         OrgId = "123456789",
 *         Destination = log_bucket.Name.Apply(name => $"storage.googleapis.com/{name}"),
 *         Filter = "resource.type = gce_instance AND severity >= WARNING",
 *     });
 *     var log_writer = new Gcp.Projects.IAMMember("log-writer", new()
 *     {
 *         Project = "your-project-id",
 *         Role = "roles/storage.objectCreator",
 *         Member = my_sink.WriterIdentity,
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"fmt"
 * 	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/logging"
 * 	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/projects"
 * 	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/storage"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		_, err := storage.NewBucket(ctx, "log-bucket", &storage.BucketArgs{
 * 			Name:     pulumi.String("organization-logging-bucket"),
 * 			Location: pulumi.String("US"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = logging.NewOrganizationSink(ctx, "my-sink", &logging.OrganizationSinkArgs{
 * 			Name:        pulumi.String("my-sink"),
 * 			Description: pulumi.String("some explanation on what this is"),
 * 			OrgId:       pulumi.String("123456789"),
 * 			Destination: log_bucket.Name.ApplyT(func(name string) (string, error) {
 * 				return fmt.Sprintf("storage.googleapis.com/%v", name), nil
 * 			}).(pulumi.StringOutput),
 * 			Filter: pulumi.String("resource.type = gce_instance AND severity >= WARNING"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = projects.NewIAMMember(ctx, "log-writer", &projects.IAMMemberArgs{
 * 			Project: pulumi.String("your-project-id"),
 * 			Role:    pulumi.String("roles/storage.objectCreator"),
 * 			Member:  my_sink.WriterIdentity,
 * 		})
 * 		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.storage.Bucket;
 * import com.pulumi.gcp.storage.BucketArgs;
 * import com.pulumi.gcp.logging.OrganizationSink;
 * import com.pulumi.gcp.logging.OrganizationSinkArgs;
 * import com.pulumi.gcp.projects.IAMMember;
 * import com.pulumi.gcp.projects.IAMMemberArgs;
 * 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 log_bucket = new Bucket("log-bucket", BucketArgs.builder()
 *             .name("organization-logging-bucket")
 *             .location("US")
 *             .build());
 *         var my_sink = new OrganizationSink("my-sink", OrganizationSinkArgs.builder()
 *             .name("my-sink")
 *             .description("some explanation on what this is")
 *             .orgId("123456789")
 *             .destination(log_bucket.name().applyValue(name -> String.format("storage.googleapis.com/%s", name)))
 *             .filter("resource.type = gce_instance AND severity >= WARNING")
 *             .build());
 *         var log_writer = new IAMMember("log-writer", IAMMemberArgs.builder()
 *             .project("your-project-id")
 *             .role("roles/storage.objectCreator")
 *             .member(my_sink.writerIdentity())
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   my-sink:
 *     type: gcp:logging:OrganizationSink
 *     properties:
 *       name: my-sink
 *       description: some explanation on what this is
 *       orgId: '123456789'
 *       destination: storage.googleapis.com/${["log-bucket"].name}
 *       filter: resource.type = gce_instance AND severity >= WARNING
 *   log-bucket:
 *     type: gcp:storage:Bucket
 *     properties:
 *       name: organization-logging-bucket
 *       location: US
 *   log-writer:
 *     type: gcp:projects:IAMMember
 *     properties:
 *       project: your-project-id
 *       role: roles/storage.objectCreator
 *       member: ${["my-sink"].writerIdentity}
 * ```
 * 
 * ## Import
 * Organization-level logging sinks can be imported using this format:
 * * `organizations/{{organization_id}}/sinks/{{sink_id}}`
 * When using the `pulumi import` command, organization-level logging sinks can be imported using one of the formats above. For example:
 * ```sh
 * $ pulumi import gcp:logging/organizationSink:OrganizationSink default organizations/{{organization_id}}/sinks/{{sink_id}}
 * ```
 */
public class OrganizationSink internal constructor(
    override val javaResource: com.pulumi.gcp.logging.OrganizationSink,
) : KotlinCustomResource(javaResource, OrganizationSinkMapper) {
    /**
     * Options that affect sinks exporting data to BigQuery. Structure documented below.
     */
    public val bigqueryOptions: Output
        get() = javaResource.bigqueryOptions().applyValue({ args0 ->
            args0.let({ args0 ->
                organizationSinkBigqueryOptionsToKotlin(args0)
            })
        })

    /**
     * A description of this sink. The maximum length of the description is 8000 characters.
     */
    public val description: Output?
        get() = javaResource.description().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * The destination of the sink (or, in other words, where logs are written to). Can be a Cloud Storage bucket, a PubSub topic, a BigQuery dataset, a Cloud Logging bucket, or a Google Cloud project. Examples:
     * - `storage.googleapis.com/[GCS_BUCKET]`
     * - `bigquery.googleapis.com/projects/[PROJECT_ID]/datasets/[DATASET]`
     * - `pubsub.googleapis.com/projects/[PROJECT_ID]/topics/[TOPIC_ID]`
     * - `logging.googleapis.com/projects/[PROJECT_ID]/locations/global/buckets/[BUCKET_ID]`
     * - `logging.googleapis.com/projects/[PROJECT_ID]`
     * The writer associated with the sink must have access to write to the above resource.
     */
    public val destination: Output
        get() = javaResource.destination().applyValue({ args0 -> args0 })

    /**
     * If set to True, then this sink is disabled and it does not export any log entries.
     */
    public val disabled: Output?
        get() = javaResource.disabled().applyValue({ args0 -> args0.map({ args0 -> args0 }).orElse(null) })

    /**
     * Log entries that match any of the exclusion filters will not be exported. If a log entry is matched by both `filter` and one of `exclusions.filter`, it will not be exported.  Can be repeated multiple times for multiple exclusions. Structure is documented below.
     */
    public val exclusions: Output>?
        get() = javaResource.exclusions().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.map({ args0 ->
                    args0.let({ args0 -> organizationSinkExclusionToKotlin(args0) })
                })
            }).orElse(null)
        })

    /**
     * The filter to apply when exporting logs. Only log entries that match the filter are exported.
     * See [Advanced Log Filters](https://cloud.google.com/logging/docs/view/advanced_filters) for information on how to
     * write a filter.
     */
    public val filter: Output?
        get() = javaResource.filter().applyValue({ args0 -> args0.map({ args0 -> args0 }).orElse(null) })

    /**
     * Whether or not to include children organizations in the sink export. If true, logs
     * associated with child projects are also exported; otherwise only logs relating to the provided organization are included.
     */
    public val includeChildren: Output?
        get() = javaResource.includeChildren().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * Whether or not to intercept logs from child projects. If true, matching logs will not match with sinks in child
     * resources, except _Required sinks. This sink will be visible to child resources when listing sinks.
     */
    public val interceptChildren: Output?
        get() = javaResource.interceptChildren().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

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

    /**
     * The numeric ID of the organization to be exported to the sink.
     */
    public val orgId: Output
        get() = javaResource.orgId().applyValue({ args0 -> args0 })

    /**
     * The identity associated with this sink. This identity must be granted write access to the
     * configured `destination`.
     */
    public val writerIdentity: Output
        get() = javaResource.writerIdentity().applyValue({ args0 -> args0 })
}

public object OrganizationSinkMapper : ResourceMapper {
    override fun supportsMappingOfType(javaResource: Resource): Boolean =
        com.pulumi.gcp.logging.OrganizationSink::class == javaResource::class

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

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy