GithubHelp home page GithubHelp logo

idwall / terraform-google-storage-bucket Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dev-nil-com/terraform-google-storage-bucket

0.0 4.0 0.0 17 KB

Terraform module to provision a GCS bucket with logging & ACLs

Home Page: https://registry.terraform.io/modules/dansible/storage-bucket/google/1.1.0

License: MIT License

HCL 100.00%

terraform-google-storage-bucket's Introduction

Google Storage Bucket

This terraform module provisions one or more Google Cloud Storage buckets with ACLs. There is also the option of creating an additional bucket to store audit and access logs if you provide logging = true to the module parameters.

Usage Example

module "my_bucket" {
  source             = "[email protected]:dansible/terraform-google-storage-bucket.git?ref=v1.1.0"

  # Required Parameters:
  names              = ["${var.bucket_names}"]

  # Optional Parameters:
  location           = "${var.region}"
  project            = "${var.project}"
  storage_class      = "REGIONAL"
  default_acl        = "projectPrivate"
  force_destroy      = "true"
  logging            = true
  versioning         = true

  labels = {
    "managed-by" = "terraform"
  }

  lifecycle_rules = [{
    action = [{
      type          = "SetStorageClass"
      storage_class = "NEARLINE"
    }]

    condition = [{
      age                   = 60
      created_before        = "2018-08-20"
      is_live               = false
      matches_storage_class = ["REGIONAL"]
      num_newer_versions    = 10
    }]
  }]

  roles = [
    "OWNER:project-owners-${var.project}",
    "WRITER:project-editors-${var.project}",
    "READER:project-viewers-${var.project}"
  ]
}

You can then reuse the bucket as a remote data source:

data "terraform_remote_state" "gcs_bucket" {
  backend = "gcs"

  config {
    bucket = "${module.my_bucket.bucket_name}" # Must be referenced through module output
  }
}
Name Description Type Default Required
default_acl Configure this ACL to be the default ACL. See https://cloud.google.com/storage/docs/access-control/lists for more details. string "projectPrivate" no
force_destroy When deleting a bucket, this boolean option will delete all contained objects. string "false" no
labels A set of key/value label pairs to assign to the bucket. map <map> no
lifecycle_rules The bucket's Lifecycle Rules configuration. See README for examples list <list> no
location The GCS location. If it is not provided, the region configured in the gcloud client is used. string "" no
logging When set to true, enable the bucket's Access and Storage Logs configuration and create a storage_bucket for them. string "false" no
names The name of the bucket list n/a yes
project The ID of the google project to which the resource belongs. If it is not provided, the project configured in the gcloud client is used. string "" no
roles List of role/entity pairs in the form ROLE:entity. See https://cloud.google.com/storage/docs/json_api/v1/bucketAccessControls for more details. list <list> no
storage_class The Storage Class of the new bucket. Supported values are: MULTI_REGIONAL, REGIONAL, NEARLINE, COLDLINE. string "REGIONAL" no
versioning While set to true, versioning is fully enabled for these buckets. string "false" no

Outputs

Name Description
bucket_names List of generated buckets.
log_bucket_name List of generated log buckets.
self_link The URI of the created resources.
url The base URL of the buckets, in the format gs://.

Links

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.