Giter Club home page Giter Club logo

terraform-google-storage-bucket's Introduction

terraform-google-storage-bucket

Terraform module to create and manage the storage bucket.

Usage

module "awesome_bucket" {
  source      = "git::https://github.com/SweetOps/terraform-google-storage-bucket.git?ref=master"
  name        = "awesome"
  stage       = "production"
  namespace   = "sweetops"
  location    = "europe-west1"
}

Requirements

Name Version
terraform >= 0.14
google >= 3.0

Providers

Name Version
google >= 3.0

Inputs

Name Description Type Default Required
additional_tag_map Additional tags for appending to tags_as_list_of_maps. Not added to tags. map(string) {} no
attributes Additional attributes (e.g. 1) list(string) [] no
context Single object for setting entire context at once.
See description of individual variables for details.
Leave string and numeric variables as null to use default value.
Individual variable settings (non-null) override settings in context object,
except for attributes, tags, and additional_tag_map, which are merged.
any
{
"additional_tag_map": {},
"attributes": [],
"delimiter": null,
"enabled": true,
"environment": null,
"id_length_limit": null,
"label_key_case": null,
"label_order": [],
"label_value_case": null,
"name": null,
"namespace": null,
"regex_replace_chars": null,
"stage": null,
"tags": {}
}
no
default_kms_key_name The id of a Cloud KMS key that will be used to encrypt objects inserted into this bucket, if no encryption method is specified. string null no
delimiter Delimiter to be used between namespace, environment, stage, name and attributes.
Defaults to - (hyphen). Set to "" to use no delimiter at all.
string "-" no
enabled Set to false to prevent the module from creating any resources bool null no
environment Environment, e.g. 'uw2', 'us-west-2', OR 'prod', 'staging', 'dev', 'UAT' string null no
force_destroy When deleting a bucket, this boolean option will delete all contained objects. bool false no
id_length_limit Limit id to this many characters (minimum 6).
Set to 0 for unlimited length.
Set to null for default, which is 0.
Does not affect id_full.
number null no
label_key_case The letter case of label keys (tag names) (i.e. name, namespace, environment, stage, attributes) to use in tags.
Possible values: lower, title, upper.
Default value: title.
string "lower" no
label_order The naming order of the id output and Name tag.
Defaults to ["namespace", "environment", "stage", "name", "attributes"].
You can omit any of the 5 elements, but at least one must be present.
list(string) null no
label_value_case The letter case of output label values (also used in tags and id).
Possible values: lower, title, upper and none (no transformation).
Default value: lower.
string null no
lifecycle_rules The list of bucket Lifecycle Rules.
action:
type:
The type of the action of this Lifecycle Rule. Allowed values: Delete and SetStorageClass.
storage_class:
The target Storage Class of objects affected by this Lifecycle Rule.
Required if action type is SetStorageClass.
Allowed values: STANDARD, MULTI_REGIONAL, REGIONAL, NEARLINE, COLDLINE, ARCHIVE.
condition:
age:
Minimum age of an object in days to satisfy this condition.
created_before:
Creation date of an object in RFC 3339 (e.g. 2017-06-13) to satisfy this condition.
with_state:
Match to live and/or archived objects. Unversioned buckets have only live objects.
Allowed values: LIVE, ARCHIVED, ANY.
matches_storage_class:
Storage Class of objects to satisfy this condition.
Allowed values: STANDARD, MULTI_REGIONAL, REGIONAL, NEARLINE, COLDLINE, ARCHIVE.
num_newer_versions:
Relevant only for versioned objects.
The number of newer versions of an object to satisfy this condition.
custom_time_before:
Creation date of an object in RFC 3339 (e.g. 2017-06-13) to satisfy this condition.
days_since_custom_time:
Date in RFC 3339 (e.g. 2017-06-13) when an object's Custom-Time metadata is earlier than the date specified in this condition.
days_since_noncurrent_time:
Relevant only for versioned objects.
Number of days elapsed since the noncurrent timestamp of an object.
noncurrent_time_before:
Relevant only for versioned objects.
The date in RFC 3339 (e.g. 2017-06-13) when the object became nonconcurrent.
set(object({
action = any
condition = any
}))
[] no
location The GCS region. string null no
name Solution name, e.g. 'app' or 'jenkins' string null no
namespace Namespace, which could be your organization name or abbreviation, e.g. 'eg' or 'cp' string null no
project The ID of the project in which the resource belongs. If it is not provided, the provider project is used. string null no
regex_replace_chars Regex to replace chars with empty string in namespace, environment, stage and name.
If not set, "/[^a-zA-Z0-9-]/" is used to remove all characters other than hyphens, letters and digits.
string null no
retention_policy Configuration of the bucket's data retention policy for how long objects in the bucket should be retained.
is_locked:
If set to true, the bucket will be locked and permanently restrict edits to the bucket's retention policy.
retention_period:
The period of time, in seconds, that objects in the bucket must be retained and cannot be deleted, overwritten, or archived.
object({
is_locked = bool
retention_period = number
})
null no
stage Stage, e.g. 'prod', 'staging', 'dev', OR 'source', 'build', 'test', 'deploy', 'release' string null no
storage_class The Storage Class of the new bucket. Allowed values: STANDARD, MULTI_REGIONAL, REGIONAL, NEARLINE, COLDLINE, ARCHIVE. string "REGIONAL" no
tags Additional tags (e.g. map('BusinessUnit','XYZ') map(string) {} no
versioning_enabled While set to true, versioning is fully enabled for this bucket. bool true no

Outputs

Name Description
name The name of bucket
self_link The URI of the created resource
url The base URL of the bucket, in the format gs://

License

The Apache-2.0 license

terraform-google-storage-bucket's People

Contributors

sweetops avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

terraform-google-storage-bucket's Issues

Error: Error refreshing state: 1 error(s) occurred:

Good day!

I have error, pls explain what i do not correct?

Error: Error refreshing state: 1 error(s) occurred:

* module.storage-bucket.google_storage_bucket_acl.default: google_storage_bucket_acl.default: value of 'count' cannot be computed
data "google_client_config" "default" {}

resource "google_storage_bucket" "default" {
  count         = "${length(var.name)}"
  name          = "${element(var.name, count.index)}"
  location      = "${length(var.location) > 0 ? var.location : data.google_client_config.default.region}"
  project       = "${length(var.project) > 0 ? var.project : data.google_client_config.default.project}"
  storage_class = "${var.storage_class}"
  force_destroy = "${var.force_destroy}"

  lifecycle_rule {
    action {
      type          = "${var.action_type}"
      storage_class = "${var.action_storage_class}"
    }

    condition {
      age                   = "${var.age}"
      created_before        = "${var.created_before}"
      is_live               = "${var.is_live}"
      matches_storage_class = "${var.matches_storage_class}"
      num_newer_versions    = "${var.num_newer_versions}"
    }
  }

  versioning {
    enabled = "${var.versioning_enabled}"
  }
}

resource "google_storage_bucket_acl" "default" {
  count       = "${length(var.role_entity) > 0 ? length(google_storage_bucket.default.*.name) : 0}"
  default_acl = "${var.default_acl}"
  bucket      = "${element(google_storage_bucket.default.*.name, count.index)}"

  role_entity = [
    "${var.role_entity}",
  ]
}

examples have s3 in them

The names in the examples make it a bit confusing. Maybe use 'gs_bucket'... instead of s3_bucket

Failed to download module

Hi
terraform init fails to download your module

module "storage-bucket" {
  source  = "SweetOps/storage-bucket/google"
  version = "0.3.0"
}
Could not download module "storage-bucket" (storage-bucket.tf:6) source code
from
"https://api.github.com/repos/SweetOps/terraform-google-storage-bucket/tarball/0.3.0//*?archive=tar.gz":
Error opening a gzip reader for /tmp/getter747894952/archive: EOF.

kindly ask for fixing

Invalid value

on .terraform/modules/label/main.tf line 81, in locals:
81: attributes = "${lower(join(local.delimiter, local.attributes))}"
|----------------
| local.attributes is tuple with 1 element

Invalid value for "lists" parameter: element 0: string required.

Error: "lifecycle_rule.0.condition.0.is_live": [REMOVED]

Hi!
terraform plan

error
Error: "lifecycle_rule.0.condition.0.is_live": [REMOVED] Please use with_state instead

on .terraform/modules/storage-bucket-prod/SweetOps-terraform-google-storage-bucket-25596b1/main.tf line 13, in resource "google_storage_bucket" "default":
13: resource "google_storage_bucket" "default" {

my terraform --version 0.12.19
my code:
provider "google" {
project = var.project
region = var.region
}

module "storage-bucket-prod" {
source = "SweetOps/storage-bucket/google"
version = "0.3.0"
name = "storage-bucket-docker-prod"
location = "europe-west1"
force_destroy = true
}

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.