2015-10-28 17:55:50 +00:00
|
|
|
---
|
|
|
|
layout: "google"
|
|
|
|
page_title: "Google: google_pubsub_subscription"
|
2018-03-06 17:52:39 +00:00
|
|
|
sidebar_current: "docs-google-pubsub-subscription-x"
|
2015-10-28 17:55:50 +00:00
|
|
|
description: |-
|
|
|
|
Creates a subscription in Google's pubsub queueing system
|
|
|
|
---
|
|
|
|
|
2017-03-29 19:06:26 +00:00
|
|
|
# google\_pubsub\_subscription
|
2015-10-28 17:55:50 +00:00
|
|
|
|
2016-04-10 21:34:15 +00:00
|
|
|
Creates a subscription in Google's pubsub queueing system. For more information see
|
2015-10-28 17:55:50 +00:00
|
|
|
[the official documentation](https://cloud.google.com/pubsub/docs) and
|
2017-09-26 20:44:13 +00:00
|
|
|
[API](https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.subscriptions).
|
2015-10-28 17:55:50 +00:00
|
|
|
|
|
|
|
|
|
|
|
## Example Usage
|
|
|
|
|
2017-04-17 10:17:54 +00:00
|
|
|
```hcl
|
2017-10-30 22:08:50 +00:00
|
|
|
resource "google_pubsub_topic" "default-topic" {
|
|
|
|
name = "default-topic"
|
|
|
|
}
|
|
|
|
|
2015-10-28 17:55:50 +00:00
|
|
|
resource "google_pubsub_subscription" "default" {
|
2016-04-10 21:34:15 +00:00
|
|
|
name = "default-subscription"
|
2017-10-30 22:08:50 +00:00
|
|
|
topic = "${google_pubsub_topic.default-topic.name}"
|
2016-04-10 21:34:15 +00:00
|
|
|
|
|
|
|
ack_deadline_seconds = 20
|
|
|
|
|
|
|
|
push_config {
|
2018-01-16 22:44:25 +00:00
|
|
|
push_endpoint = "https://example.com/push"
|
2017-02-18 22:48:50 +00:00
|
|
|
|
2016-04-10 21:34:15 +00:00
|
|
|
attributes {
|
|
|
|
x-goog-version = "v1"
|
2015-12-03 14:48:45 +00:00
|
|
|
}
|
2016-04-10 21:34:15 +00:00
|
|
|
}
|
2015-10-28 17:55:50 +00:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2017-10-30 22:08:50 +00:00
|
|
|
If the subscription has a topic in a different project:
|
|
|
|
|
|
|
|
```hcl
|
|
|
|
resource "google_pubsub_topic" "topic-different-project" {
|
|
|
|
project = "another-project"
|
|
|
|
name = "topic-different-project"
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "google_pubsub_subscription" "default" {
|
|
|
|
name = "default-subscription"
|
|
|
|
topic = "${google_pubsub_topic.topic-different-project.id}"
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2015-10-28 17:55:50 +00:00
|
|
|
## Argument Reference
|
|
|
|
|
|
|
|
The following arguments are supported:
|
|
|
|
|
|
|
|
* `name` - (Required) A unique name for the resource, required by pubsub.
|
|
|
|
Changing this forces a new resource to be created.
|
2015-12-03 14:48:45 +00:00
|
|
|
|
2017-10-30 22:08:50 +00:00
|
|
|
* `topic` - (Required) The topic name or id to bind this subscription to, required by pubsub.
|
2015-10-28 17:55:50 +00:00
|
|
|
Changing this forces a new resource to be created.
|
|
|
|
|
2016-04-10 21:34:15 +00:00
|
|
|
- - -
|
|
|
|
|
2015-12-03 14:48:45 +00:00
|
|
|
* `ack_deadline_seconds` - (Optional) The maximum number of seconds a
|
|
|
|
subscriber has to acknowledge a received message, otherwise the message is
|
|
|
|
redelivered. Changing this forces a new resource to be created.
|
|
|
|
|
2018-03-12 20:59:47 +00:00
|
|
|
* `project` - (Optional) The ID of the project in which the resource belongs. If it
|
2016-04-10 21:34:15 +00:00
|
|
|
is not provided, the provider project is used.
|
|
|
|
|
|
|
|
* `push_config` - (Optional) Block configuration for push options. More
|
|
|
|
configuration options are detailed below.
|
|
|
|
|
2015-12-03 14:48:45 +00:00
|
|
|
The optional `push_config` block supports:
|
2015-10-28 17:55:50 +00:00
|
|
|
|
2017-09-26 20:44:13 +00:00
|
|
|
* `push_endpoint` - (Required) The URL of the endpoint to which messages should
|
2015-12-03 14:48:45 +00:00
|
|
|
be pushed. Changing this forces a new resource to be created.
|
2015-10-28 17:55:50 +00:00
|
|
|
|
2015-12-03 14:48:45 +00:00
|
|
|
* `attributes` - (Optional) Key-value pairs of API supported attributes used
|
|
|
|
to control aspects of the message delivery. Currently, only
|
|
|
|
`x-goog-version` is supported, which controls the format of the data
|
|
|
|
delivery. For more information, read [the API docs
|
|
|
|
here](https://cloud.google.com/pubsub/reference/rest/v1/projects.subscriptions#PushConfig.FIELDS.attributes).
|
|
|
|
Changing this forces a new resource to be created.
|
2016-04-10 21:34:15 +00:00
|
|
|
|
|
|
|
## Attributes Reference
|
|
|
|
|
2017-05-05 13:57:24 +00:00
|
|
|
* `path` - Path of the subscription in the format `projects/{project}/subscriptions/{sub}`
|
2017-09-26 20:44:13 +00:00
|
|
|
|
|
|
|
## Import
|
|
|
|
|
|
|
|
Pubsub subscription can be imported using the `name`, e.g.
|
|
|
|
|
|
|
|
```
|
|
|
|
$ terraform import google_pubsub_subscription.default default-subscription
|
|
|
|
```
|
|
|
|
|