mirror of
https://github.com/letic/terraform-provider-google.git
synced 2024-06-29 06:42:36 +00:00
Autogen Global Forwarding Rule, fix Load Balancer related-resources (#3393)
Signed-off-by: Modular Magician <magic-modules@google.com>
This commit is contained in:
parent
726394fec8
commit
d28bfc7aaf
|
@ -168,7 +168,6 @@ func ResourceMapWithErrors() (map[string]*schema.Resource, error) {
|
|||
"google_cloudiot_registry": resourceCloudIoTRegistry(),
|
||||
"google_composer_environment": resourceComposerEnvironment(),
|
||||
"google_compute_attached_disk": resourceComputeAttachedDisk(),
|
||||
"google_compute_global_forwarding_rule": resourceComputeGlobalForwardingRule(),
|
||||
"google_compute_instance": resourceComputeInstance(),
|
||||
"google_compute_instance_from_template": resourceComputeInstanceFromTemplate(),
|
||||
"google_compute_instance_group": resourceComputeInstanceGroup(),
|
||||
|
|
|
@ -27,6 +27,7 @@ var GeneratedComputeResourcesMap = map[string]*schema.Resource{
|
|||
"google_compute_firewall": resourceComputeFirewall(),
|
||||
"google_compute_forwarding_rule": resourceComputeForwardingRule(),
|
||||
"google_compute_global_address": resourceComputeGlobalAddress(),
|
||||
"google_compute_global_forwarding_rule": resourceComputeGlobalForwardingRule(),
|
||||
"google_compute_http_health_check": resourceComputeHttpHealthCheck(),
|
||||
"google_compute_https_health_check": resourceComputeHttpsHealthCheck(),
|
||||
"google_compute_health_check": resourceComputeHealthCheck(),
|
||||
|
|
|
@ -1,14 +1,28 @@
|
|||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// *** 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
|
||||
// .github/CONTRIBUTING.md.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
package google
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"reflect"
|
||||
"time"
|
||||
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
"github.com/hashicorp/terraform/helper/validation"
|
||||
|
||||
computeBeta "google.golang.org/api/compute/v0.beta"
|
||||
compute "google.golang.org/api/compute/v1"
|
||||
"google.golang.org/api/compute/v1"
|
||||
)
|
||||
|
||||
func resourceComputeGlobalForwardingRule() *schema.Resource {
|
||||
|
@ -19,7 +33,13 @@ func resourceComputeGlobalForwardingRule() *schema.Resource {
|
|||
Delete: resourceComputeGlobalForwardingRuleDelete,
|
||||
|
||||
Importer: &schema.ResourceImporter{
|
||||
State: schema.ImportStatePassthrough,
|
||||
State: resourceComputeGlobalForwardingRuleImport,
|
||||
},
|
||||
|
||||
Timeouts: &schema.ResourceTimeout{
|
||||
Create: schema.DefaultTimeout(240 * time.Second),
|
||||
Update: schema.DefaultTimeout(240 * time.Second),
|
||||
Delete: schema.DefaultTimeout(240 * time.Second),
|
||||
},
|
||||
|
||||
Schema: map[string]*schema.Schema{
|
||||
|
@ -28,74 +48,48 @@ func resourceComputeGlobalForwardingRule() *schema.Resource {
|
|||
Required: true,
|
||||
ForceNew: true,
|
||||
},
|
||||
|
||||
"target": {
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
DiffSuppressFunc: compareSelfLinkRelativePaths,
|
||||
},
|
||||
|
||||
"ip_address": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Optional: true,
|
||||
ForceNew: true,
|
||||
},
|
||||
"ip_protocol": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Optional: true,
|
||||
ForceNew: true,
|
||||
ValidateFunc: validation.StringInSlice([]string{"TCP", "UDP", "ESP", "AH", "SCTP", "ICMP", ""}, false),
|
||||
DiffSuppressFunc: caseDiffSuppress,
|
||||
},
|
||||
"description": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
ForceNew: true,
|
||||
},
|
||||
|
||||
"ip_address": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
ForceNew: true,
|
||||
Computed: true,
|
||||
"ip_version": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
ForceNew: true,
|
||||
ValidateFunc: validation.StringInSlice([]string{"IPV4", "IPV6", ""}, false),
|
||||
},
|
||||
|
||||
"ip_protocol": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
ForceNew: true,
|
||||
Computed: true,
|
||||
},
|
||||
|
||||
"labels": {
|
||||
Removed: "This field is in beta. Use it in the the google-beta provider instead. See https://terraform.io/docs/providers/google/provider_versions.html for more details.",
|
||||
Type: schema.TypeMap,
|
||||
Optional: true,
|
||||
Elem: &schema.Schema{Type: schema.TypeString},
|
||||
},
|
||||
|
||||
"label_fingerprint": {
|
||||
Removed: "This field is in beta. Use it in the the google-beta provider instead. See https://terraform.io/docs/providers/google/provider_versions.html for more details.",
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
|
||||
"port_range": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
ForceNew: true,
|
||||
DiffSuppressFunc: portRangeDiffSuppress,
|
||||
},
|
||||
|
||||
"ip_version": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
ForceNew: true,
|
||||
ValidateFunc: validation.StringInSlice([]string{"IPV4", "IPV6"}, false),
|
||||
},
|
||||
|
||||
"project": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
ForceNew: true,
|
||||
},
|
||||
|
||||
"region": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
ForceNew: true,
|
||||
Removed: "Please remove this attribute (it was never used)",
|
||||
},
|
||||
|
||||
"self_link": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
|
@ -107,58 +101,179 @@ func resourceComputeGlobalForwardingRule() *schema.Resource {
|
|||
func resourceComputeGlobalForwardingRuleCreate(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
|
||||
obj := make(map[string]interface{})
|
||||
descriptionProp, err := expandComputeGlobalForwardingRuleDescription(d.Get("description"), d, config)
|
||||
if err != nil {
|
||||
return err
|
||||
} else if v, ok := d.GetOkExists("description"); !isEmptyValue(reflect.ValueOf(descriptionProp)) && (ok || !reflect.DeepEqual(v, descriptionProp)) {
|
||||
obj["description"] = descriptionProp
|
||||
}
|
||||
IPAddressProp, err := expandComputeGlobalForwardingRuleIPAddress(d.Get("ip_address"), d, config)
|
||||
if err != nil {
|
||||
return err
|
||||
} else if v, ok := d.GetOkExists("ip_address"); !isEmptyValue(reflect.ValueOf(IPAddressProp)) && (ok || !reflect.DeepEqual(v, IPAddressProp)) {
|
||||
obj["IPAddress"] = IPAddressProp
|
||||
}
|
||||
IPProtocolProp, err := expandComputeGlobalForwardingRuleIPProtocol(d.Get("ip_protocol"), d, config)
|
||||
if err != nil {
|
||||
return err
|
||||
} else if v, ok := d.GetOkExists("ip_protocol"); !isEmptyValue(reflect.ValueOf(IPProtocolProp)) && (ok || !reflect.DeepEqual(v, IPProtocolProp)) {
|
||||
obj["IPProtocol"] = IPProtocolProp
|
||||
}
|
||||
ipVersionProp, err := expandComputeGlobalForwardingRuleIpVersion(d.Get("ip_version"), d, config)
|
||||
if err != nil {
|
||||
return err
|
||||
} else if v, ok := d.GetOkExists("ip_version"); !isEmptyValue(reflect.ValueOf(ipVersionProp)) && (ok || !reflect.DeepEqual(v, ipVersionProp)) {
|
||||
obj["ipVersion"] = ipVersionProp
|
||||
}
|
||||
nameProp, err := expandComputeGlobalForwardingRuleName(d.Get("name"), d, config)
|
||||
if err != nil {
|
||||
return err
|
||||
} else if v, ok := d.GetOkExists("name"); !isEmptyValue(reflect.ValueOf(nameProp)) && (ok || !reflect.DeepEqual(v, nameProp)) {
|
||||
obj["name"] = nameProp
|
||||
}
|
||||
portRangeProp, err := expandComputeGlobalForwardingRulePortRange(d.Get("port_range"), d, config)
|
||||
if err != nil {
|
||||
return err
|
||||
} else if v, ok := d.GetOkExists("port_range"); !isEmptyValue(reflect.ValueOf(portRangeProp)) && (ok || !reflect.DeepEqual(v, portRangeProp)) {
|
||||
obj["portRange"] = portRangeProp
|
||||
}
|
||||
targetProp, err := expandComputeGlobalForwardingRuleTarget(d.Get("target"), d, config)
|
||||
if err != nil {
|
||||
return err
|
||||
} else if v, ok := d.GetOkExists("target"); !isEmptyValue(reflect.ValueOf(targetProp)) && (ok || !reflect.DeepEqual(v, targetProp)) {
|
||||
obj["target"] = targetProp
|
||||
}
|
||||
|
||||
url, err := replaceVars(d, config, "https://www.googleapis.com/compute/v1/projects/{{project}}/global/forwardingRules")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
log.Printf("[DEBUG] Creating new GlobalForwardingRule: %#v", obj)
|
||||
res, err := sendRequestWithTimeout(config, "POST", url, obj, d.Timeout(schema.TimeoutCreate))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating GlobalForwardingRule: %s", err)
|
||||
}
|
||||
|
||||
// Store the ID now
|
||||
id, err := replaceVars(d, config, "{{name}}")
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error constructing id: %s", err)
|
||||
}
|
||||
d.SetId(id)
|
||||
|
||||
project, err := getProject(d, config)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
frule := &computeBeta.ForwardingRule{
|
||||
IPAddress: d.Get("ip_address").(string),
|
||||
IPProtocol: d.Get("ip_protocol").(string),
|
||||
IpVersion: d.Get("ip_version").(string),
|
||||
Description: d.Get("description").(string),
|
||||
Name: d.Get("name").(string),
|
||||
PortRange: d.Get("port_range").(string),
|
||||
Target: d.Get("target").(string),
|
||||
}
|
||||
|
||||
op, err := config.clientComputeBeta.GlobalForwardingRules.Insert(project, frule).Do()
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating Global Forwarding Rule: %s", err)
|
||||
}
|
||||
|
||||
// It probably maybe worked, so store the ID now
|
||||
d.SetId(frule.Name)
|
||||
|
||||
err = computeSharedOperationWait(config.clientCompute, op, project, "Creating Global Fowarding Rule")
|
||||
op := &compute.Operation{}
|
||||
err = Convert(res, op)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
waitErr := computeOperationWaitTime(
|
||||
config.clientCompute, op, project, "Creating GlobalForwardingRule",
|
||||
int(d.Timeout(schema.TimeoutCreate).Minutes()))
|
||||
|
||||
if waitErr != nil {
|
||||
// The resource didn't actually create
|
||||
d.SetId("")
|
||||
return fmt.Errorf("Error waiting to create GlobalForwardingRule: %s", waitErr)
|
||||
}
|
||||
|
||||
log.Printf("[DEBUG] Finished creating GlobalForwardingRule %q: %#v", d.Id(), res)
|
||||
|
||||
return resourceComputeGlobalForwardingRuleRead(d, meta)
|
||||
}
|
||||
|
||||
func resourceComputeGlobalForwardingRuleRead(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
|
||||
url, err := replaceVars(d, config, "https://www.googleapis.com/compute/v1/projects/{{project}}/global/forwardingRules/{{name}}")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
res, err := sendRequest(config, "GET", url, nil)
|
||||
if err != nil {
|
||||
return handleNotFoundError(err, d, fmt.Sprintf("ComputeGlobalForwardingRule %q", d.Id()))
|
||||
}
|
||||
|
||||
project, err := getProject(d, config)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := d.Set("project", project); err != nil {
|
||||
return fmt.Errorf("Error reading GlobalForwardingRule: %s", err)
|
||||
}
|
||||
|
||||
if err := d.Set("description", flattenComputeGlobalForwardingRuleDescription(res["description"], d)); err != nil {
|
||||
return fmt.Errorf("Error reading GlobalForwardingRule: %s", err)
|
||||
}
|
||||
if err := d.Set("ip_address", flattenComputeGlobalForwardingRuleIPAddress(res["IPAddress"], d)); err != nil {
|
||||
return fmt.Errorf("Error reading GlobalForwardingRule: %s", err)
|
||||
}
|
||||
if err := d.Set("ip_protocol", flattenComputeGlobalForwardingRuleIPProtocol(res["IPProtocol"], d)); err != nil {
|
||||
return fmt.Errorf("Error reading GlobalForwardingRule: %s", err)
|
||||
}
|
||||
if err := d.Set("ip_version", flattenComputeGlobalForwardingRuleIpVersion(res["ipVersion"], d)); err != nil {
|
||||
return fmt.Errorf("Error reading GlobalForwardingRule: %s", err)
|
||||
}
|
||||
if err := d.Set("name", flattenComputeGlobalForwardingRuleName(res["name"], d)); err != nil {
|
||||
return fmt.Errorf("Error reading GlobalForwardingRule: %s", err)
|
||||
}
|
||||
if err := d.Set("port_range", flattenComputeGlobalForwardingRulePortRange(res["portRange"], d)); err != nil {
|
||||
return fmt.Errorf("Error reading GlobalForwardingRule: %s", err)
|
||||
}
|
||||
if err := d.Set("target", flattenComputeGlobalForwardingRuleTarget(res["target"], d)); err != nil {
|
||||
return fmt.Errorf("Error reading GlobalForwardingRule: %s", err)
|
||||
}
|
||||
if err := d.Set("self_link", ConvertSelfLinkToV1(res["selfLink"].(string))); err != nil {
|
||||
return fmt.Errorf("Error reading GlobalForwardingRule: %s", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func resourceComputeGlobalForwardingRuleUpdate(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
|
||||
project, err := getProject(d, config)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
d.Partial(true)
|
||||
|
||||
if d.HasChange("target") {
|
||||
target := d.Get("target").(string)
|
||||
targetRef := &compute.TargetReference{Target: target}
|
||||
|
||||
op, err := config.clientCompute.GlobalForwardingRules.SetTarget(
|
||||
project, d.Id(), targetRef).Do()
|
||||
obj := make(map[string]interface{})
|
||||
targetProp, err := expandComputeGlobalForwardingRuleTarget(d.Get("target"), d, config)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error updating target: %s", err)
|
||||
return err
|
||||
} else if v, ok := d.GetOkExists("target"); !isEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, targetProp)) {
|
||||
obj["target"] = targetProp
|
||||
}
|
||||
|
||||
err = computeSharedOperationWait(config.clientCompute, op, project, "Updating Global Forwarding Rule")
|
||||
url, err := replaceVars(d, config, "https://www.googleapis.com/compute/v1/projects/{{project}}/global/forwardingRules/{{name}}/setTarget")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
res, err := sendRequestWithTimeout(config, "POST", url, obj, d.Timeout(schema.TimeoutUpdate))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error updating GlobalForwardingRule %q: %s", d.Id(), err)
|
||||
}
|
||||
|
||||
project, err := getProject(d, config)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
op := &compute.Operation{}
|
||||
err = Convert(res, op)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = computeOperationWaitTime(
|
||||
config.clientCompute, op, project, "Updating GlobalForwardingRule",
|
||||
int(d.Timeout(schema.TimeoutUpdate).Minutes()))
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -171,53 +286,111 @@ func resourceComputeGlobalForwardingRuleUpdate(d *schema.ResourceData, meta inte
|
|||
return resourceComputeGlobalForwardingRuleRead(d, meta)
|
||||
}
|
||||
|
||||
func resourceComputeGlobalForwardingRuleRead(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
|
||||
project, err := getProject(d, config)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
frule, err := config.clientComputeBeta.GlobalForwardingRules.Get(project, d.Id()).Do()
|
||||
if err != nil {
|
||||
return handleNotFoundError(err, d, fmt.Sprintf("Global Forwarding Rule %q", d.Get("name").(string)))
|
||||
}
|
||||
|
||||
d.Set("name", frule.Name)
|
||||
d.Set("description", frule.Description)
|
||||
d.Set("target", frule.Target)
|
||||
d.Set("port_range", frule.PortRange)
|
||||
d.Set("ip_address", frule.IPAddress)
|
||||
d.Set("ip_protocol", frule.IPProtocol)
|
||||
d.Set("ip_version", frule.IpVersion)
|
||||
d.Set("self_link", ConvertSelfLinkToV1(frule.SelfLink))
|
||||
// removed lists need something set
|
||||
d.Set("labels", nil)
|
||||
d.Set("project", project)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func resourceComputeGlobalForwardingRuleDelete(d *schema.ResourceData, meta interface{}) error {
|
||||
config := meta.(*Config)
|
||||
|
||||
url, err := replaceVars(d, config, "https://www.googleapis.com/compute/v1/projects/{{project}}/global/forwardingRules/{{name}}")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var obj map[string]interface{}
|
||||
log.Printf("[DEBUG] Deleting GlobalForwardingRule %q", d.Id())
|
||||
res, err := sendRequestWithTimeout(config, "DELETE", url, obj, d.Timeout(schema.TimeoutDelete))
|
||||
if err != nil {
|
||||
return handleNotFoundError(err, d, "GlobalForwardingRule")
|
||||
}
|
||||
|
||||
project, err := getProject(d, config)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Delete the GlobalForwardingRule
|
||||
log.Printf("[DEBUG] GlobalForwardingRule delete request")
|
||||
op, err := config.clientCompute.GlobalForwardingRules.Delete(project, d.Id()).Do()
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error deleting GlobalForwardingRule: %s", err)
|
||||
}
|
||||
err = computeSharedOperationWait(config.clientCompute, op, project, "Deleting GlobalForwarding Rule")
|
||||
op := &compute.Operation{}
|
||||
err = Convert(res, op)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
d.SetId("")
|
||||
err = computeOperationWaitTime(
|
||||
config.clientCompute, op, project, "Deleting GlobalForwardingRule",
|
||||
int(d.Timeout(schema.TimeoutDelete).Minutes()))
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
log.Printf("[DEBUG] Finished deleting GlobalForwardingRule %q: %#v", d.Id(), res)
|
||||
return nil
|
||||
}
|
||||
|
||||
func resourceComputeGlobalForwardingRuleImport(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) {
|
||||
config := meta.(*Config)
|
||||
if err := parseImportId([]string{"projects/(?P<project>[^/]+)/global/forwardingRules/(?P<name>[^/]+)", "(?P<project>[^/]+)/(?P<name>[^/]+)", "(?P<name>[^/]+)"}, d, config); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Replace import id for the resource id
|
||||
id, err := replaceVars(d, config, "{{name}}")
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Error constructing id: %s", err)
|
||||
}
|
||||
d.SetId(id)
|
||||
|
||||
return []*schema.ResourceData{d}, nil
|
||||
}
|
||||
|
||||
func flattenComputeGlobalForwardingRuleDescription(v interface{}, d *schema.ResourceData) interface{} {
|
||||
return v
|
||||
}
|
||||
|
||||
func flattenComputeGlobalForwardingRuleIPAddress(v interface{}, d *schema.ResourceData) interface{} {
|
||||
return v
|
||||
}
|
||||
|
||||
func flattenComputeGlobalForwardingRuleIPProtocol(v interface{}, d *schema.ResourceData) interface{} {
|
||||
return v
|
||||
}
|
||||
|
||||
func flattenComputeGlobalForwardingRuleIpVersion(v interface{}, d *schema.ResourceData) interface{} {
|
||||
return v
|
||||
}
|
||||
|
||||
func flattenComputeGlobalForwardingRuleName(v interface{}, d *schema.ResourceData) interface{} {
|
||||
return v
|
||||
}
|
||||
|
||||
func flattenComputeGlobalForwardingRulePortRange(v interface{}, d *schema.ResourceData) interface{} {
|
||||
return v
|
||||
}
|
||||
|
||||
func flattenComputeGlobalForwardingRuleTarget(v interface{}, d *schema.ResourceData) interface{} {
|
||||
return v
|
||||
}
|
||||
|
||||
func expandComputeGlobalForwardingRuleDescription(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) {
|
||||
return v, nil
|
||||
}
|
||||
|
||||
func expandComputeGlobalForwardingRuleIPAddress(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) {
|
||||
return v, nil
|
||||
}
|
||||
|
||||
func expandComputeGlobalForwardingRuleIPProtocol(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) {
|
||||
return v, nil
|
||||
}
|
||||
|
||||
func expandComputeGlobalForwardingRuleIpVersion(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) {
|
||||
return v, nil
|
||||
}
|
||||
|
||||
func expandComputeGlobalForwardingRuleName(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) {
|
||||
return v, nil
|
||||
}
|
||||
|
||||
func expandComputeGlobalForwardingRulePortRange(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) {
|
||||
return v, nil
|
||||
}
|
||||
|
||||
func expandComputeGlobalForwardingRuleTarget(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) {
|
||||
return v, nil
|
||||
}
|
||||
|
|
127
google/resource_compute_global_forwarding_rule_generated_test.go
Normal file
127
google/resource_compute_global_forwarding_rule_generated_test.go
Normal file
|
@ -0,0 +1,127 @@
|
|||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// *** 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
|
||||
// .github/CONTRIBUTING.md.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
package google
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/terraform/helper/acctest"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/terraform"
|
||||
)
|
||||
|
||||
func TestAccComputeGlobalForwardingRule_globalForwardingRuleHttpExample(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
context := map[string]interface{}{
|
||||
"random_suffix": acctest.RandString(10),
|
||||
}
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testAccCheckComputeGlobalForwardingRuleDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: testAccComputeGlobalForwardingRule_globalForwardingRuleHttpExample(context),
|
||||
},
|
||||
{
|
||||
ResourceName: "google_compute_global_forwarding_rule.default",
|
||||
ImportState: true,
|
||||
ImportStateVerify: true,
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func testAccComputeGlobalForwardingRule_globalForwardingRuleHttpExample(context map[string]interface{}) string {
|
||||
return Nprintf(`
|
||||
resource "google_compute_global_forwarding_rule" "default" {
|
||||
name = "global-rule-%{random_suffix}"
|
||||
target = "${google_compute_target_http_proxy.default.self_link}"
|
||||
port_range = "80"
|
||||
}
|
||||
|
||||
resource "google_compute_target_http_proxy" "default" {
|
||||
name = "target-proxy-%{random_suffix}"
|
||||
description = "a description"
|
||||
url_map = "${google_compute_url_map.default.self_link}"
|
||||
}
|
||||
|
||||
resource "google_compute_url_map" "default" {
|
||||
name = "url-map-target-proxy-%{random_suffix}"
|
||||
description = "a description"
|
||||
default_service = "${google_compute_backend_service.default.self_link}"
|
||||
|
||||
host_rule {
|
||||
hosts = ["mysite.com"]
|
||||
path_matcher = "allpaths"
|
||||
}
|
||||
|
||||
path_matcher {
|
||||
name = "allpaths"
|
||||
default_service = "${google_compute_backend_service.default.self_link}"
|
||||
|
||||
path_rule {
|
||||
paths = ["/*"]
|
||||
service = "${google_compute_backend_service.default.self_link}"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
resource "google_compute_backend_service" "default" {
|
||||
name = "backend-%{random_suffix}"
|
||||
port_name = "http"
|
||||
protocol = "HTTP"
|
||||
timeout_sec = 10
|
||||
|
||||
health_checks = ["${google_compute_http_health_check.default.self_link}"]
|
||||
}
|
||||
|
||||
resource "google_compute_http_health_check" "default" {
|
||||
name = "check-backend-%{random_suffix}"
|
||||
request_path = "/"
|
||||
check_interval_sec = 1
|
||||
timeout_sec = 1
|
||||
}
|
||||
`, context)
|
||||
}
|
||||
|
||||
func testAccCheckComputeGlobalForwardingRuleDestroy(s *terraform.State) error {
|
||||
for name, rs := range s.RootModule().Resources {
|
||||
if rs.Type != "google_compute_global_forwarding_rule" {
|
||||
continue
|
||||
}
|
||||
if strings.HasPrefix(name, "data.") {
|
||||
continue
|
||||
}
|
||||
|
||||
config := testAccProvider.Meta().(*Config)
|
||||
|
||||
url, err := replaceVarsForTest(rs, "https://www.googleapis.com/compute/v1/projects/{{project}}/global/forwardingRules/{{name}}")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
_, err = sendRequest(config, "GET", url, nil)
|
||||
if err == nil {
|
||||
return fmt.Errorf("ComputeGlobalForwardingRule still exists at %s", url)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
|
@ -2,21 +2,19 @@ package google
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"regexp"
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/terraform/helper/acctest"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/terraform"
|
||||
|
||||
computeBeta "google.golang.org/api/compute/v0.beta"
|
||||
)
|
||||
|
||||
func TestAccComputeGlobalForwardingRule_basic(t *testing.T) {
|
||||
func TestAccComputeGlobalForwardingRule_updateTarget(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
fr := fmt.Sprintf("forwardrule-test-%s", acctest.RandString(10))
|
||||
proxy1 := fmt.Sprintf("forwardrule-test-%s", acctest.RandString(10))
|
||||
proxy2 := fmt.Sprintf("forwardrule-test-%s", acctest.RandString(10))
|
||||
proxy := fmt.Sprintf("forwardrule-test-%s", acctest.RandString(10))
|
||||
proxyUpdated := fmt.Sprintf("forwardrule-test-%s", acctest.RandString(10))
|
||||
backend := fmt.Sprintf("forwardrule-test-%s", acctest.RandString(10))
|
||||
hc := fmt.Sprintf("forwardrule-test-%s", acctest.RandString(10))
|
||||
urlmap := fmt.Sprintf("forwardrule-test-%s", acctest.RandString(10))
|
||||
|
@ -27,53 +25,28 @@ func TestAccComputeGlobalForwardingRule_basic(t *testing.T) {
|
|||
CheckDestroy: testAccCheckComputeGlobalForwardingRuleDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: testAccComputeGlobalForwardingRule_basic1(fr, proxy1, proxy2, backend, hc, urlmap),
|
||||
Config: testAccComputeGlobalForwardingRule_httpProxy(fr, "proxy", proxy, proxyUpdated, backend, hc, urlmap),
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckComputeGlobalForwardingRuleExists(
|
||||
"google_compute_global_forwarding_rule.foobar"),
|
||||
|
||||
// Unlike GlobalAddress, IpVersion is "" instead of "IPV4" when this is made with a v1 API.
|
||||
testAccCheckComputeBetaGlobalForwardingRuleIpVersion("google_compute_global_forwarding_rule.foobar", ""),
|
||||
resource.TestMatchResourceAttr(
|
||||
"google_compute_global_forwarding_rule.forwarding_rule", "target", regexp.MustCompile(proxy+"$")),
|
||||
),
|
||||
},
|
||||
{
|
||||
ResourceName: "google_compute_global_forwarding_rule.foobar",
|
||||
ResourceName: "google_compute_global_forwarding_rule.forwarding_rule",
|
||||
ImportState: true,
|
||||
ImportStateVerify: true,
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func TestAccComputeGlobalForwardingRule_update(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
fr := fmt.Sprintf("forwardrule-test-%s", acctest.RandString(10))
|
||||
proxy1 := fmt.Sprintf("forwardrule-test-%s", acctest.RandString(10))
|
||||
proxy2 := fmt.Sprintf("forwardrule-test-%s", acctest.RandString(10))
|
||||
backend := fmt.Sprintf("forwardrule-test-%s", acctest.RandString(10))
|
||||
hc := fmt.Sprintf("forwardrule-test-%s", acctest.RandString(10))
|
||||
urlmap := fmt.Sprintf("forwardrule-test-%s", acctest.RandString(10))
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testAccCheckComputeGlobalForwardingRuleDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: testAccComputeGlobalForwardingRule_basic1(fr, proxy1, proxy2, backend, hc, urlmap),
|
||||
Config: testAccComputeGlobalForwardingRule_httpProxy(fr, "proxy2", proxy, proxyUpdated, backend, hc, urlmap),
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckComputeGlobalForwardingRuleExists(
|
||||
"google_compute_global_forwarding_rule.foobar"),
|
||||
resource.TestMatchResourceAttr(
|
||||
"google_compute_global_forwarding_rule.forwarding_rule", "target", regexp.MustCompile(proxyUpdated+"$")),
|
||||
),
|
||||
},
|
||||
|
||||
{
|
||||
Config: testAccComputeGlobalForwardingRule_basic2(fr, proxy1, proxy2, backend, hc, urlmap),
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckComputeGlobalForwardingRuleExists(
|
||||
"google_compute_global_forwarding_rule.foobar"),
|
||||
),
|
||||
ResourceName: "google_compute_global_forwarding_rule.forwarding_rule",
|
||||
ImportState: true,
|
||||
ImportStateVerify: true,
|
||||
},
|
||||
},
|
||||
})
|
||||
|
@ -82,11 +55,8 @@ func TestAccComputeGlobalForwardingRule_update(t *testing.T) {
|
|||
func TestAccComputeGlobalForwardingRule_ipv6(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
var frule computeBeta.ForwardingRule
|
||||
|
||||
fr := fmt.Sprintf("forwardrule-test-%s", acctest.RandString(10))
|
||||
proxy1 := fmt.Sprintf("forwardrule-test-%s", acctest.RandString(10))
|
||||
proxy2 := fmt.Sprintf("forwardrule-test-%s", acctest.RandString(10))
|
||||
proxy := fmt.Sprintf("forwardrule-test-%s", acctest.RandString(10))
|
||||
backend := fmt.Sprintf("forwardrule-test-%s", acctest.RandString(10))
|
||||
hc := fmt.Sprintf("forwardrule-test-%s", acctest.RandString(10))
|
||||
urlmap := fmt.Sprintf("forwardrule-test-%s", acctest.RandString(10))
|
||||
|
@ -97,15 +67,14 @@ func TestAccComputeGlobalForwardingRule_ipv6(t *testing.T) {
|
|||
CheckDestroy: testAccCheckComputeGlobalForwardingRuleDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: testAccComputeGlobalForwardingRule_ipv6(fr, proxy1, proxy2, backend, hc, urlmap),
|
||||
Config: testAccComputeGlobalForwardingRule_ipv6(fr, proxy, backend, hc, urlmap),
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckComputeBetaGlobalForwardingRuleExists(
|
||||
"google_compute_global_forwarding_rule.foobar", &frule),
|
||||
testAccCheckComputeBetaGlobalForwardingRuleIpVersion("google_compute_global_forwarding_rule.foobar", "IPV6"),
|
||||
resource.TestCheckResourceAttr(
|
||||
"google_compute_global_forwarding_rule.forwarding_rule", "ip_version", "IPV6"),
|
||||
),
|
||||
},
|
||||
{
|
||||
ResourceName: "google_compute_global_forwarding_rule.foobar",
|
||||
ResourceName: "google_compute_global_forwarding_rule.forwarding_rule",
|
||||
ImportState: true,
|
||||
ImportStateVerify: true,
|
||||
},
|
||||
|
@ -113,129 +82,29 @@ func TestAccComputeGlobalForwardingRule_ipv6(t *testing.T) {
|
|||
})
|
||||
}
|
||||
|
||||
func testAccCheckComputeGlobalForwardingRuleDestroy(s *terraform.State) error {
|
||||
config := testAccProvider.Meta().(*Config)
|
||||
|
||||
for _, rs := range s.RootModule().Resources {
|
||||
if rs.Type != "google_compute_global_forwarding_rule" {
|
||||
continue
|
||||
}
|
||||
|
||||
_, err := config.clientCompute.GlobalForwardingRules.Get(
|
||||
config.Project, rs.Primary.ID).Do()
|
||||
if err == nil {
|
||||
return fmt.Errorf("Global Forwarding Rule still exists")
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func testAccCheckComputeGlobalForwardingRuleExists(n string) resource.TestCheckFunc {
|
||||
return func(s *terraform.State) error {
|
||||
rs, ok := s.RootModule().Resources[n]
|
||||
if !ok {
|
||||
return fmt.Errorf("Not found: %s", n)
|
||||
}
|
||||
|
||||
if rs.Primary.ID == "" {
|
||||
return fmt.Errorf("No ID is set")
|
||||
}
|
||||
|
||||
config := testAccProvider.Meta().(*Config)
|
||||
|
||||
found, err := config.clientCompute.GlobalForwardingRules.Get(
|
||||
config.Project, rs.Primary.ID).Do()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if found.Name != rs.Primary.ID {
|
||||
return fmt.Errorf("Global Forwarding Rule not found")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
func testAccCheckComputeBetaGlobalForwardingRuleExists(n string, frule *computeBeta.ForwardingRule) resource.TestCheckFunc {
|
||||
return func(s *terraform.State) error {
|
||||
rs, ok := s.RootModule().Resources[n]
|
||||
if !ok {
|
||||
return fmt.Errorf("Not found: %s", n)
|
||||
}
|
||||
|
||||
if rs.Primary.ID == "" {
|
||||
return fmt.Errorf("No ID is set")
|
||||
}
|
||||
|
||||
config := testAccProvider.Meta().(*Config)
|
||||
|
||||
found, err := config.clientComputeBeta.GlobalForwardingRules.Get(
|
||||
config.Project, rs.Primary.ID).Do()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if found.Name != rs.Primary.ID {
|
||||
return fmt.Errorf("Global Forwarding Rule not found")
|
||||
}
|
||||
|
||||
*frule = *found
|
||||
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
func testAccCheckComputeBetaGlobalForwardingRuleIpVersion(n, version string) resource.TestCheckFunc {
|
||||
return func(s *terraform.State) error {
|
||||
rs, ok := s.RootModule().Resources[n]
|
||||
if !ok {
|
||||
return fmt.Errorf("Not found: %s", n)
|
||||
}
|
||||
|
||||
if rs.Primary.ID == "" {
|
||||
return fmt.Errorf("No ID is set")
|
||||
}
|
||||
|
||||
config := testAccProvider.Meta().(*Config)
|
||||
|
||||
frule, err := config.clientComputeBeta.GlobalForwardingRules.Get(config.Project, rs.Primary.ID).Do()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if frule.IpVersion != version {
|
||||
return fmt.Errorf("Expected IP version to be %s, got %s", version, frule.IpVersion)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
func testAccComputeGlobalForwardingRule_basic1(fr, proxy1, proxy2, backend, hc, urlmap string) string {
|
||||
func testAccComputeGlobalForwardingRule_httpProxy(fr, targetProxy, proxy, proxy2, backend, hc, urlmap string) string {
|
||||
return fmt.Sprintf(`
|
||||
resource "google_compute_global_forwarding_rule" "foobar" {
|
||||
resource "google_compute_global_forwarding_rule" "forwarding_rule" {
|
||||
description = "Resource created for Terraform acceptance testing"
|
||||
ip_protocol = "TCP"
|
||||
name = "%s"
|
||||
port_range = "80"
|
||||
target = "${google_compute_target_http_proxy.foobar1.self_link}"
|
||||
target = "${google_compute_target_http_proxy.%s.self_link}"
|
||||
}
|
||||
|
||||
resource "google_compute_target_http_proxy" "foobar1" {
|
||||
resource "google_compute_target_http_proxy" "proxy" {
|
||||
description = "Resource created for Terraform acceptance testing"
|
||||
name = "%s"
|
||||
url_map = "${google_compute_url_map.foobar.self_link}"
|
||||
url_map = "${google_compute_url_map.url_map.self_link}"
|
||||
}
|
||||
|
||||
resource "google_compute_target_http_proxy" "foobar2" {
|
||||
resource "google_compute_target_http_proxy" "proxy2" {
|
||||
description = "Resource created for Terraform acceptance testing"
|
||||
name = "%s"
|
||||
url_map = "${google_compute_url_map.foobar.self_link}"
|
||||
url_map = "${google_compute_url_map.url_map.self_link}"
|
||||
}
|
||||
|
||||
resource "google_compute_backend_service" "foobar" {
|
||||
resource "google_compute_backend_service" "backend" {
|
||||
name = "%s"
|
||||
health_checks = ["${google_compute_http_health_check.zero.self_link}"]
|
||||
}
|
||||
|
@ -247,110 +116,47 @@ func testAccComputeGlobalForwardingRule_basic1(fr, proxy1, proxy2, backend, hc,
|
|||
timeout_sec = 1
|
||||
}
|
||||
|
||||
resource "google_compute_url_map" "foobar" {
|
||||
resource "google_compute_url_map" "url_map" {
|
||||
name = "%s"
|
||||
default_service = "${google_compute_backend_service.foobar.self_link}"
|
||||
default_service = "${google_compute_backend_service.backend.self_link}"
|
||||
host_rule {
|
||||
hosts = ["mysite.com", "myothersite.com"]
|
||||
path_matcher = "boop"
|
||||
}
|
||||
path_matcher {
|
||||
default_service = "${google_compute_backend_service.foobar.self_link}"
|
||||
default_service = "${google_compute_backend_service.backend.self_link}"
|
||||
name = "boop"
|
||||
path_rule {
|
||||
paths = ["/*"]
|
||||
service = "${google_compute_backend_service.foobar.self_link}"
|
||||
service = "${google_compute_backend_service.backend.self_link}"
|
||||
}
|
||||
}
|
||||
test {
|
||||
host = "mysite.com"
|
||||
path = "/*"
|
||||
service = "${google_compute_backend_service.foobar.self_link}"
|
||||
service = "${google_compute_backend_service.backend.self_link}"
|
||||
}
|
||||
}`, fr, proxy1, proxy2, backend, hc, urlmap)
|
||||
}`, fr, targetProxy, proxy, proxy2, backend, hc, urlmap)
|
||||
}
|
||||
|
||||
func testAccComputeGlobalForwardingRule_basic2(fr, proxy1, proxy2, backend, hc, urlmap string) string {
|
||||
func testAccComputeGlobalForwardingRule_ipv6(fr, proxy, backend, hc, urlmap string) string {
|
||||
return fmt.Sprintf(`
|
||||
resource "google_compute_global_forwarding_rule" "foobar" {
|
||||
resource "google_compute_global_forwarding_rule" "forwarding_rule" {
|
||||
description = "Resource created for Terraform acceptance testing"
|
||||
ip_protocol = "TCP"
|
||||
name = "%s"
|
||||
port_range = "80"
|
||||
target = "${google_compute_target_http_proxy.foobar2.self_link}"
|
||||
}
|
||||
|
||||
resource "google_compute_target_http_proxy" "foobar1" {
|
||||
description = "Resource created for Terraform acceptance testing"
|
||||
name = "%s"
|
||||
url_map = "${google_compute_url_map.foobar.self_link}"
|
||||
}
|
||||
|
||||
resource "google_compute_target_http_proxy" "foobar2" {
|
||||
description = "Resource created for Terraform acceptance testing"
|
||||
name = "%s"
|
||||
url_map = "${google_compute_url_map.foobar.self_link}"
|
||||
}
|
||||
|
||||
resource "google_compute_backend_service" "foobar" {
|
||||
name = "%s"
|
||||
health_checks = ["${google_compute_http_health_check.zero.self_link}"]
|
||||
}
|
||||
|
||||
resource "google_compute_http_health_check" "zero" {
|
||||
name = "%s"
|
||||
request_path = "/"
|
||||
check_interval_sec = 1
|
||||
timeout_sec = 1
|
||||
}
|
||||
|
||||
resource "google_compute_url_map" "foobar" {
|
||||
name = "%s"
|
||||
default_service = "${google_compute_backend_service.foobar.self_link}"
|
||||
host_rule {
|
||||
hosts = ["mysite.com", "myothersite.com"]
|
||||
path_matcher = "boop"
|
||||
}
|
||||
path_matcher {
|
||||
default_service = "${google_compute_backend_service.foobar.self_link}"
|
||||
name = "boop"
|
||||
path_rule {
|
||||
paths = ["/*"]
|
||||
service = "${google_compute_backend_service.foobar.self_link}"
|
||||
}
|
||||
}
|
||||
test {
|
||||
host = "mysite.com"
|
||||
path = "/*"
|
||||
service = "${google_compute_backend_service.foobar.self_link}"
|
||||
}
|
||||
}`, fr, proxy1, proxy2, backend, hc, urlmap)
|
||||
}
|
||||
|
||||
func testAccComputeGlobalForwardingRule_ipv6(fr, proxy1, proxy2, backend, hc, urlmap string) string {
|
||||
return fmt.Sprintf(`
|
||||
resource "google_compute_global_forwarding_rule" "foobar" {
|
||||
description = "Resource created for Terraform acceptance testing"
|
||||
ip_protocol = "TCP"
|
||||
name = "%s"
|
||||
port_range = "80"
|
||||
target = "${google_compute_target_http_proxy.foobar1.self_link}"
|
||||
target = "${google_compute_target_http_proxy.proxy.self_link}"
|
||||
ip_version = "IPV6"
|
||||
}
|
||||
|
||||
resource "google_compute_target_http_proxy" "foobar1" {
|
||||
resource "google_compute_target_http_proxy" "proxy" {
|
||||
description = "Resource created for Terraform acceptance testing"
|
||||
name = "%s"
|
||||
url_map = "${google_compute_url_map.foobar.self_link}"
|
||||
url_map = "${google_compute_url_map.urlmap.self_link}"
|
||||
}
|
||||
|
||||
resource "google_compute_target_http_proxy" "foobar2" {
|
||||
description = "Resource created for Terraform acceptance testing"
|
||||
name = "%s"
|
||||
url_map = "${google_compute_url_map.foobar.self_link}"
|
||||
}
|
||||
|
||||
resource "google_compute_backend_service" "foobar" {
|
||||
resource "google_compute_backend_service" "backend" {
|
||||
name = "%s"
|
||||
health_checks = ["${google_compute_http_health_check.zero.self_link}"]
|
||||
}
|
||||
|
@ -362,25 +168,25 @@ func testAccComputeGlobalForwardingRule_ipv6(fr, proxy1, proxy2, backend, hc, ur
|
|||
timeout_sec = 1
|
||||
}
|
||||
|
||||
resource "google_compute_url_map" "foobar" {
|
||||
resource "google_compute_url_map" "urlmap" {
|
||||
name = "%s"
|
||||
default_service = "${google_compute_backend_service.foobar.self_link}"
|
||||
default_service = "${google_compute_backend_service.backend.self_link}"
|
||||
host_rule {
|
||||
hosts = ["mysite.com", "myothersite.com"]
|
||||
path_matcher = "boop"
|
||||
}
|
||||
path_matcher {
|
||||
default_service = "${google_compute_backend_service.foobar.self_link}"
|
||||
default_service = "${google_compute_backend_service.backend.self_link}"
|
||||
name = "boop"
|
||||
path_rule {
|
||||
paths = ["/*"]
|
||||
service = "${google_compute_backend_service.foobar.self_link}"
|
||||
service = "${google_compute_backend_service.backend.self_link}"
|
||||
}
|
||||
}
|
||||
test {
|
||||
host = "mysite.com"
|
||||
path = "/*"
|
||||
service = "${google_compute_backend_service.foobar.self_link}"
|
||||
service = "${google_compute_backend_service.backend.self_link}"
|
||||
}
|
||||
}`, fr, proxy1, proxy2, backend, hc, urlmap)
|
||||
}`, fr, proxy, backend, hc, urlmap)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user