Skip to content

A Terraform module to create and manage projects, the basis for creating, enabling, and using all Google Cloud services including managing APIs, enabling billing, adding and removing collaborators, and managing permissions in Google Cloud https://cloud.google.com/resource-manager/docs/creating-managing-projects

License

Notifications You must be signed in to change notification settings

mineiros-io/terraform-google-project

Repository files navigation

Build Status GitHub tag (latest SemVer) Terraform Version Google Provider Version Join Slack

terraform-google-project

A Terraform module for creating and managing projects in Google Cloud Platform (GCP).

This module supports Terraform version 1 and is compatible with the Terraform Google Provider version 4. and 5._**

This module is part of our Infrastructure as Code (IaC) framework that enables our users and customers to easily deploy and manage reusable, secure, and production-grade cloud infrastructure.

Module Features

A Terraform base module for creating a google_project resources. Which allows creation and management of a Google Cloud Platform project.

Getting Started

Most basic usage just setting required arguments:

module "terraform-google-project" {
  source = "github.com/mineiros-io/terraform-google-project.git?ref=v0.4.0"

  name       = "My Project"
  project_id = "your-project-id"
  org_id     = "1234567"
}

Module Argument Reference

See variables.tf and examples/ for details and use-cases.

Top-level Arguments

Main Resource Configuration

  • project_id: (Required string)

    The project ID. Changing this forces a new project to be created. Note: The project ID is a unique string used to differentiate your project from all others in Google Cloud.

  • name: (Optional string)

    The display name of the project.

    Default is var.project.

  • iam: (Optional list(iam))

    A list of IAM access to apply to the created secret.

    Example:

    iam = [
      {
        role    = "roles/viewer"
        members = ["user:[email protected]"]
      },
      {
        roles = [
          "roles/editor",
          "roles/owner",
        ]
        members = ["user:[email protected]"]
      }
    ]

    Each iam object in the list accepts the following attributes:

    • role: (Optional string)

      The role that members will be assigned to. Note that custom roles must be of the format [projects|organizations]/{parent-name}/roles/{role-name}. At least one of role or roles needs to be set. Each role can only exist once within all elements of the list. Each role can only exist once within all elements of the list unless it specifies a different condition.

    • roles: (Optional set(string))

      A set roles that members will be assigned to. Note that custom roles must be of the format [projects|organizations]/{parent-name}/roles/{role-name}. At least one of role or roles needs to be set. Each role can only exist once within all elements of the list unless it specifies a different condition.

    • members: (Optional set(string))

      Identities that will be granted the privilege in role. Each entry can have one of the following values:

      • allUsers: A special identifier that represents anyone who is on the internet; with or without a Google account.
      • allAuthenticatedUsers: A special identifier that represents anyone who is authenticated with a Google account or a service account.
      • user:{emailid}: An email address that represents a specific Google account. For example, [email protected] or [email protected].
      • serviceAccount:{emailid}: An email address that represents a service account. For example, [email protected].
      • group:{emailid}: An email address that represents a Google group. For example, [email protected].
      • domain:{domain}: A G Suite domain (primary, instead of alias) name that represents all the users of that domain. For example, google.com or example.com.
      • computed:{identifier}: An existing key from var.computed_members_map.

      Default is [].

    • authoritative: (Optional bool)

      Whether to exclusively set (authoritative mode) or add (non-authoritative/additive mode) members to the role.

      Default is true.

  • org_id: (Optional string)

    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.

  • folder_id: (Optional string)

    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.

  • billing_account: (Optional string)

    The alphanumeric ID of the billing account this project belongs to. The user or service account performing this operation with Terraform must have at minimum Billing Account User privileges (roles/billing.user) on the billing account.

  • skip_delete: (Optional bool)

    If set to true, the Terraform resource can be deleted without deleting the Project via the Google API.

    Default is false.

  • labels: (Optional map(string))

    A set of key/value label pairs to assign to the project.

    Default is {}.

  • auto_create_network: (Optional bool)

    Create the default network automatically. If kept as 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.

    It is recommended to use the constraints/compute.skipDefaultNetworkCreation constraint to remove the default network instead of setting auto_create_network to false.

    Default is false.

  • computed_members_map: (Optional map(string))

    A map of members to replace in members of various IAM settings to handle terraform computed values.

    Default is {}.

Module Configuration

  • module_enabled: (Optional bool)

    Specifies whether resources in the module will be created.

    Default is true.

  • module_depends_on: (Optional list(dependency))

    A list of dependencies. Any object can be assigned to this list to define a hidden external dependency.

    Example:

    module_depends_on = [
      google_network.network
    ]

Module Outputs

The following attributes are exported in the outputs of the module:

  • google_project: (object(google_project))

    All outputs of the created google_project resource.

  • iam: (list(iam))

    The resources created by mineiros-io/project-iam/google module.

External Documentation

Google Documentation

Terraform Google Provider Documentation

Module Versioning

This Module follows the principles of Semantic Versioning (SemVer).

Given a version number MAJOR.MINOR.PATCH, we increment the:

  1. MAJOR version when we make incompatible changes,
  2. MINOR version when we add functionality in a backwards compatible manner, and
  3. PATCH version when we make backwards compatible bug fixes.

Backwards compatibility in 0.0.z and 0.y.z version

  • Backwards compatibility in versions 0.0.z is not guaranteed when z is increased. (Initial development)
  • Backwards compatibility in versions 0.y.z is not guaranteed when y is increased. (Pre-release)

About Mineiros

Mineiros is a remote-first company headquartered in Berlin, Germany that solves development, automation and security challenges in cloud infrastructure.

Our vision is to massively reduce time and overhead for teams to manage and deploy production-grade and secure cloud infrastructure.

We offer commercial support for all of our modules and encourage you to reach out if you have any questions or need help. Feel free to email us at [email protected] or join our Community Slack channel.

Reporting Issues

We use GitHub Issues to track community reported issues and missing features.

Contributing

Contributions are always encouraged and welcome! For the process of accepting changes, we use Pull Requests. If you'd like more information, please see our Contribution Guidelines.

Makefile Targets

This repository comes with a handy Makefile. Run make help to see details on each available target.

License

license

This module is licensed under the Apache License Version 2.0, January 2004. Please see LICENSE for full details.

Copyright © 2020-2022 Mineiros GmbH

About

A Terraform module to create and manage projects, the basis for creating, enabling, and using all Google Cloud services including managing APIs, enabling billing, adding and removing collaborators, and managing permissions in Google Cloud https://cloud.google.com/resource-manager/docs/creating-managing-projects

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published