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

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

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

    public var args: ReleaseArgs = ReleaseArgs()

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

/**
 * For more information, see:
 * * [Get started with Firebase Security Rules](https://firebase.google.com/docs/rules/get-started)
 * ## Example Usage
 * ### Firestore_release
 * Creates a Firebase Rules Release to Cloud Firestore
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 * const firestore = new gcp.firebaserules.Ruleset("firestore", {
 *     source: {
 *         files: [{
 *             content: "service cloud.firestore {match /databases/{database}/documents { match /{document=**} { allow read, write: if false; } } }",
 *             name: "firestore.rules",
 *         }],
 *     },
 *     project: "my-project-name",
 * });
 * const primary = new gcp.firebaserules.Release("primary", {
 *     name: "cloud.firestore/database",
 *     rulesetName: pulumi.interpolate`projects/my-project-name/rulesets/${firestore.name}`,
 *     project: "my-project-name",
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_gcp as gcp
 * firestore = gcp.firebaserules.Ruleset("firestore",
 *     source=gcp.firebaserules.RulesetSourceArgs(
 *         files=[gcp.firebaserules.RulesetSourceFileArgs(
 *             content="service cloud.firestore {match /databases/{database}/documents { match /{document=**} { allow read, write: if false; } } }",
 *             name="firestore.rules",
 *         )],
 *     ),
 *     project="my-project-name")
 * primary = gcp.firebaserules.Release("primary",
 *     name="cloud.firestore/database",
 *     ruleset_name=firestore.name.apply(lambda name: f"projects/my-project-name/rulesets/{name}"),
 *     project="my-project-name")
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Gcp = Pulumi.Gcp;
 * return await Deployment.RunAsync(() =>
 * {
 *     var firestore = new Gcp.Firebaserules.Ruleset("firestore", new()
 *     {
 *         Source = new Gcp.Firebaserules.Inputs.RulesetSourceArgs
 *         {
 *             Files = new[]
 *             {
 *                 new Gcp.Firebaserules.Inputs.RulesetSourceFileArgs
 *                 {
 *                     Content = "service cloud.firestore {match /databases/{database}/documents { match /{document=**} { allow read, write: if false; } } }",
 *                     Name = "firestore.rules",
 *                 },
 *             },
 *         },
 *         Project = "my-project-name",
 *     });
 *     var primary = new Gcp.Firebaserules.Release("primary", new()
 *     {
 *         Name = "cloud.firestore/database",
 *         RulesetName = firestore.Name.Apply(name => $"projects/my-project-name/rulesets/{name}"),
 *         Project = "my-project-name",
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"fmt"
 * 	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/firebaserules"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		firestore, err := firebaserules.NewRuleset(ctx, "firestore", &firebaserules.RulesetArgs{
 * 			Source: &firebaserules.RulesetSourceArgs{
 * 				Files: firebaserules.RulesetSourceFileArray{
 * 					&firebaserules.RulesetSourceFileArgs{
 * 						Content: pulumi.String("service cloud.firestore {match /databases/{database}/documents { match /{document=**} { allow read, write: if false; } } }"),
 * 						Name:    pulumi.String("firestore.rules"),
 * 					},
 * 				},
 * 			},
 * 			Project: pulumi.String("my-project-name"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = firebaserules.NewRelease(ctx, "primary", &firebaserules.ReleaseArgs{
 * 			Name: pulumi.String("cloud.firestore/database"),
 * 			RulesetName: firestore.Name.ApplyT(func(name string) (string, error) {
 * 				return fmt.Sprintf("projects/my-project-name/rulesets/%v", name), nil
 * 			}).(pulumi.StringOutput),
 * 			Project: pulumi.String("my-project-name"),
 * 		})
 * 		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.firebaserules.Ruleset;
 * import com.pulumi.gcp.firebaserules.RulesetArgs;
 * import com.pulumi.gcp.firebaserules.inputs.RulesetSourceArgs;
 * import com.pulumi.gcp.firebaserules.Release;
 * import com.pulumi.gcp.firebaserules.ReleaseArgs;
 * 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 firestore = new Ruleset("firestore", RulesetArgs.builder()
 *             .source(RulesetSourceArgs.builder()
 *                 .files(RulesetSourceFileArgs.builder()
 *                     .content("service cloud.firestore {match /databases/{database}/documents { match /{document=**} { allow read, write: if false; } } }")
 *                     .name("firestore.rules")
 *                     .build())
 *                 .build())
 *             .project("my-project-name")
 *             .build());
 *         var primary = new Release("primary", ReleaseArgs.builder()
 *             .name("cloud.firestore/database")
 *             .rulesetName(firestore.name().applyValue(name -> String.format("projects/my-project-name/rulesets/%s", name)))
 *             .project("my-project-name")
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   primary:
 *     type: gcp:firebaserules:Release
 *     properties:
 *       name: cloud.firestore/database
 *       rulesetName: projects/my-project-name/rulesets/${firestore.name}
 *       project: my-project-name
 *   firestore:
 *     type: gcp:firebaserules:Ruleset
 *     properties:
 *       source:
 *         files:
 *           - content: 'service cloud.firestore {match /databases/{database}/documents { match /{document=**} { allow read, write: if false; } } }'
 *             name: firestore.rules
 *       project: my-project-name
 * ```
 * 
 * ### Storage_release
 * Creates a Firebase Rules Release for a Storage bucket
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 * // Provision a non-default Cloud Storage bucket.
 * const bucket = new gcp.storage.Bucket("bucket", {
 *     project: "my-project-name",
 *     name: "bucket",
 *     location: "us-west1",
 * });
 * // Create a ruleset of Firebase Security Rules from a local file.
 * const storage = new gcp.firebaserules.Ruleset("storage", {
 *     project: "my-project-name",
 *     source: {
 *         files: [{
 *             name: "storage.rules",
 *             content: "service firebase.storage {match /b/{bucket}/o {match /{allPaths=**} {allow read, write: if request.auth != null;}}}",
 *         }],
 *     },
 * });
 * const primary = new gcp.firebaserules.Release("primary", {
 *     name: pulumi.interpolate`firebase.storage/${bucket.name}`,
 *     rulesetName: pulumi.interpolate`projects/my-project-name/rulesets/${storage.name}`,
 *     project: "my-project-name",
 * });
 * // Make the Storage bucket accessible for Firebase SDKs, authentication, and Firebase Security Rules.
 * const bucketStorageBucket = new gcp.firebase.StorageBucket("bucket", {
 *     project: "my-project-name",
 *     bucketId: bucket.name,
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_gcp as gcp
 * # Provision a non-default Cloud Storage bucket.
 * bucket = gcp.storage.Bucket("bucket",
 *     project="my-project-name",
 *     name="bucket",
 *     location="us-west1")
 * # Create a ruleset of Firebase Security Rules from a local file.
 * storage = gcp.firebaserules.Ruleset("storage",
 *     project="my-project-name",
 *     source=gcp.firebaserules.RulesetSourceArgs(
 *         files=[gcp.firebaserules.RulesetSourceFileArgs(
 *             name="storage.rules",
 *             content="service firebase.storage {match /b/{bucket}/o {match /{allPaths=**} {allow read, write: if request.auth != null;}}}",
 *         )],
 *     ))
 * primary = gcp.firebaserules.Release("primary",
 *     name=bucket.name.apply(lambda name: f"firebase.storage/{name}"),
 *     ruleset_name=storage.name.apply(lambda name: f"projects/my-project-name/rulesets/{name}"),
 *     project="my-project-name")
 * # Make the Storage bucket accessible for Firebase SDKs, authentication, and Firebase Security Rules.
 * bucket_storage_bucket = gcp.firebase.StorageBucket("bucket",
 *     project="my-project-name",
 *     bucket_id=bucket.name)
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Gcp = Pulumi.Gcp;
 * return await Deployment.RunAsync(() =>
 * {
 *     // Provision a non-default Cloud Storage bucket.
 *     var bucket = new Gcp.Storage.Bucket("bucket", new()
 *     {
 *         Project = "my-project-name",
 *         Name = "bucket",
 *         Location = "us-west1",
 *     });
 *     // Create a ruleset of Firebase Security Rules from a local file.
 *     var storage = new Gcp.Firebaserules.Ruleset("storage", new()
 *     {
 *         Project = "my-project-name",
 *         Source = new Gcp.Firebaserules.Inputs.RulesetSourceArgs
 *         {
 *             Files = new[]
 *             {
 *                 new Gcp.Firebaserules.Inputs.RulesetSourceFileArgs
 *                 {
 *                     Name = "storage.rules",
 *                     Content = "service firebase.storage {match /b/{bucket}/o {match /{allPaths=**} {allow read, write: if request.auth != null;}}}",
 *                 },
 *             },
 *         },
 *     });
 *     var primary = new Gcp.Firebaserules.Release("primary", new()
 *     {
 *         Name = bucket.Name.Apply(name => $"firebase.storage/{name}"),
 *         RulesetName = storage.Name.Apply(name => $"projects/my-project-name/rulesets/{name}"),
 *         Project = "my-project-name",
 *     });
 *     // Make the Storage bucket accessible for Firebase SDKs, authentication, and Firebase Security Rules.
 *     var bucketStorageBucket = new Gcp.Firebase.StorageBucket("bucket", new()
 *     {
 *         Project = "my-project-name",
 *         BucketId = bucket.Name,
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"fmt"
 * 	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/firebase"
 * 	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/firebaserules"
 * 	"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 {
 * 		// Provision a non-default Cloud Storage bucket.
 * 		bucket, err := storage.NewBucket(ctx, "bucket", &storage.BucketArgs{
 * 			Project:  pulumi.String("my-project-name"),
 * 			Name:     pulumi.String("bucket"),
 * 			Location: pulumi.String("us-west1"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		// Create a ruleset of Firebase Security Rules from a local file.
 * 		storage, err := firebaserules.NewRuleset(ctx, "storage", &firebaserules.RulesetArgs{
 * 			Project: pulumi.String("my-project-name"),
 * 			Source: &firebaserules.RulesetSourceArgs{
 * 				Files: firebaserules.RulesetSourceFileArray{
 * 					&firebaserules.RulesetSourceFileArgs{
 * 						Name:    pulumi.String("storage.rules"),
 * 						Content: pulumi.String("service firebase.storage {match /b/{bucket}/o {match /{allPaths=**} {allow read, write: if request.auth != null;}}}"),
 * 					},
 * 				},
 * 			},
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = firebaserules.NewRelease(ctx, "primary", &firebaserules.ReleaseArgs{
 * 			Name: bucket.Name.ApplyT(func(name string) (string, error) {
 * 				return fmt.Sprintf("firebase.storage/%v", name), nil
 * 			}).(pulumi.StringOutput),
 * 			RulesetName: storage.Name.ApplyT(func(name string) (string, error) {
 * 				return fmt.Sprintf("projects/my-project-name/rulesets/%v", name), nil
 * 			}).(pulumi.StringOutput),
 * 			Project: pulumi.String("my-project-name"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		// Make the Storage bucket accessible for Firebase SDKs, authentication, and Firebase Security Rules.
 * 		_, err = firebase.NewStorageBucket(ctx, "bucket", &firebase.StorageBucketArgs{
 * 			Project:  pulumi.String("my-project-name"),
 * 			BucketId: bucket.Name,
 * 		})
 * 		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.firebaserules.Ruleset;
 * import com.pulumi.gcp.firebaserules.RulesetArgs;
 * import com.pulumi.gcp.firebaserules.inputs.RulesetSourceArgs;
 * import com.pulumi.gcp.firebaserules.Release;
 * import com.pulumi.gcp.firebaserules.ReleaseArgs;
 * import com.pulumi.gcp.firebase.StorageBucket;
 * import com.pulumi.gcp.firebase.StorageBucketArgs;
 * 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) {
 *         // Provision a non-default Cloud Storage bucket.
 *         var bucket = new Bucket("bucket", BucketArgs.builder()
 *             .project("my-project-name")
 *             .name("bucket")
 *             .location("us-west1")
 *             .build());
 *         // Create a ruleset of Firebase Security Rules from a local file.
 *         var storage = new Ruleset("storage", RulesetArgs.builder()
 *             .project("my-project-name")
 *             .source(RulesetSourceArgs.builder()
 *                 .files(RulesetSourceFileArgs.builder()
 *                     .name("storage.rules")
 *                     .content("service firebase.storage {match /b/{bucket}/o {match /{allPaths=**} {allow read, write: if request.auth != null;}}}")
 *                     .build())
 *                 .build())
 *             .build());
 *         var primary = new Release("primary", ReleaseArgs.builder()
 *             .name(bucket.name().applyValue(name -> String.format("firebase.storage/%s", name)))
 *             .rulesetName(storage.name().applyValue(name -> String.format("projects/my-project-name/rulesets/%s", name)))
 *             .project("my-project-name")
 *             .build());
 *         // Make the Storage bucket accessible for Firebase SDKs, authentication, and Firebase Security Rules.
 *         var bucketStorageBucket = new StorageBucket("bucketStorageBucket", StorageBucketArgs.builder()
 *             .project("my-project-name")
 *             .bucketId(bucket.name())
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   primary:
 *     type: gcp:firebaserules:Release
 *     properties:
 *       name: firebase.storage/${bucket.name}
 *       rulesetName: projects/my-project-name/rulesets/${storage.name}
 *       project: my-project-name
 *   # Provision a non-default Cloud Storage bucket.
 *   bucket:
 *     type: gcp:storage:Bucket
 *     properties:
 *       project: my-project-name
 *       name: bucket
 *       location: us-west1
 *   # Make the Storage bucket accessible for Firebase SDKs, authentication, and Firebase Security Rules.
 *   bucketStorageBucket:
 *     type: gcp:firebase:StorageBucket
 *     name: bucket
 *     properties:
 *       project: my-project-name
 *       bucketId: ${bucket.name}
 *   # Create a ruleset of Firebase Security Rules from a local file.
 *   storage:
 *     type: gcp:firebaserules:Ruleset
 *     properties:
 *       project: my-project-name
 *       source:
 *         files:
 *           - name: storage.rules
 *             content: 'service firebase.storage {match /b/{bucket}/o {match /{allPaths=**} {allow read, write: if request.auth != null;}}}'
 * ```
 * 
 * ## Import
 * Release can be imported using any of these accepted formats:
 * * `projects/{{project}}/releases/{{name}}`
 * When using the `pulumi import` command, Release can be imported using one of the formats above. For example:
 * ```sh
 * $ pulumi import gcp:firebaserules/release:Release default projects/{{project}}/releases/{{name}}
 * ```
 */
public class Release internal constructor(
    override val javaResource: com.pulumi.gcp.firebaserules.Release,
) : KotlinCustomResource(javaResource, ReleaseMapper) {
    /**
     * Output only. Time the release was created.
     */
    public val createTime: Output
        get() = javaResource.createTime().applyValue({ args0 -> args0 })

    /**
     * Disable the release to keep it from being served. The response code of NOT_FOUND will be given for executables generated from this Release.
     */
    public val disabled: Output
        get() = javaResource.disabled().applyValue({ args0 -> args0 })

    /**
     * Format: `projects/{project_id}/releases/{release_id}`\Firestore Rules Releases will **always** have the name 'cloud.firestore'
     */
    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 })

    /**
     * Name of the `Ruleset` referred to by this `Release`. The `Ruleset` must exist for the `Release` to be created.
     * - - -
     */
    public val rulesetName: Output
        get() = javaResource.rulesetName().applyValue({ args0 -> args0 })

    /**
     * Output only. Time the release was updated.
     */
    public val updateTime: Output
        get() = javaResource.updateTime().applyValue({ args0 -> args0 })
}

public object ReleaseMapper : ResourceMapper {
    override fun supportsMappingOfType(javaResource: Resource): Boolean =
        com.pulumi.gcp.firebaserules.Release::class == javaResource::class

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

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

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




© 2015 - 2025 Weber Informatics LLC | Privacy Policy