Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Terraform Pub/Sub fix, do not send name on topic/subscription creation. #3818

Merged
merged 1 commit into from
Jun 10, 2019
Merged
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
Terraform Pub/Sub fix, do not send name on topic/subscription creation.
Signed-off-by: Modular Magician <magic-modules@google.com>
drebes authored and modular-magician committed Jun 7, 2019
commit fbed7ded99208c133819b8a60a823a7901e76e55
10 changes: 10 additions & 0 deletions google/resource_pubsub_subscription.go
Original file line number Diff line number Diff line change
@@ -187,6 +187,11 @@ func resourcePubsubSubscriptionCreate(d *schema.ResourceData, meta interface{})
obj["expirationPolicy"] = expirationPolicyProp
}

obj, err = resourcePubsubSubscriptionEncoder(d, meta, obj)
if err != nil {
return err
}

url, err := replaceVars(d, config, "https://pubsub.googleapis.com/v1/projects/{{project}}/subscriptions/{{name}}")
if err != nil {
return err
@@ -599,6 +604,11 @@ func expandPubsubSubscriptionExpirationPolicyTtl(v interface{}, d TerraformResou
return v, nil
}

func resourcePubsubSubscriptionEncoder(d *schema.ResourceData, meta interface{}, obj map[string]interface{}) (map[string]interface{}, error) {
delete(obj, "name")
return obj, nil
}

func resourcePubsubSubscriptionUpdateEncoder(d *schema.ResourceData, meta interface{}, obj map[string]interface{}) (map[string]interface{}, error) {
newObj := make(map[string]interface{})
newObj["subscription"] = obj
10 changes: 10 additions & 0 deletions google/resource_pubsub_topic.go
Original file line number Diff line number Diff line change
@@ -78,6 +78,11 @@ func resourcePubsubTopicCreate(d *schema.ResourceData, meta interface{}) error {
obj["labels"] = labelsProp
}

obj, err = resourcePubsubTopicEncoder(d, meta, obj)
if err != nil {
return err
}

url, err := replaceVars(d, config, "https://pubsub.googleapis.com/v1/projects/{{project}}/topics/{{name}}")
if err != nil {
return err
@@ -192,3 +197,8 @@ func expandPubsubTopicLabels(v interface{}, d TerraformResourceData, config *Con
}
return m, nil
}

func resourcePubsubTopicEncoder(d *schema.ResourceData, meta interface{}, obj map[string]interface{}) (map[string]interface{}, error) {
delete(obj, "name")
return obj, nil
}