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

com.pulumi.gcp.logging.kotlin.FolderSettings.kt Maven / Gradle / Ivy

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

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

    public var args: FolderSettingsArgs = FolderSettingsArgs()

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

/**
 * Default resource settings control whether CMEK is required for new log buckets. These settings also determine the storage location for the _Default and _Required log buckets, and whether the _Default sink is enabled or disabled.
 * To get more information about FolderSettings, see:
 * * [API documentation](https://cloud.google.com/logging/docs/reference/v2/rest/v2/TopLevel/getSettings)
 * * How-to Guides
 *     * [Configure default settings for organizations and folders](https://cloud.google.com/logging/docs/default-settings)
 * ## Example Usage
 * ### Logging Folder Settings All
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 * const myFolder = new gcp.organizations.Folder("my_folder", {
 *     displayName: "folder-name",
 *     parent: "organizations/123456789",
 * });
 * const settings = gcp.logging.getFolderSettingsOutput({
 *     folder: myFolder.folderId,
 * });
 * const iam = new gcp.kms.CryptoKeyIAMMember("iam", {
 *     cryptoKeyId: "kms-key",
 *     role: "roles/cloudkms.cryptoKeyEncrypterDecrypter",
 *     member: settings.apply(settings => `serviceAccount:${settings.kmsServiceAccountId}`),
 * });
 * const example = new gcp.logging.FolderSettings("example", {
 *     disableDefaultSink: true,
 *     folder: myFolder.folderId,
 *     kmsKeyName: "kms-key",
 *     storageLocation: "us-central1",
 * }, {
 *     dependsOn: [iam],
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_gcp as gcp
 * my_folder = gcp.organizations.Folder("my_folder",
 *     display_name="folder-name",
 *     parent="organizations/123456789")
 * settings = gcp.logging.get_folder_settings_output(folder=my_folder.folder_id)
 * iam = gcp.kms.CryptoKeyIAMMember("iam",
 *     crypto_key_id="kms-key",
 *     role="roles/cloudkms.cryptoKeyEncrypterDecrypter",
 *     member=settings.apply(lambda settings: f"serviceAccount:{settings.kms_service_account_id}"))
 * example = gcp.logging.FolderSettings("example",
 *     disable_default_sink=True,
 *     folder=my_folder.folder_id,
 *     kms_key_name="kms-key",
 *     storage_location="us-central1",
 *     opts = pulumi.ResourceOptions(depends_on=[iam]))
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Gcp = Pulumi.Gcp;
 * return await Deployment.RunAsync(() =>
 * {
 *     var myFolder = new Gcp.Organizations.Folder("my_folder", new()
 *     {
 *         DisplayName = "folder-name",
 *         Parent = "organizations/123456789",
 *     });
 *     var settings = Gcp.Logging.GetFolderSettings.Invoke(new()
 *     {
 *         Folder = myFolder.FolderId,
 *     });
 *     var iam = new Gcp.Kms.CryptoKeyIAMMember("iam", new()
 *     {
 *         CryptoKeyId = "kms-key",
 *         Role = "roles/cloudkms.cryptoKeyEncrypterDecrypter",
 *         Member = $"serviceAccount:{settings.Apply(getFolderSettingsResult => getFolderSettingsResult.KmsServiceAccountId)}",
 *     });
 *     var example = new Gcp.Logging.FolderSettings("example", new()
 *     {
 *         DisableDefaultSink = true,
 *         Folder = myFolder.FolderId,
 *         KmsKeyName = "kms-key",
 *         StorageLocation = "us-central1",
 *     }, new CustomResourceOptions
 *     {
 *         DependsOn =
 *         {
 *             iam,
 *         },
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"fmt"
 * 	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/kms"
 * 	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/logging"
 * 	"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 {
 * 		myFolder, err := organizations.NewFolder(ctx, "my_folder", &organizations.FolderArgs{
 * 			DisplayName: pulumi.String("folder-name"),
 * 			Parent:      pulumi.String("organizations/123456789"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		settings := logging.LookupFolderSettingsOutput(ctx, logging.GetFolderSettingsOutputArgs{
 * 			Folder: myFolder.FolderId,
 * 		}, nil)
 * 		iam, err := kms.NewCryptoKeyIAMMember(ctx, "iam", &kms.CryptoKeyIAMMemberArgs{
 * 			CryptoKeyId: pulumi.String("kms-key"),
 * 			Role:        pulumi.String("roles/cloudkms.cryptoKeyEncrypterDecrypter"),
 * 			Member: settings.ApplyT(func(settings logging.GetFolderSettingsResult) (string, error) {
 * 				return fmt.Sprintf("serviceAccount:%v", settings.KmsServiceAccountId), nil
 * 			}).(pulumi.StringOutput),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = logging.NewFolderSettings(ctx, "example", &logging.FolderSettingsArgs{
 * 			DisableDefaultSink: pulumi.Bool(true),
 * 			Folder:             myFolder.FolderId,
 * 			KmsKeyName:         pulumi.String("kms-key"),
 * 			StorageLocation:    pulumi.String("us-central1"),
 * 		}, pulumi.DependsOn([]pulumi.Resource{
 * 			iam,
 * 		}))
 * 		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.Folder;
 * import com.pulumi.gcp.organizations.FolderArgs;
 * import com.pulumi.gcp.logging.LoggingFunctions;
 * import com.pulumi.gcp.logging.inputs.GetFolderSettingsArgs;
 * import com.pulumi.gcp.kms.CryptoKeyIAMMember;
 * import com.pulumi.gcp.kms.CryptoKeyIAMMemberArgs;
 * import com.pulumi.gcp.logging.FolderSettings;
 * import com.pulumi.gcp.logging.FolderSettingsArgs;
 * import com.pulumi.resources.CustomResourceOptions;
 * 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 myFolder = new Folder("myFolder", FolderArgs.builder()
 *             .displayName("folder-name")
 *             .parent("organizations/123456789")
 *             .build());
 *         final var settings = LoggingFunctions.getFolderSettings(GetFolderSettingsArgs.builder()
 *             .folder(myFolder.folderId())
 *             .build());
 *         var iam = new CryptoKeyIAMMember("iam", CryptoKeyIAMMemberArgs.builder()
 *             .cryptoKeyId("kms-key")
 *             .role("roles/cloudkms.cryptoKeyEncrypterDecrypter")
 *             .member(settings.applyValue(getFolderSettingsResult -> getFolderSettingsResult).applyValue(settings -> String.format("serviceAccount:%s", settings.applyValue(getFolderSettingsResult -> getFolderSettingsResult.kmsServiceAccountId()))))
 *             .build());
 *         var example = new FolderSettings("example", FolderSettingsArgs.builder()
 *             .disableDefaultSink(true)
 *             .folder(myFolder.folderId())
 *             .kmsKeyName("kms-key")
 *             .storageLocation("us-central1")
 *             .build(), CustomResourceOptions.builder()
 *                 .dependsOn(iam)
 *                 .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   example:
 *     type: gcp:logging:FolderSettings
 *     properties:
 *       disableDefaultSink: true
 *       folder: ${myFolder.folderId}
 *       kmsKeyName: kms-key
 *       storageLocation: us-central1
 *     options:
 *       dependson:
 *         - ${iam}
 *   myFolder:
 *     type: gcp:organizations:Folder
 *     name: my_folder
 *     properties:
 *       displayName: folder-name
 *       parent: organizations/123456789
 *   iam:
 *     type: gcp:kms:CryptoKeyIAMMember
 *     properties:
 *       cryptoKeyId: kms-key
 *       role: roles/cloudkms.cryptoKeyEncrypterDecrypter
 *       member: serviceAccount:${settings.kmsServiceAccountId}
 * variables:
 *   settings:
 *     fn::invoke:
 *       Function: gcp:logging:getFolderSettings
 *       Arguments:
 *         folder: ${myFolder.folderId}
 * ```
 * 
 * ## Import
 * FolderSettings can be imported using any of these accepted formats:
 * * `folders/{{folder}}/settings`
 * * `{{folder}}`
 * When using the `pulumi import` command, FolderSettings can be imported using one of the formats above. For example:
 * ```sh
 * $ pulumi import gcp:logging/folderSettings:FolderSettings default folders/{{folder}}/settings
 * ```
 * ```sh
 * $ pulumi import gcp:logging/folderSettings:FolderSettings default {{folder}}
 * ```
 */
public class FolderSettings internal constructor(
    override val javaResource: com.pulumi.gcp.logging.FolderSettings,
) : KotlinCustomResource(javaResource, FolderSettingsMapper) {
    /**
     * If set to true, the _Default sink in newly created projects and folders will created in a disabled state. This can be used to automatically disable log storage if there is already an aggregated sink configured in the hierarchy. The _Default sink can be re-enabled manually if needed.
     */
    public val disableDefaultSink: Output
        get() = javaResource.disableDefaultSink().applyValue({ args0 -> args0 })

    /**
     * The folder for which to retrieve settings.
     * - - -
     */
    public val folder: Output
        get() = javaResource.folder().applyValue({ args0 -> args0 })

    /**
     * The resource name for the configured Cloud KMS key.
     */
    public val kmsKeyName: Output
        get() = javaResource.kmsKeyName().applyValue({ args0 -> args0 })

    /**
     * The service account that will be used by the Log Router to access your Cloud KMS key.
     */
    public val kmsServiceAccountId: Output
        get() = javaResource.kmsServiceAccountId().applyValue({ args0 -> args0 })

    /**
     * The service account for the given container. Sinks use this service account as their writerIdentity if no custom service account is provided.
     */
    public val loggingServiceAccountId: Output
        get() = javaResource.loggingServiceAccountId().applyValue({ args0 -> args0 })

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

    /**
     * The storage location that Cloud Logging will use to create new resources when a location is needed but not explicitly provided.
     */
    public val storageLocation: Output
        get() = javaResource.storageLocation().applyValue({ args0 -> args0 })
}

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

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

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy