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

add enforce_in_transit field in google_pubsub_topic #9069

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
3 changes: 3 additions & 0 deletions .changelog/12716.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note: enhancement
pubsub: added `enforce_in_transit` fields to `google_pubsub_topic` resource
```
25 changes: 25 additions & 0 deletions google-beta/services/pubsub/resource_pubsub_topic.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,14 @@ and is not a valid configuration.`,
Type: schema.TypeString,
},
},
"enforce_in_transit": {
Type: schema.TypeBool,
Optional: true,
Description: `If true, 'allowedPersistenceRegions' is also used to enforce in-transit
guarantees for messages. That is, Pub/Sub will fail topics.publish
operations on this topic and subscribe operations on any subscription
attached to this topic in any region that is not in 'allowedPersistenceRegions'.`,
},
},
},
},
Expand Down Expand Up @@ -819,12 +827,18 @@ func flattenPubsubTopicMessageStoragePolicy(v interface{}, d *schema.ResourceDat
transformed := make(map[string]interface{})
transformed["allowed_persistence_regions"] =
flattenPubsubTopicMessageStoragePolicyAllowedPersistenceRegions(original["allowedPersistenceRegions"], d, config)
transformed["enforce_in_transit"] =
flattenPubsubTopicMessageStoragePolicyEnforceInTransit(original["enforceInTransit"], d, config)
return []interface{}{transformed}
}
func flattenPubsubTopicMessageStoragePolicyAllowedPersistenceRegions(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
return v
}

func flattenPubsubTopicMessageStoragePolicyEnforceInTransit(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
return v
}

func flattenPubsubTopicSchemaSettings(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
if v == nil {
return nil
Expand Down Expand Up @@ -1087,13 +1101,24 @@ func expandPubsubTopicMessageStoragePolicy(v interface{}, d tpgresource.Terrafor
transformed["allowedPersistenceRegions"] = transformedAllowedPersistenceRegions
}

transformedEnforceInTransit, err := expandPubsubTopicMessageStoragePolicyEnforceInTransit(original["enforce_in_transit"], d, config)
if err != nil {
return nil, err
} else if val := reflect.ValueOf(transformedEnforceInTransit); val.IsValid() && !tpgresource.IsEmptyValue(val) {
transformed["enforceInTransit"] = transformedEnforceInTransit
}

return transformed, nil
}

func expandPubsubTopicMessageStoragePolicyAllowedPersistenceRegions(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
return v, nil
}

func expandPubsubTopicMessageStoragePolicyEnforceInTransit(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
return v, nil
}

func expandPubsubTopicSchemaSettings(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
l := v.([]interface{})
if len(l) == 0 || l[0] == nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ resource "google_pubsub_topic" "example" {
allowed_persistence_regions = [
"europe-west3",
]
enforce_in_transit = true
}
}
`, context)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ resource "google_pubsub_topic" "foo" {
allowed_persistence_regions = [
"%s",
]
enforce_in_transit = false
}
}
`, topic, key, value, region)
Expand Down
8 changes: 8 additions & 0 deletions website/docs/r/pubsub_topic.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ resource "google_pubsub_topic" "example" {
allowed_persistence_regions = [
"europe-west3",
]
enforce_in_transit = true
}
}
```
Expand Down Expand Up @@ -257,6 +258,13 @@ The following arguments are supported:
allowed regions. An empty list means that no regions are allowed,
and is not a valid configuration.

* `enforce_in_transit` -
(Optional)
If true, `allowedPersistenceRegions` is also used to enforce in-transit
guarantees for messages. That is, Pub/Sub will fail topics.publish
operations on this topic and subscribe operations on any subscription
attached to this topic in any region that is not in `allowedPersistenceRegions`.

<a name="nested_schema_settings"></a>The `schema_settings` block supports:

* `schema` -
Expand Down
Loading