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

com.pulumi.gcp.organizations.kotlin.Project.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.organizations.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
import kotlin.collections.Map

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

    public var args: ProjectArgs = ProjectArgs()

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

/**
 * Allows creation and management of a Google Cloud Platform project.
 * Projects created with this resource must be associated with an Organization.
 * See the [Organization documentation](https://cloud.google.com/resource-manager/docs/quickstarts) for more details.
 * The user or service account that is running this provider when creating a `gcp.organizations.Project`
 * resource must have `roles/resourcemanager.projectCreator` on the specified organization. See the
 * [Access Control for Organizations Using IAM](https://cloud.google.com/resource-manager/docs/access-control-org)
 * doc for more information.
 * > This resource reads the specified billing account on every pulumi up and plan operation so you must have permissions on the specified billing account.
 * To get more information about projects, see:
 * * [API documentation](https://cloud.google.com/resource-manager/reference/rest/v1/projects)
 * * How-to Guides
 *     * [Creating and managing projects](https://cloud.google.com/resource-manager/docs/creating-managing-projects)
 * ## Example Usage
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 * const myProject = new gcp.organizations.Project("my_project", {
 *     name: "My Project",
 *     projectId: "your-project-id",
 *     orgId: "1234567",
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_gcp as gcp
 * my_project = gcp.organizations.Project("my_project",
 *     name="My Project",
 *     project_id="your-project-id",
 *     org_id="1234567")
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Gcp = Pulumi.Gcp;
 * return await Deployment.RunAsync(() =>
 * {
 *     var myProject = new Gcp.Organizations.Project("my_project", new()
 *     {
 *         Name = "My Project",
 *         ProjectId = "your-project-id",
 *         OrgId = "1234567",
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"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 {
 * 		_, err := organizations.NewProject(ctx, "my_project", &organizations.ProjectArgs{
 * 			Name:      pulumi.String("My Project"),
 * 			ProjectId: pulumi.String("your-project-id"),
 * 			OrgId:     pulumi.String("1234567"),
 * 		})
 * 		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.Project;
 * import com.pulumi.gcp.organizations.ProjectArgs;
 * 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 myProject = new Project("myProject", ProjectArgs.builder()
 *             .name("My Project")
 *             .projectId("your-project-id")
 *             .orgId("1234567")
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   myProject:
 *     type: gcp:organizations:Project
 *     name: my_project
 *     properties:
 *       name: My Project
 *       projectId: your-project-id
 *       orgId: '1234567'
 * ```
 * 
 * To create a project under a specific folder
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 * const department1 = new gcp.organizations.Folder("department1", {
 *     displayName: "Department 1",
 *     parent: "organizations/1234567",
 * });
 * const myProject_in_a_folder = new gcp.organizations.Project("my_project-in-a-folder", {
 *     name: "My Project",
 *     projectId: "your-project-id",
 *     folderId: department1.name,
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_gcp as gcp
 * department1 = gcp.organizations.Folder("department1",
 *     display_name="Department 1",
 *     parent="organizations/1234567")
 * my_project_in_a_folder = gcp.organizations.Project("my_project-in-a-folder",
 *     name="My Project",
 *     project_id="your-project-id",
 *     folder_id=department1.name)
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Gcp = Pulumi.Gcp;
 * return await Deployment.RunAsync(() =>
 * {
 *     var department1 = new Gcp.Organizations.Folder("department1", new()
 *     {
 *         DisplayName = "Department 1",
 *         Parent = "organizations/1234567",
 *     });
 *     var myProject_in_a_folder = new Gcp.Organizations.Project("my_project-in-a-folder", new()
 *     {
 *         Name = "My Project",
 *         ProjectId = "your-project-id",
 *         FolderId = department1.Name,
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"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 {
 * 		department1, err := organizations.NewFolder(ctx, "department1", &organizations.FolderArgs{
 * 			DisplayName: pulumi.String("Department 1"),
 * 			Parent:      pulumi.String("organizations/1234567"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = organizations.NewProject(ctx, "my_project-in-a-folder", &organizations.ProjectArgs{
 * 			Name:      pulumi.String("My Project"),
 * 			ProjectId: pulumi.String("your-project-id"),
 * 			FolderId:  department1.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.organizations.Folder;
 * import com.pulumi.gcp.organizations.FolderArgs;
 * import com.pulumi.gcp.organizations.Project;
 * import com.pulumi.gcp.organizations.ProjectArgs;
 * 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 department1 = new Folder("department1", FolderArgs.builder()
 *             .displayName("Department 1")
 *             .parent("organizations/1234567")
 *             .build());
 *         var myProject_in_a_folder = new Project("myProject-in-a-folder", ProjectArgs.builder()
 *             .name("My Project")
 *             .projectId("your-project-id")
 *             .folderId(department1.name())
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   myProject-in-a-folder:
 *     type: gcp:organizations:Project
 *     name: my_project-in-a-folder
 *     properties:
 *       name: My Project
 *       projectId: your-project-id
 *       folderId: ${department1.name}
 *   department1:
 *     type: gcp:organizations:Folder
 *     properties:
 *       displayName: Department 1
 *       parent: organizations/1234567
 * ```
 * 
 * ## Import
 * Projects can be imported using the `project_id`, e.g.
 * * `{{project_id}}`
 * When using the `pulumi import` command, Projects can be imported using one of the formats above. For example:
 * ```sh
 * $ pulumi import gcp:organizations/project:Project default {{project_id}}
 * ```
 */
public class Project internal constructor(
    override val javaResource: com.pulumi.gcp.organizations.Project,
) : KotlinCustomResource(javaResource, ProjectMapper) {
    /**
     * Create the 'default' network automatically. Default true. If set to false, the default network will be deleted. Note
     * that, for quota purposes, you will still need to have 1 network slot available to create the project successfully, even
     * if you set auto_create_network to false, since the network will exist momentarily.
     */
    public val autoCreateNetwork: Output?
        get() = javaResource.autoCreateNetwork().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * The alphanumeric ID of the billing account this project
     * belongs to. The user or service account performing this operation with the provider
     * must have at mininum Billing Account User privileges (`roles/billing.user`) on the billing account.
     * See [Google Cloud Billing API Access Control](https://cloud.google.com/billing/docs/how-to/billing-access)
     * for more details.
     */
    public val billingAccount: Output?
        get() = javaResource.billingAccount().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Pulumi, other clients and services.
     */
    public val effectiveLabels: Output>
        get() = javaResource.effectiveLabels().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.key.to(args0.value)
            }).toMap()
        })

    /**
     * The numeric ID of the folder this project should be
     * created under. Only one of `org_id` or `folder_id` may be
     * specified. If the `folder_id` is specified, then the project is
     * created under the specified folder. Changing this forces the
     * project to be migrated to the newly specified folder.
     */
    public val folderId: Output?
        get() = javaResource.folderId().applyValue({ args0 -> args0.map({ args0 -> args0 }).orElse(null) })

    /**
     * A set of key/value label pairs to assign to the project.
     * **Note**: This field is non-authoritative, and will only manage the labels present in your configuration.
     * Please refer to the field 'effective_labels' for all of the labels present on the resource.
     */
    public val labels: Output>?
        get() = javaResource.labels().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.map({ args0 ->
                    args0.key.to(args0.value)
                }).toMap()
            }).orElse(null)
        })

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

    /**
     * The numeric identifier of the project.
     */
    public val number: Output
        get() = javaResource.number().applyValue({ args0 -> args0 })

    /**
     * The numeric ID of the organization this project belongs to.
     * Changing this forces a new project to be created.  Only one of
     * `org_id` or `folder_id` may be specified. If the `org_id` is
     * specified then the project is created at the top level. Changing
     * this forces the project to be migrated to the newly specified
     * organization.
     */
    public val orgId: Output?
        get() = javaResource.orgId().applyValue({ args0 -> args0.map({ args0 -> args0 }).orElse(null) })

    /**
     * The project ID. Changing this forces a new project to be created.
     */
    public val projectId: Output
        get() = javaResource.projectId().applyValue({ args0 -> args0 })

    /**
     * The combination of labels configured directly on the resource and default labels configured on the provider.
     */
    public val pulumiLabels: Output>
        get() = javaResource.pulumiLabels().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.key.to(args0.value)
            }).toMap()
        })

    /**
     * If true, the resource can be deleted
     * without deleting the Project via the Google API.
     */
    public val skipDelete: Output
        get() = javaResource.skipDelete().applyValue({ args0 -> args0 })
}

public object ProjectMapper : ResourceMapper {
    override fun supportsMappingOfType(javaResource: Resource): Boolean =
        com.pulumi.gcp.organizations.Project::class == javaResource::class

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

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy