Skip to content

SweetOps/terraform-google-storage-bucket

Repository files navigation

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