Skip to content

Commit

Permalink
Make allowedPersistenceRegions optional in messageStoragePolicy for g…
Browse files Browse the repository at this point in the history
…oogle_pubsub_topic
  • Loading branch information
shunsuke-tsumori committed Nov 22, 2024
1 parent 67c66d2 commit 05cc615
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
2 changes: 1 addition & 1 deletion mmv1/products/pubsub/Topic.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ properties:
of GCP altogether) will be routed for storage in one of the
allowed regions. An empty list means that no regions are allowed,
and is not a valid configuration.
required: true
required: false
item_type:
type: String
- name: 'schemaSettings'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,44 @@ func TestAccPubsubTopic_cloudStorageIngestionUpdate(t *testing.T) {
})
}

func TestAccGooglePubsubTopic_MessageStoragePolicyRemove(t *testing.T) {
resourceName := "google_pubsub_topic.usage-metrics"

initialConfig := `
resource "google_pubsub_topic" "usage-metrics" {
name = "topic-name"
message_storage_policy {
allowed_persistence_regions = ["us-central1"]
}
}
`

updatedConfig := `
resource "google_pubsub_topic" "usage-metrics" {
name = "topic-name"
}
`

resource.Test(t, resource.TestCase{
PreCheck: func() {},
Steps: []resource.TestStep{
{
Config: initialConfig,
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(resourceName, "message_storage_policy.0.allowed_persistence_regions.#", "1"),
),
},
{
Config: updatedConfig,
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(resourceName, "message_storage_policy.#", "0"),
),
},
},
})
}

func testAccPubsubTopic_update(topic, key, value string) string {
return fmt.Sprintf(`
resource "google_pubsub_topic" "foo" {
Expand Down

0 comments on commit 05cc615

Please sign in to comment.