provider/google: Support Import of 'google_compute_forwarding_rule'
This commit is contained in:
parent
3fc119923e
commit
b45650c390
|
@ -0,0 +1,32 @@
|
|||
package google
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/terraform/helper/acctest"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
)
|
||||
|
||||
func TestAccComputeForwardingRule_importBasic(t *testing.T) {
|
||||
resourceName := "google_compute_forwarding_rule.foobar"
|
||||
poolName := fmt.Sprintf("tf-%s", acctest.RandString(10))
|
||||
ruleName := fmt.Sprintf("tf-%s", acctest.RandString(10))
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testAccCheckComputeForwardingRuleDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
resource.TestStep{
|
||||
Config: testAccComputeForwardingRule_basic(poolName, ruleName),
|
||||
},
|
||||
|
||||
resource.TestStep{
|
||||
ResourceName: resourceName,
|
||||
ImportState: true,
|
||||
ImportStateVerify: true,
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
|
@ -15,6 +15,9 @@ func resourceComputeForwardingRule() *schema.Resource {
|
|||
Read: resourceComputeForwardingRuleRead,
|
||||
Delete: resourceComputeForwardingRuleDelete,
|
||||
Update: resourceComputeForwardingRuleUpdate,
|
||||
Importer: &schema.ResourceImporter{
|
||||
State: schema.ImportStatePassthrough,
|
||||
},
|
||||
|
||||
Schema: map[string]*schema.Schema{
|
||||
"name": &schema.Schema{
|
||||
|
@ -59,12 +62,14 @@ func resourceComputeForwardingRule() *schema.Resource {
|
|||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
ForceNew: true,
|
||||
Computed: true,
|
||||
},
|
||||
|
||||
"region": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
ForceNew: true,
|
||||
Computed: true,
|
||||
},
|
||||
|
||||
"self_link": &schema.Schema{
|
||||
|
@ -179,10 +184,15 @@ func resourceComputeForwardingRuleRead(d *schema.ResourceData, meta interface{})
|
|||
return fmt.Errorf("Error reading ForwardingRule: %s", err)
|
||||
}
|
||||
|
||||
d.Set("name", frule.Name)
|
||||
d.Set("target", frule.Target)
|
||||
d.Set("description", frule.Description)
|
||||
d.Set("port_range", frule.PortRange)
|
||||
d.Set("project", project)
|
||||
d.Set("region", region)
|
||||
d.Set("ip_address", frule.IPAddress)
|
||||
d.Set("ip_protocol", frule.IPProtocol)
|
||||
d.Set("self_link", frule.SelfLink)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue