Skip to content

Commit

Permalink
Merge pull request #15 from paulpalamarchuk/add_message_storage_policy
Browse files Browse the repository at this point in the history
Add message_storage_policy block
  • Loading branch information
morgante authored Oct 31, 2019
2 parents 6d52da3 + 9fd7b46 commit 72a59a2
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 3 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ module "pubsub" {

| Name | Description | Type | Default | Required |
|------|-------------|:----:|:-----:|:-----:|
| message\_storage\_policy | A map of storage policies. Default - inherit from organization's Resource Location Restriction policy. | map | `<map>` | no |
| project\_id | The project ID to manage the Pub/Sub resources | string | n/a | yes |
| pull\_subscriptions | The list of the pull subscriptions | list(map(string)) | `<list>` | no |
| push\_subscriptions | The list of the push subscriptions | list(map(string)) | `<list>` | no |
Expand All @@ -64,7 +65,7 @@ module "pubsub" {
### Installation Dependencies

- [terraform](https://www.terraform.io/downloads.html) 0.12.x
- [terraform-provider-google](https://github.com/terraform-providers/terraform-provider-google) plugin v2.7.x
- [terraform-provider-google](https://github.com/terraform-providers/terraform-provider-google) plugin >= v2.13

### Configure a Service Account

Expand Down
2 changes: 1 addition & 1 deletion examples/simple/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

provider "google" {
version = "~> 2.7"
version = "~> 2.13"
region = "us-central1"
}

Expand Down
7 changes: 7 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ resource "google_pubsub_topic" "topic" {
project = var.project_id
name = var.topic
labels = var.topic_labels

dynamic "message_storage_policy" {
for_each = var.message_storage_policy
content {
allowed_persistence_regions = message_storage_policy.key == "allowed_persistence_regions" ? message_storage_policy.value : null
}
}
}

resource "google_pubsub_subscription" "push_subscriptions" {
Expand Down
2 changes: 1 addition & 1 deletion test/integration/default/controls/pubsub.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
describe command("gcloud --project='#{project_id}' pubsub topics describe #{topic}") do
its(:exit_status) { should be_zero }
it { expect(subject.stdout).to match(%r{name: projects/#{project_id}/topics/#{topic}}) }
it { expect(subject.stdout).to match(%r{labels:\n bar_label: bar_value\n foo_label: foo_value\nname}) }
it { expect(subject.stdout).to match(/labels:\n bar_label: bar_value\n foo_label: foo_value\n.*name/m) }
end

describe command("gcloud --project='#{project_id}' pubsub subscriptions describe pull --format=json") do
Expand Down
5 changes: 5 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,8 @@ variable "pull_subscriptions" {
default = []
}

variable "message_storage_policy" {
type = map
description = "A map of storage policies. Default - inherit from organization's Resource Location Restriction policy."
default = {}
}

0 comments on commit 72a59a2

Please sign in to comment.