diff --git a/builtin/providers/aws/resource_aws_load_balancer_backend_server_policy.go b/builtin/providers/aws/resource_aws_load_balancer_backend_server_policy.go index 0bdd85f94..d3759ffcb 100644 --- a/builtin/providers/aws/resource_aws_load_balancer_backend_server_policy.go +++ b/builtin/providers/aws/resource_aws_load_balancer_backend_server_policy.go @@ -60,10 +60,7 @@ func resourceAwsLoadBalancerBackendServerPoliciesCreate(d *schema.ResourceData, } d.SetId(fmt.Sprintf("%s:%s", *setOpts.LoadBalancerName, strconv.FormatInt(*setOpts.InstancePort, 10))) - d.Set("load_balancer_name", setOpts.LoadBalancerName) - d.Set("instance_port", setOpts.InstancePort) - d.Set("policy_names", flattenStringList(setOpts.PolicyNames)) - return nil + return resourceAwsLoadBalancerBackendServerPoliciesRead(d, meta) } func resourceAwsLoadBalancerBackendServerPoliciesRead(d *schema.ResourceData, meta interface{}) error { @@ -81,6 +78,7 @@ func resourceAwsLoadBalancerBackendServerPoliciesRead(d *schema.ResourceData, me if ec2err, ok := err.(awserr.Error); ok { if ec2err.Code() == "LoadBalancerNotFound" { return fmt.Errorf("LoadBalancerNotFound: %s", err) + d.SetId("") } } return fmt.Errorf("Error retrieving ELB description: %s", err) @@ -130,6 +128,7 @@ func resourceAwsLoadBalancerBackendServerPoliciesDelete(d *schema.ResourceData, return fmt.Errorf("Error setting LoadBalancerPoliciesForBackendServer: %s", err) } + d.SetId("") return nil } diff --git a/builtin/providers/aws/resource_aws_load_balancer_listener_policy.go b/builtin/providers/aws/resource_aws_load_balancer_listener_policy.go index 494b8bd98..2a13be1c3 100644 --- a/builtin/providers/aws/resource_aws_load_balancer_listener_policy.go +++ b/builtin/providers/aws/resource_aws_load_balancer_listener_policy.go @@ -60,10 +60,7 @@ func resourceAwsLoadBalancerListenerPoliciesCreate(d *schema.ResourceData, meta } d.SetId(fmt.Sprintf("%s:%s", *setOpts.LoadBalancerName, strconv.FormatInt(*setOpts.LoadBalancerPort, 10))) - d.Set("load_balancer_name", setOpts.LoadBalancerName) - d.Set("load_balancer_port", setOpts.LoadBalancerPort) - d.Set("policy_names", flattenStringList(setOpts.PolicyNames)) - return nil + return resourceAwsLoadBalancerListenerPoliciesRead(d, meta) } func resourceAwsLoadBalancerListenerPoliciesRead(d *schema.ResourceData, meta interface{}) error { @@ -81,6 +78,7 @@ func resourceAwsLoadBalancerListenerPoliciesRead(d *schema.ResourceData, meta in if ec2err, ok := err.(awserr.Error); ok { if ec2err.Code() == "LoadBalancerNotFound" { return fmt.Errorf("LoadBalancerNotFound: %s", err) + d.SetId("") } } return fmt.Errorf("Error retrieving ELB description: %s", err) @@ -130,6 +128,7 @@ func resourceAwsLoadBalancerListenerPoliciesDelete(d *schema.ResourceData, meta return fmt.Errorf("Error setting LoadBalancerPoliciesOfListener: %s", err) } + d.SetId("") return nil } diff --git a/builtin/providers/aws/resource_aws_load_balancer_policy.go b/builtin/providers/aws/resource_aws_load_balancer_policy.go index 1d1219c80..8305cf992 100644 --- a/builtin/providers/aws/resource_aws_load_balancer_policy.go +++ b/builtin/providers/aws/resource_aws_load_balancer_policy.go @@ -86,7 +86,7 @@ func resourceAwsLoadBalancerPolicyCreate(d *schema.ResourceData, meta interface{ d.SetId(fmt.Sprintf("%s:%s", *lbspOpts.LoadBalancerName, *lbspOpts.PolicyName)) - return nil + return resourceAwsLoadBalancerPolicyRead(d, meta) } func resourceAwsLoadBalancerPolicyRead(d *schema.ResourceData, meta interface{}) error { @@ -176,7 +176,7 @@ func resourceAwsLoadBalancerPolicyUpdate(d *schema.ResourceData, meta interface{ } } - return nil + return resourceAwsLoadBalancerPolicyRead(d, meta) } func resourceAwsLoadBalancerPolicyDelete(d *schema.ResourceData, meta interface{}) error { @@ -204,6 +204,8 @@ func resourceAwsLoadBalancerPolicyDelete(d *schema.ResourceData, meta interface{ if _, err := elbconn.DeleteLoadBalancerPolicy(request); err != nil { return fmt.Errorf("Error deleting Load Balancer Policy %s: %s", d.Id(), err) } + + d.SetId("") return nil }