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

com.pulumi.gcp.storage.kotlin.HmacKey.kt Maven / Gradle / Ivy

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

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

    public var args: HmacKeyArgs = HmacKeyArgs()

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

/**
 * The hmacKeys resource represents an HMAC key within Cloud Storage. The resource
 * consists of a secret and HMAC key metadata. HMAC keys can be used as credentials
 * for service accounts.
 * To get more information about HmacKey, see:
 * * [API documentation](https://cloud.google.com/storage/docs/json_api/v1/projects/hmacKeys)
 * * How-to Guides
 *     * [Official Documentation](https://cloud.google.com/storage/docs/authentication/managing-hmackeys)
 * ## Example Usage
 * ### Storage Hmac Key
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 * // Create a new service account
 * const serviceAccount = new gcp.serviceaccount.Account("service_account", {accountId: "my-svc-acc"});
 * //Create the HMAC key for the associated service account
 * const key = new gcp.storage.HmacKey("key", {serviceAccountEmail: serviceAccount.email});
 * ```
 * ```python
 * import pulumi
 * import pulumi_gcp as gcp
 * # Create a new service account
 * service_account = gcp.serviceaccount.Account("service_account", account_id="my-svc-acc")
 * #Create the HMAC key for the associated service account
 * key = gcp.storage.HmacKey("key", service_account_email=service_account.email)
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Gcp = Pulumi.Gcp;
 * return await Deployment.RunAsync(() =>
 * {
 *     // Create a new service account
 *     var serviceAccount = new Gcp.ServiceAccount.Account("service_account", new()
 *     {
 *         AccountId = "my-svc-acc",
 *     });
 *     //Create the HMAC key for the associated service account
 *     var key = new Gcp.Storage.HmacKey("key", new()
 *     {
 *         ServiceAccountEmail = serviceAccount.Email,
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/serviceaccount"
 * 	"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 {
 * 		// Create a new service account
 * 		serviceAccount, err := serviceaccount.NewAccount(ctx, "service_account", &serviceaccount.AccountArgs{
 * 			AccountId: pulumi.String("my-svc-acc"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		// Create the HMAC key for the associated service account
 * 		_, err = storage.NewHmacKey(ctx, "key", &storage.HmacKeyArgs{
 * 			ServiceAccountEmail: serviceAccount.Email,
 * 		})
 * 		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.serviceaccount.Account;
 * import com.pulumi.gcp.serviceaccount.AccountArgs;
 * import com.pulumi.gcp.storage.HmacKey;
 * import com.pulumi.gcp.storage.HmacKeyArgs;
 * 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 new service account
 *         var serviceAccount = new Account("serviceAccount", AccountArgs.builder()
 *             .accountId("my-svc-acc")
 *             .build());
 *         //Create the HMAC key for the associated service account
 *         var key = new HmacKey("key", HmacKeyArgs.builder()
 *             .serviceAccountEmail(serviceAccount.email())
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   # Create a new service account
 *   serviceAccount:
 *     type: gcp:serviceaccount:Account
 *     name: service_account
 *     properties:
 *       accountId: my-svc-acc
 *   #Create the HMAC key for the associated service account
 *   key:
 *     type: gcp:storage:HmacKey
 *     properties:
 *       serviceAccountEmail: ${serviceAccount.email}
 * ```
 * 
 * ## Import
 * HmacKey can be imported using any of these accepted formats:
 * * `projects/{{project}}/hmacKeys/{{access_id}}`
 * * `{{project}}/{{access_id}}`
 * * `{{access_id}}`
 * When using the `pulumi import` command, HmacKey can be imported using one of the formats above. For example:
 * ```sh
 * $ pulumi import gcp:storage/hmacKey:HmacKey default projects/{{project}}/hmacKeys/{{access_id}}
 * ```
 * ```sh
 * $ pulumi import gcp:storage/hmacKey:HmacKey default {{project}}/{{access_id}}
 * ```
 * ```sh
 * $ pulumi import gcp:storage/hmacKey:HmacKey default {{access_id}}
 * ```
 */
public class HmacKey internal constructor(
    override val javaResource: com.pulumi.gcp.storage.HmacKey,
) : KotlinCustomResource(javaResource, HmacKeyMapper) {
    /**
     * The access ID of the HMAC Key.
     */
    public val accessId: Output
        get() = javaResource.accessId().applyValue({ args0 -> args0 })

    /**
     * The ID of the project in which the resource belongs.
     * If it is not provided, the provider project is used.
     */
    public val project: Output
        get() = javaResource.project().applyValue({ args0 -> args0 })

    /**
     * HMAC secret key material.
     * **Note**: This property is sensitive and will not be displayed in the plan.
     */
    public val secret: Output
        get() = javaResource.secret().applyValue({ args0 -> args0 })

    /**
     * The email address of the key's associated service account.
     * - - -
     */
    public val serviceAccountEmail: Output
        get() = javaResource.serviceAccountEmail().applyValue({ args0 -> args0 })

    /**
     * The state of the key. Can be set to one of ACTIVE, INACTIVE.
     * Default value is `ACTIVE`.
     * Possible values are: `ACTIVE`, `INACTIVE`.
     */
    public val state: Output?
        get() = javaResource.state().applyValue({ args0 -> args0.map({ args0 -> args0 }).orElse(null) })

    /**
     * 'The creation time of the HMAC key in RFC 3339 format. '
     */
    public val timeCreated: Output
        get() = javaResource.timeCreated().applyValue({ args0 -> args0 })

    /**
     * 'The last modification time of the HMAC key metadata in RFC 3339 format.'
     */
    public val updated: Output
        get() = javaResource.updated().applyValue({ args0 -> args0 })
}

public object HmacKeyMapper : ResourceMapper {
    override fun supportsMappingOfType(javaResource: Resource): Boolean =
        com.pulumi.gcp.storage.HmacKey::class == javaResource::class

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

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy