diff --git a/.changelog/11676.txt b/.changelog/11676.txt new file mode 100644 index 0000000000..b2cc8fb134 --- /dev/null +++ b/.changelog/11676.txt @@ -0,0 +1,3 @@ +```release-note:bug +pubsub: allowed `google_pubsub_subscription` `filter` field to contain line breaks +``` \ No newline at end of file diff --git a/google-beta/services/pubsub/resource_pubsub_subscription.go b/google-beta/services/pubsub/resource_pubsub_subscription.go index d6d02ee89d..897b7e6a82 100644 --- a/google-beta/services/pubsub/resource_pubsub_subscription.go +++ b/google-beta/services/pubsub/resource_pubsub_subscription.go @@ -366,7 +366,7 @@ Example - "3.5s".`, Type: schema.TypeString, Optional: true, ForceNew: true, - ValidateFunc: verify.ValidateRegexp(`^.{0,256}$`), + ValidateFunc: verify.ValidateRegexp(`^[\s\S]{0,256}$`), Description: `The subscription only delivers the messages that match the filter. Pub/Sub automatically acknowledges the messages that don't match the filter. You can filter messages by their attributes. The maximum length of a filter is 256 bytes. After creating the subscription, diff --git a/google-beta/services/pubsub/resource_pubsub_subscription_generated_test.go b/google-beta/services/pubsub/resource_pubsub_subscription_generated_test.go index 60320e16e5..b8227cdbb6 100644 --- a/google-beta/services/pubsub/resource_pubsub_subscription_generated_test.go +++ b/google-beta/services/pubsub/resource_pubsub_subscription_generated_test.go @@ -139,6 +139,55 @@ resource "google_pubsub_subscription" "example" { `, context) } +func TestAccPubsubSubscription_pubsubSubscriptionPullFilterExample(t *testing.T) { + t.Parallel() + + context := map[string]interface{}{ + "random_suffix": acctest.RandString(t, 10), + } + + acctest.VcrTest(t, resource.TestCase{ + PreCheck: func() { acctest.AccTestPreCheck(t) }, + ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t), + CheckDestroy: testAccCheckPubsubSubscriptionDestroyProducer(t), + Steps: []resource.TestStep{ + { + Config: testAccPubsubSubscription_pubsubSubscriptionPullFilterExample(context), + }, + { + ResourceName: "google_pubsub_subscription.example", + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"labels", "terraform_labels", "topic"}, + }, + }, + }) +} + +func testAccPubsubSubscription_pubsubSubscriptionPullFilterExample(context map[string]interface{}) string { + return acctest.Nprintf(` +resource "google_pubsub_topic" "example" { + name = "tf-test-example-topic%{random_suffix}" +} + +resource "google_pubsub_subscription" "example" { + name = "tf-test-example-subscription%{random_suffix}" + topic = google_pubsub_topic.example.id + + labels = { + foo = "bar" + } + + filter = < + + Open in Cloud Shell + + +## Example Usage - Pubsub Subscription Pull Filter + + +```hcl +resource "google_pubsub_topic" "example" { + name = "example-topic" +} + +resource "google_pubsub_subscription" "example" { + name = "example-subscription" + topic = google_pubsub_topic.example.id + + labels = { + foo = "bar" + } + + filter = < Open in Cloud Shell