Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove default location from gcs module #2303

Merged
merged 5 commits into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions blueprints/apigee/bigquery-analytics/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ module "bucket_export" {
source = "../../../modules/gcs"
project_id = module.project.project_id
name = "${module.project.project_id}-export"
location = var.organization.analytics_region
iam = {
"roles/storage.objectViewer" = [
module.function_gcs2bq.service_account_iam_email
Expand Down
1 change: 1 addition & 0 deletions modules/folder/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ module "gcs" {
project_id = var.project_id
prefix = var.prefix
name = "gcs_sink"
location = "EU"
force_destroy = true
}

Expand Down
13 changes: 11 additions & 2 deletions modules/gcs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ module "bucket" {
project_id = var.project_id
prefix = var.prefix
name = "my-bucket"
location = "EU"
versioning = true
labels = {
cost-center = "devops"
Expand Down Expand Up @@ -62,8 +63,8 @@ module "bucket" {
project_id = var.project_id
prefix = var.prefix
name = "my-bucket"
encryption_key = module.kms.keys.bucket_key.id
location = "EU"
encryption_key = module.kms.keys.bucket_key.id
}

# tftest modules=3 skip e2e
Expand All @@ -77,6 +78,7 @@ module "bucket" {
project_id = var.project_id
prefix = var.prefix
name = "my-bucket"
location = "EU"
retention_policy = {
retention_period = 100
is_locked = true
Expand All @@ -98,6 +100,7 @@ module "bucket" {
project_id = var.project_id
prefix = var.prefix
name = "my-bucket"
location = "EU"
lifecycle_rules = {
lr-0 = {
action = {
Expand Down Expand Up @@ -127,6 +130,7 @@ module "bucket-gcs-notification" {
project_id = var.project_id
prefix = var.prefix
name = "my-bucket"
location = "EU"
notification_config = {
enabled = true
payload_format = "JSON_API_V1"
Expand All @@ -147,6 +151,7 @@ module "bucket" {
project_id = var.project_id
prefix = var.prefix
name = "my-bucket"
location = "EU"
objects_to_upload = {
sample-data = {
name = "example-file.csv"
Expand Down Expand Up @@ -176,6 +181,7 @@ module "bucket" {
project_id = var.project_id
prefix = var.prefix
name = "my-bucket"
location = "EU"
iam = {
"roles/storage.admin" = ["group:${var.group_email}"]
}
Expand All @@ -189,6 +195,7 @@ module "bucket" {
project_id = var.project_id
prefix = var.prefix
name = "my-bucket"
location = "EU"
iam_bindings = {
storage-admin-with-delegated_roles = {
role = "roles/storage.admin"
Expand Down Expand Up @@ -217,6 +224,7 @@ module "bucket" {
project_id = var.project_id
prefix = var.prefix
name = "my-bucket"
location = "EU"
iam_bindings_additive = {
storage-admin-with-delegated_roles = {
role = "roles/storage.admin"
Expand Down Expand Up @@ -264,6 +272,7 @@ module "bucket" {
project_id = var.project_id
prefix = var.prefix
name = "my-bucket"
location = "EU"
tag_bindings = {
env-sandbox = module.org.tag_values["environment/sandbox"].id
}
Expand All @@ -275,6 +284,7 @@ module "bucket" {

| name | description | type | required | default |
|---|---|:---:|:---:|:---:|
| [location](variables.tf#L149) | Bucket location. | <code>string</code> | ✓ | |
| [name](variables.tf#L164) | Bucket name suffix. | <code>string</code> | ✓ | |
| [project_id](variables.tf#L219) | Bucket project id. | <code>string</code> | ✓ | |
| [autoclass](variables.tf#L17) | Enable autoclass to automatically transition objects to appropriate storage classes based on their access pattern. If set to true, storage_class must be set to STANDARD. Defaults to false. | <code>bool</code> | | <code>false</code> |
Expand All @@ -288,7 +298,6 @@ module "bucket" {
| [iam_bindings_additive](variables.tf#L79) | Individual additive IAM bindings. Keys are arbitrary. | <code title="map&#40;object&#40;&#123;&#10; member &#61; string&#10; role &#61; string&#10; condition &#61; optional&#40;object&#40;&#123;&#10; expression &#61; string&#10; title &#61; string&#10; description &#61; optional&#40;string&#41;&#10; &#125;&#41;&#41;&#10;&#125;&#41;&#41;">map&#40;object&#40;&#123;&#8230;&#125;&#41;&#41;</code> | | <code>&#123;&#125;</code> |
| [labels](variables.tf#L94) | Labels to be attached to all buckets. | <code>map&#40;string&#41;</code> | | <code>&#123;&#125;</code> |
| [lifecycle_rules](variables.tf#L100) | Bucket lifecycle rule. | <code title="map&#40;object&#40;&#123;&#10; action &#61; object&#40;&#123;&#10; type &#61; string&#10; storage_class &#61; optional&#40;string&#41;&#10; &#125;&#41;&#10; condition &#61; object&#40;&#123;&#10; age &#61; optional&#40;number&#41;&#10; created_before &#61; optional&#40;string&#41;&#10; custom_time_before &#61; optional&#40;string&#41;&#10; days_since_custom_time &#61; optional&#40;number&#41;&#10; days_since_noncurrent_time &#61; optional&#40;number&#41;&#10; matches_prefix &#61; optional&#40;list&#40;string&#41;&#41;&#10; matches_storage_class &#61; optional&#40;list&#40;string&#41;&#41; &#35; STANDARD, MULTI_REGIONAL, REGIONAL, NEARLINE, COLDLINE, ARCHIVE, DURABLE_REDUCED_AVAILABILITY&#10; matches_suffix &#61; optional&#40;list&#40;string&#41;&#41;&#10; noncurrent_time_before &#61; optional&#40;string&#41;&#10; num_newer_versions &#61; optional&#40;number&#41;&#10; with_state &#61; optional&#40;string&#41; &#35; &#34;LIVE&#34;, &#34;ARCHIVED&#34;, &#34;ANY&#34;&#10; &#125;&#41;&#10;&#125;&#41;&#41;">map&#40;object&#40;&#123;&#8230;&#125;&#41;&#41;</code> | | <code>&#123;&#125;</code> |
| [location](variables.tf#L149) | Bucket location. | <code>string</code> | | <code>&#34;EU&#34;</code> |
| [logging_config](variables.tf#L155) | Bucket logging configuration. | <code title="object&#40;&#123;&#10; log_bucket &#61; string&#10; log_object_prefix &#61; optional&#40;string&#41;&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | | <code>null</code> |
| [notification_config](variables.tf#L169) | GCS Notification configuration. | <code title="object&#40;&#123;&#10; enabled &#61; bool&#10; payload_format &#61; string&#10; topic_name &#61; string&#10; sa_email &#61; string&#10; event_types &#61; optional&#40;list&#40;string&#41;&#41;&#10; custom_attributes &#61; optional&#40;map&#40;string&#41;&#41;&#10; object_name_prefix &#61; optional&#40;string&#41;&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | | <code>null</code> |
| [objects_to_upload](variables.tf#L183) | Objects to be uploaded to bucket. | <code title="map&#40;object&#40;&#123;&#10; name &#61; string&#10; metadata &#61; optional&#40;map&#40;string&#41;&#41;&#10; content &#61; optional&#40;string&#41;&#10; source &#61; optional&#40;string&#41;&#10; cache_control &#61; optional&#40;string&#41;&#10; content_disposition &#61; optional&#40;string&#41;&#10; content_encoding &#61; optional&#40;string&#41;&#10; content_language &#61; optional&#40;string&#41;&#10; content_type &#61; optional&#40;string&#41;&#10; event_based_hold &#61; optional&#40;bool&#41;&#10; temporary_hold &#61; optional&#40;bool&#41;&#10; detect_md5hash &#61; optional&#40;string&#41;&#10; storage_class &#61; optional&#40;string&#41;&#10; kms_key_name &#61; optional&#40;string&#41;&#10; customer_encryption &#61; optional&#40;object&#40;&#123;&#10; encryption_algorithm &#61; optional&#40;string&#41;&#10; encryption_key &#61; string&#10; &#125;&#41;&#41;&#10;&#125;&#41;&#41;">map&#40;object&#40;&#123;&#8230;&#125;&#41;&#41;</code> | | <code>&#123;&#125;</code> |
Expand Down
2 changes: 1 addition & 1 deletion modules/gcs/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ variable "lifecycle_rules" {
variable "location" {
description = "Bucket location."
type = string
default = "EU"
# default = "EU"
}

variable "logging_config" {
Expand Down
1 change: 1 addition & 0 deletions modules/organization/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ module "gcs" {
project_id = var.project_id
prefix = var.prefix
name = "gcs_sink"
location = "EU"
force_destroy = true
}

Expand Down
2 changes: 2 additions & 0 deletions modules/project/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,7 @@ module "gcs" {
source = "./fabric/modules/gcs"
project_id = var.project_id
name = "gcs_sink"
location = "EU"
prefix = var.prefix
force_destroy = true
}
Expand Down Expand Up @@ -1133,6 +1134,7 @@ module "gcs" {
source = "./fabric/modules/gcs"
project_id = var.project_id
name = "gcs_sink"
location = "EU"
prefix = var.prefix
force_destroy = true
}
Expand Down
3 changes: 2 additions & 1 deletion modules/pubsub/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ module "pubsub" {
}
# tftest modules=2 resources=4 fixtures=fixtures/gcs.tf inventory=cloud-storage-subscription.yaml e2e
```

### Subscriptions with IAM

```hcl
Expand Down Expand Up @@ -173,7 +174,7 @@ module "pubsub" {
| [message_retention_duration](variables.tf#L67) | Minimum duration to retain a message after it is published to the topic. | <code>string</code> | | <code>null</code> |
| [regions](variables.tf#L83) | List of regions used to set persistence policy. | <code>list&#40;string&#41;</code> | | <code>&#91;&#93;</code> |
| [schema](variables.tf#L90) | Topic schema. If set, all messages in this topic should follow this schema. | <code title="object&#40;&#123;&#10; definition &#61; string&#10; msg_encoding &#61; optional&#40;string, &#34;ENCODING_UNSPECIFIED&#34;&#41;&#10; schema_type &#61; string&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | | <code>null</code> |
| [subscriptions](variables.tf#L100) | Topic subscriptions. Also define push configs for push subscriptions. If options is set to null subscription defaults will be used. Labels default to topic labels if set to null. | <code title="map&#40;object&#40;&#123;&#10; labels &#61; optional&#40;map&#40;string&#41;&#41;&#10; ack_deadline_seconds &#61; optional&#40;number&#41;&#10; message_retention_duration &#61; optional&#40;string&#41;&#10; retain_acked_messages &#61; optional&#40;bool, false&#41;&#10; expiration_policy_ttl &#61; optional&#40;string&#41;&#10; filter &#61; optional&#40;string&#41;&#10; enable_message_ordering &#61; optional&#40;bool, false&#41;&#10; enable_exactly_once_delivery &#61; optional&#40;bool, false&#41;&#10; dead_letter_policy &#61; optional&#40;object&#40;&#123;&#10; topic &#61; string&#10; max_delivery_attempts &#61; optional&#40;number&#41;&#10; &#125;&#41;&#41;&#10; retry_policy &#61; optional&#40;object&#40;&#123;&#10; minimum_backoff &#61; optional&#40;number&#41;&#10; maximum_backoff &#61; optional&#40;number&#41;&#10; &#125;&#41;&#41;&#10;&#10;&#10; bigquery &#61; optional&#40;object&#40;&#123;&#10; table &#61; string&#10; use_topic_schema &#61; optional&#40;bool, false&#41;&#10; write_metadata &#61; optional&#40;bool, false&#41;&#10; drop_unknown_fields &#61; optional&#40;bool, false&#41;&#10; &#125;&#41;&#41;&#10; cloud_storage &#61; optional&#40;object&#40;&#123;&#10; bucket &#61; string&#10; filename_prefix &#61; optional&#40;string&#41;&#10; filename_suffix &#61; optional&#40;string&#41;&#10; max_duration &#61; optional&#40;string&#41;&#10; max_bytes &#61; optional&#40;number&#41;&#10; avro_config &#61; optional&#40;object&#40;&#123;&#10; write_metadata &#61; optional&#40;bool, false&#41;&#10; &#125;&#41;&#41;&#10; &#125;&#41;&#41;&#10; push &#61; optional&#40;object&#40;&#123;&#10; endpoint &#61; string&#10; attributes &#61; optional&#40;map&#40;string&#41;&#41;&#10; no_wrapper &#61; optional&#40;bool, false&#41;&#10; oidc_token &#61; optional&#40;object&#40;&#123;&#10; audience &#61; optional&#40;string&#41;&#10; service_account_email &#61; string&#10; &#125;&#41;&#41;&#10; &#125;&#41;&#41;&#10;&#10;&#10; iam &#61; optional&#40;map&#40;list&#40;string&#41;&#41;, &#123;&#125;&#41;&#10; iam_bindings &#61; optional&#40;map&#40;object&#40;&#123;&#10; members &#61; list&#40;string&#41;&#10; role &#61; string&#10; condition &#61; optional&#40;object&#40;&#123;&#10; expression &#61; string&#10; title &#61; string&#10; description &#61; optional&#40;string&#41;&#10; &#125;&#41;&#41;&#10; &#125;&#41;&#41;, &#123;&#125;&#41;&#10; iam_bindings_additive &#61; optional&#40;map&#40;object&#40;&#123;&#10; member &#61; string&#10; role &#61; string&#10; condition &#61; optional&#40;object&#40;&#123;&#10; expression &#61; string&#10; title &#61; string&#10; description &#61; optional&#40;string&#41;&#10; &#125;&#41;&#41;&#10; &#125;&#41;&#41;, &#123;&#125;&#41;&#10;&#125;&#41;&#41;">map&#40;object&#40;&#123;&#8230;&#125;&#41;&#41;</code> | | <code>&#123;&#125;</code> |
| [subscriptions](variables.tf#L100) | Topic subscriptions. Also define push configs for push subscriptions. If options is set to null subscription defaults will be used. Labels default to topic labels if set to null. | <code title="map&#40;object&#40;&#123;&#10; labels &#61; optional&#40;map&#40;string&#41;&#41;&#10; ack_deadline_seconds &#61; optional&#40;number&#41;&#10; message_retention_duration &#61; optional&#40;string&#41;&#10; retain_acked_messages &#61; optional&#40;bool, false&#41;&#10; expiration_policy_ttl &#61; optional&#40;string&#41;&#10; filter &#61; optional&#40;string&#41;&#10; enable_message_ordering &#61; optional&#40;bool, false&#41;&#10; enable_exactly_once_delivery &#61; optional&#40;bool, false&#41;&#10; dead_letter_policy &#61; optional&#40;object&#40;&#123;&#10; topic &#61; string&#10; max_delivery_attempts &#61; optional&#40;number&#41;&#10; &#125;&#41;&#41;&#10; retry_policy &#61; optional&#40;object&#40;&#123;&#10; minimum_backoff &#61; optional&#40;number&#41;&#10; maximum_backoff &#61; optional&#40;number&#41;&#10; &#125;&#41;&#41;&#10; bigquery &#61; optional&#40;object&#40;&#123;&#10; table &#61; string&#10; use_topic_schema &#61; optional&#40;bool, false&#41;&#10; write_metadata &#61; optional&#40;bool, false&#41;&#10; drop_unknown_fields &#61; optional&#40;bool, false&#41;&#10; &#125;&#41;&#41;&#10; cloud_storage &#61; optional&#40;object&#40;&#123;&#10; bucket &#61; string&#10; filename_prefix &#61; optional&#40;string&#41;&#10; filename_suffix &#61; optional&#40;string&#41;&#10; max_duration &#61; optional&#40;string&#41;&#10; max_bytes &#61; optional&#40;number&#41;&#10; avro_config &#61; optional&#40;object&#40;&#123;&#10; write_metadata &#61; optional&#40;bool, false&#41;&#10; &#125;&#41;&#41;&#10; &#125;&#41;&#41;&#10; push &#61; optional&#40;object&#40;&#123;&#10; endpoint &#61; string&#10; attributes &#61; optional&#40;map&#40;string&#41;&#41;&#10; no_wrapper &#61; optional&#40;bool, false&#41;&#10; oidc_token &#61; optional&#40;object&#40;&#123;&#10; audience &#61; optional&#40;string&#41;&#10; service_account_email &#61; string&#10; &#125;&#41;&#41;&#10; &#125;&#41;&#41;&#10;&#10;&#10; iam &#61; optional&#40;map&#40;list&#40;string&#41;&#41;, &#123;&#125;&#41;&#10; iam_bindings &#61; optional&#40;map&#40;object&#40;&#123;&#10; members &#61; list&#40;string&#41;&#10; role &#61; string&#10; condition &#61; optional&#40;object&#40;&#123;&#10; expression &#61; string&#10; title &#61; string&#10; description &#61; optional&#40;string&#41;&#10; &#125;&#41;&#41;&#10; &#125;&#41;&#41;, &#123;&#125;&#41;&#10; iam_bindings_additive &#61; optional&#40;map&#40;object&#40;&#123;&#10; member &#61; string&#10; role &#61; string&#10; condition &#61; optional&#40;object&#40;&#123;&#10; expression &#61; string&#10; title &#61; string&#10; description &#61; optional&#40;string&#41;&#10; &#125;&#41;&#41;&#10; &#125;&#41;&#41;, &#123;&#125;&#41;&#10;&#125;&#41;&#41;">map&#40;object&#40;&#123;&#8230;&#125;&#41;&#41;</code> | | <code>&#123;&#125;</code> |

## Outputs

Expand Down
1 change: 0 additions & 1 deletion modules/pubsub/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ variable "subscriptions" {
minimum_backoff = optional(number)
maximum_backoff = optional(number)
}))

bigquery = optional(object({
table = string
use_topic_schema = optional(bool, false)
Expand Down
3 changes: 2 additions & 1 deletion tests/fixtures/gcs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ module "gcs" {
project_id = var.project_id
prefix = var.prefix
name = "my-bucket"
location = "EU"
iam = {
"roles/storage.admin" = ["serviceAccount:service-${var.project_number}@gcp-sa-pubsub.iam.gserviceaccount.com"]
}
}
}
Loading