The module creates an object storage bucket in Google Cloud Storage.
Allows configuring essential parameters:
Once you have a Corewide Solutions Portal account, this one-time action will use your browser session to retrieve credentials:
shellterraform login solutions.corewide.com
Initialize mandatory providers:
Copy and paste into your Terraform configuration and insert the variables:
hclmodule "tf_gcp_storage_bucket" {
source = "solutions.corewide.com/google-cloud/tf-gcp-storage-bucket/google"
version = "~> 3.0.0"
# specify module inputs here or try one of the examples below
...
}
Initialize the setup:
shellterraform init
Corewide DevOps team strictly follows Semantic Versioning
Specification
to
provide our clients with products that have predictable upgrades between versions. We
recommend
pinning
patch versions of our modules using pessimistic
constraint operator (~>) to prevent breaking changes during upgrades.
To get new features during the upgrades (without breaking compatibility), use
~> 3.0 and run
terraform init -upgrade
For the safest setup, use strict pinning with version = "3.0.0"
|
Module
35% off
|
€270
|
| TOTAL | €270 |
The module creates an object storage bucket in Google Cloud Storage.
Allows configuring essential parameters:
All notable changes to this project are documented here.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
8.41.9 due to using cross-object referencing for input variable validations(Last version compatible with the GCP Terraform provider version 7.0)
7.0(Last version compatible with the GCP Terraform provider version 6.0)
force_destroy variable to optionally allow buckets with content to be destroyedFirst stable version
v1.x to v2.xModule from v2.0 has changed GCP Terraform provider version, which isn't compatible with older versions. After the module version is upgraded, re-init the module to upgrade the provider version. Upgrade the GCP provider version at the project level:
hclterraform {
required_providers {
google = {
source = "hashicorp/google"
version = "~> 7.0"
}
}
}
Upgrade project dependencies:
bashterraform init --upgrade
Update the declaration of the module according to the requirements and examples to match the designed configuration, then the configuration can be applied.
Apply the changes to make sure the state of the resources is up-to-date with the new provider version:
bashterraform apply
v2.x to v3.xModule from v3.0 has changed GCP Terraform provider version, which isn't compatible with older versions. After the module version is upgraded, re-init the module to upgrade the provider version. Upgrade the GCP provider version at the project level:
hclterraform {
required_providers {
google = {
source = "hashicorp/google"
version = "~> 8.4"
}
}
}
Upgrade project dependencies:
bashterraform init --upgrade
Update the declaration of the module according to the requirements and examples to match the designed configuration, then the configuration can be applied.
Apply the changes to make sure the state of the resources is up-to-date with the new provider version:
bashterraform apply
Setup with custom configuration, force_destroy and versioning are enabled, access_mode set private, policy is assigned, and a storage_class configured as multi_regional:
hcldata "google_iam_policy" "policy1" {
binding {
role = "roles/storage.objectAdmin"
members = [
"user:[email protected]",
]
}
}
data "google_iam_policy" "policy2" {
binding {
role = "roles/storage.objectViewer"
members = [
"user:[email protected]",
]
}
}
module "bucket" {
source = "solutions.corewide.com/google-cloud/tf-gcp-storage-bucket/google"
version = "~> 3.0"
name = "foo"
region = "us-central1"
access_mode = "private"
storage_class = "multi_regional"
force_destroy = true
bucket_policies = {
policy1 = data.google_iam_policy.policy1.policy_data
policy2 = data.google_iam_policy.policy2.policy_data
}
}
Simple configuration with publicly accessible storage:
hclmodule "bucket" {
source = "solutions.corewide.com/google-cloud/tf-gcp-storage-bucket/google"
version = "~> 3.0"
name = "foo"
region = "us-central1"
access_mode = "public-read"
}
Minimal setup with default parameters:
hclmodule "bucket" {
source = "solutions.corewide.com/google-cloud/tf-gcp-storage-bucket/google"
version = "~> 3.0"
region = "us-central1"
name = "foo"
}
| Variable | Description | Type | Default | Required | Sensitive |
|---|---|---|---|---|---|
name |
Storage bucket name. Maximum length is 63 characters (56 characters when add_random_suffix is enabled) |
string |
yes | no | |
region |
GCP region to create resources in | string |
yes | no | |
access_mode |
Storage bucket access mode. Possible values are public-read and private |
string |
private |
no | no |
add_random_suffix |
Append a random suffix to the bucket name to ensure uniqueness. Note: modifying this variable will trigger the re-creation of the bucket | bool |
false |
no | no |
bucket_policies |
Valid IAM policy data to apply to the storage bucket in key-value format. Each key defines the policy name, and the value references an IAM policy document that specifies the roles and members for access control |
map(string) |
{} |
no | no |
force_destroy |
Whether to allow bucket force deletion if it contains objects | bool |
false |
no | no |
storage_class |
The storage class for the bucket. Possible values are: STANDARD, MULTI_REGIONAL, REGIONAL, NEARLINE, COLDLINE, and ARCHIVE |
string |
STANDARD |
no | no |
versioning |
Toggle bucket versioning | bool |
true |
no | no |
| Output | Description | Type | Sensitive |
|---|---|---|---|
bucket |
Contains all the Storage bucket attributes | resource |
no |
| Dependency | Version | Kind |
|---|---|---|
terraform |
>= 1.9 |
CLI |
hashicorp/google |
~> 8.4 |
provider |
hashicorp/random |
~> 3.3 |
provider |