Fix order of getting project for storage notification topic (#1490)

* fix getting project for storage notification topic

* add more documentation for storage notification topic
This commit is contained in:
emily 2018-05-15 13:30:59 -07:00 committed by GitHub
parent 612be33ab9
commit 3cc868b4a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 8 deletions

View File

@ -79,13 +79,16 @@ func resourceStorageNotificationCreate(d *schema.ResourceData, meta interface{})
bucket := d.Get("bucket").(string)
project, err := getProject(d, config)
if err != nil {
return err
topicName := d.Get("topic").(string)
computedTopicName := getComputedTopicName("", topicName)
if computedTopicName != topicName {
project, err := getProject(d, config)
if err != nil {
return err
}
computedTopicName = getComputedTopicName(project, topicName)
}
computedTopicName := getComputedTopicName(project, d.Get("topic").(string))
storageNotification := &storage.Notification{
CustomAttributes: expandStringMap(d, "custom_attributes"),
EventTypes: convertStringSet(d.Get("event_types").(*schema.Set)),

View File

@ -44,7 +44,7 @@ resource "google_storage_notification" "notification" {
bucket = "${google_storage_bucket.bucket.name}"
payload_format = "JSON_API_V1"
topic = "${google_pubsub_topic.topic.id}"
event_types = ["%s","%s"]
event_types = ["OBJECT_FINALIZE", "OBJECT_METADATA_UPDATE"]
custom_attributes {
new-attribute = "new-attribute-value"
}
@ -60,8 +60,10 @@ The following arguments are supported:
* `payload_format` - (Required) The desired content of the Payload. One of `"JSON_API_V1"` or `"NONE"`.
* `topic` - (Required) The Cloud PubSub topic to which this subscription publishes.
* `topic` - (Required) The Cloud PubSub topic to which this subscription publishes. Expects either the
topic name, assumed to belong to the default GCP provider project, or the project-level name,
i.e. `projects/my-gcp-project/topics/my-topic` or `my-topic`.
- - -
* `custom_attributes` - (Optional) A set of key/value attribute pairs to attach to each Cloud PubSub message published for this notification subscription