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

com.pulumi.vault.secrets.kotlin.SyncGcpDestination.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: 6.4.0.0
Show newest version
@file:Suppress("NAME_SHADOWING", "DEPRECATION")

package com.pulumi.vault.secrets.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.Any
import kotlin.Boolean
import kotlin.String
import kotlin.Suppress
import kotlin.Unit
import kotlin.collections.Map

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

    public var args: SyncGcpDestinationArgs = SyncGcpDestinationArgs()

    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 SyncGcpDestinationArgsBuilder.() -> Unit) {
        val builder = SyncGcpDestinationArgsBuilder()
        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(): SyncGcpDestination {
        val builtJavaResource = com.pulumi.vault.secrets.SyncGcpDestination(
            this.name,
            this.args.toJava(),
            this.opts.toJava(),
        )
        return SyncGcpDestination(builtJavaResource)
    }
}

/**
 * ## Example Usage
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as std from "@pulumi/std";
 * import * as vault from "@pulumi/vault";
 * const gcp = new vault.secrets.SyncGcpDestination("gcp", {
 *     name: "gcp-dest",
 *     projectId: "gcp-project-id",
 *     credentials: std.file({
 *         input: credentialsFile,
 *     }).then(invoke => invoke.result),
 *     secretNameTemplate: "vault_{{ .MountAccessor | lowercase }}_{{ .SecretPath | lowercase }}",
 *     customTags: {
 *         foo: "bar",
 *     },
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_std as std
 * import pulumi_vault as vault
 * gcp = vault.secrets.SyncGcpDestination("gcp",
 *     name="gcp-dest",
 *     project_id="gcp-project-id",
 *     credentials=std.file(input=credentials_file).result,
 *     secret_name_template="vault_{{ .MountAccessor | lowercase }}_{{ .SecretPath | lowercase }}",
 *     custom_tags={
 *         "foo": "bar",
 *     })
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Std = Pulumi.Std;
 * using Vault = Pulumi.Vault;
 * return await Deployment.RunAsync(() =>
 * {
 *     var gcp = new Vault.Secrets.SyncGcpDestination("gcp", new()
 *     {
 *         Name = "gcp-dest",
 *         ProjectId = "gcp-project-id",
 *         Credentials = Std.File.Invoke(new()
 *         {
 *             Input = credentialsFile,
 *         }).Apply(invoke => invoke.Result),
 *         SecretNameTemplate = "vault_{{ .MountAccessor | lowercase }}_{{ .SecretPath | lowercase }}",
 *         CustomTags =
 *         {
 *             { "foo", "bar" },
 *         },
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-std/sdk/go/std"
 * 	"github.com/pulumi/pulumi-vault/sdk/v6/go/vault/secrets"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		invokeFile, err := std.File(ctx, &std.FileArgs{
 * 			Input: credentialsFile,
 * 		}, nil)
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = secrets.NewSyncGcpDestination(ctx, "gcp", &secrets.SyncGcpDestinationArgs{
 * 			Name:               pulumi.String("gcp-dest"),
 * 			ProjectId:          pulumi.String("gcp-project-id"),
 * 			Credentials:        pulumi.String(invokeFile.Result),
 * 			SecretNameTemplate: pulumi.String("vault_{{ .MountAccessor | lowercase }}_{{ .SecretPath | lowercase }}"),
 * 			CustomTags: pulumi.Map{
 * 				"foo": pulumi.Any("bar"),
 * 			},
 * 		})
 * 		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.vault.secrets.SyncGcpDestination;
 * import com.pulumi.vault.secrets.SyncGcpDestinationArgs;
 * 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 gcp = new SyncGcpDestination("gcp", SyncGcpDestinationArgs.builder()
 *             .name("gcp-dest")
 *             .projectId("gcp-project-id")
 *             .credentials(StdFunctions.file(FileArgs.builder()
 *                 .input(credentialsFile)
 *                 .build()).result())
 *             .secretNameTemplate("vault_{{ .MountAccessor | lowercase }}_{{ .SecretPath | lowercase }}")
 *             .customTags(Map.of("foo", "bar"))
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   gcp:
 *     type: vault:secrets:SyncGcpDestination
 *     properties:
 *       name: gcp-dest
 *       projectId: gcp-project-id
 *       credentials:
 *         fn::invoke:
 *           Function: std:file
 *           Arguments:
 *             input: ${credentialsFile}
 *           Return: result
 *       secretNameTemplate: vault_{{ .MountAccessor | lowercase }}_{{ .SecretPath | lowercase }}
 *       customTags:
 *         foo: bar
 * ```
 * 
 * ## Import
 * GCP Secrets sync destinations can be imported using the `name`, e.g.
 * ```sh
 * $ pulumi import vault:secrets/syncGcpDestination:SyncGcpDestination gcp gcp-dest
 * ```
 */
public class SyncGcpDestination internal constructor(
    override val javaResource: com.pulumi.vault.secrets.SyncGcpDestination,
) : KotlinCustomResource(javaResource, SyncGcpDestinationMapper) {
    /**
     * JSON-encoded credentials to use to connect to GCP.
     * Can be omitted and directly provided to Vault using the `GOOGLE_APPLICATION_CREDENTIALS` environment
     * variable.
     */
    public val credentials: Output?
        get() = javaResource.credentials().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * Custom tags to set on the secret managed at the destination.
     */
    public val customTags: Output>?
        get() = javaResource.customTags().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.map({ args0 ->
                    args0.key.to(args0.value)
                }).toMap()
            }).orElse(null)
        })

    /**
     * Determines what level of information is synced as a distinct resource
     * at the destination. Supports `secret-path` and `secret-key`.
     */
    public val granularity: Output?
        get() = javaResource.granularity().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * Unique name of the GCP destination.
     */
    public val name: Output
        get() = javaResource.name().applyValue({ args0 -> args0 })

    /**
     * The namespace to provision the resource in.
     * The value should not contain leading or trailing forward slashes.
     * The `namespace` is always relative to the provider's configured [namespace](https://www.terraform.io/docs/providers/vault/index.html#namespace).
     */
    public val namespace: Output?
        get() = javaResource.namespace().applyValue({ args0 -> args0.map({ args0 -> args0 }).orElse(null) })

    /**
     * The target project to manage secrets in. If set,
     * overrides the project ID derived from the service account JSON credentials or application
     * default credentials. The service account must be [authorized](https://cloud.google.com/iam/docs/service-account-overview#locations)
     * to perform Secret Manager actions in the target project.
     */
    public val projectId: Output?
        get() = javaResource.projectId().applyValue({ args0 -> args0.map({ args0 -> args0 }).orElse(null) })

    /**
     * Template describing how to generate external secret names.
     * Supports a subset of the Go Template syntax.
     */
    public val secretNameTemplate: Output
        get() = javaResource.secretNameTemplate().applyValue({ args0 -> args0 })

    /**
     * The type of the secrets destination (`gcp-sm`).
     */
    public val type: Output
        get() = javaResource.type().applyValue({ args0 -> args0 })
}

public object SyncGcpDestinationMapper : ResourceMapper {
    override fun supportsMappingOfType(javaResource: Resource): Boolean =
        com.pulumi.vault.secrets.SyncGcpDestination::class == javaResource::class

    override fun map(javaResource: Resource): SyncGcpDestination = SyncGcpDestination(
        javaResource as
            com.pulumi.vault.secrets.SyncGcpDestination,
    )
}

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

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




© 2015 - 2025 Weber Informatics LLC | Privacy Policy