Skip to content
This repository has been archived by the owner on Nov 14, 2024. It is now read-only.

Pub/Sub Geo Restriction #175

Merged
merged 1 commit into from
Aug 6, 2019
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
4 changes: 4 additions & 0 deletions docs/resources/google_pubsub_topic.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ Properties that can be accessed from the `google_pubsub_topic` resource:

* `labels`: A set of key/value label pairs to assign to this Topic.

* `message_storage_policy`: Policy constraining the set of Google Cloud Platform regions where messages published to the topic may be stored. If not present, then no constraints are in effect.

* `allowed_persistence_regions`: A list of IDs of GCP regions where messages that are published to the topic may be persisted in storage. Messages published by publishers running in non-allowed GCP regions (or running outside 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.



## GCP Permissions
Expand Down
1 change: 1 addition & 0 deletions docs/resources/google_pubsub_topics.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ See [google_pubsub_topic.md](google_pubsub_topic.md) for more detailed informati
* `names`: an array of `google_pubsub_topic` name
* `kms_key_names`: an array of `google_pubsub_topic` kms_key_name
* `labels`: an array of `google_pubsub_topic` labels
* `message_storage_policies`: an array of `google_pubsub_topic` message_storage_policy

## Filter Criteria
This resource supports all of the above properties as filter criteria, which can be used
Expand Down
34 changes: 34 additions & 0 deletions libraries/google/pubsub/property/topic_message_storage_policy.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# frozen_string_literal: false

# ----------------------------------------------------------------------------
#
# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
#
# ----------------------------------------------------------------------------
#
# This file is automatically generated by Magic Modules and manual
# changes will be clobbered when the file is regenerated.
#
# Please read more about how to change this file in README.md and
# CONTRIBUTING.md located at the root of this package.
#
# ----------------------------------------------------------------------------
module GoogleInSpec
module Pubsub
module Property
class TopicMessageStoragePolicy
attr_reader :allowed_persistence_regions

def initialize(args = nil, parent_identifier = nil)
return if args.nil?
@parent_identifier = parent_identifier
@allowed_persistence_regions = args['allowedPersistenceRegions']
end

def to_s
"#{@parent_identifier} TopicMessageStoragePolicy"
end
end
end
end
end
3 changes: 3 additions & 0 deletions libraries/google_pubsub_topic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#
# ----------------------------------------------------------------------------
require 'gcp_backend'
require 'google/pubsub/property/topic_message_storage_policy'

# A provider to manage Cloud Pub/Sub resources.
class Topic < GcpResourceBase
Expand All @@ -25,6 +26,7 @@ class Topic < GcpResourceBase
attr_reader :name
attr_reader :kms_key_name
attr_reader :labels
attr_reader :message_storage_policy

def initialize(params)
super(params.merge({ use_http_transport: true }))
Expand All @@ -37,6 +39,7 @@ def parse
@name = name_from_self_link(@fetched['name'])
@kms_key_name = @fetched['kmsKeyName']
@labels = @fetched['labels']
@message_storage_policy = GoogleInSpec::Pubsub::Property::TopicMessageStoragePolicy.new(@fetched['messageStoragePolicy'], to_s)
end

# Handles parsing RFC3339 time string
Expand Down
2 changes: 2 additions & 0 deletions libraries/google_pubsub_topics.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class Topics < GcpResourceBase
filter_table_config.add(:names, field: :name)
filter_table_config.add(:kms_key_names, field: :kms_key_name)
filter_table_config.add(:labels, field: :labels)
filter_table_config.add(:message_storage_policies, field: :message_storage_policy)

filter_table_config.connect(self, :table)

Expand Down Expand Up @@ -68,6 +69,7 @@ def transformers
'name' => ->(obj) { return :name, name_from_self_link(obj['name']) },
'kmsKeyName' => ->(obj) { return :kms_key_name, obj['kmsKeyName'] },
'labels' => ->(obj) { return :labels, obj['labels'] },
'messageStoragePolicy' => ->(obj) { return :message_storage_policy, GoogleInSpec::Pubsub::Property::TopicMessageStoragePolicy.new(obj['messageStoragePolicy'], to_s) },
}
end

Expand Down