From d484ebadcd867af54093000f2f8a33f18a6b835e Mon Sep 17 00:00:00 2001 From: Jack Pearkes Date: Wed, 2 Jul 2014 22:40:55 -0700 Subject: [PATCH] providers/aws: update --- builtin/providers/aws/resource_aws_elb.go | 34 ++++++++++++++++++++++- builtin/providers/aws/resources.go | 1 + 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/builtin/providers/aws/resource_aws_elb.go b/builtin/providers/aws/resource_aws_elb.go index e7c2caba5..b77cb6c12 100644 --- a/builtin/providers/aws/resource_aws_elb.go +++ b/builtin/providers/aws/resource_aws_elb.go @@ -68,11 +68,43 @@ func resource_aws_elb_create( return nil, fmt.Errorf("Unable to find ELB: %#v", describeResp.LoadBalancers) } } + loadBalancer := describeResp.LoadBalancers[0] + // If we have any instances, we need to register them + v = flatmap.Expand(rs.Attributes, "instances").([]interface{}) + instances := expandStringList(v) + + if len(instances) > 0 { + registerInstancesOpts := elb.RegisterInstancesWithLoadBalancer{ + LoadBalancerName: elbName, + Instances: instances, + } + + registerResp, err := elbconn.RegisterInstancesWithLoadBalancer(registerInstancesOpts) + } + return resource_aws_elb_update_state(rs, &loadBalancer) } +func resource_aws_elb_update( + s *terraform.ResourceState, + d *terraform.ResourceDiff, + meta interface{}) (*terraform.ResourceState, error) { + // p := meta.(*ResourceProvider) + // elbconn := p.elbconn + + // Merge the diff into the state so that we have all the attributes + // properly. + rs := s.MergeDiff(d) + + log.Println(rs) + + rs.Attributes + + return nil, nil +} + func resource_aws_elb_destroy( s *terraform.ResourceState, meta interface{}) error { @@ -99,11 +131,11 @@ func resource_aws_elb_diff( "name": diff.AttrTypeCreate, "availability_zone": diff.AttrTypeCreate, "listener": diff.AttrTypeCreate, + "instances": diff.AttrTypeUpdate, }, ComputedAttrs: []string{ "dns_name", - "instances ", }, } diff --git a/builtin/providers/aws/resources.go b/builtin/providers/aws/resources.go index aff7a581a..2703f024c 100644 --- a/builtin/providers/aws/resources.go +++ b/builtin/providers/aws/resources.go @@ -19,6 +19,7 @@ func init() { }, "aws_elb": resource.Resource{ Create: resource_aws_elb_create, + Update: resource_aws_elb_update, Destroy: resource_aws_elb_destroy, Diff: resource_aws_elb_diff, Refresh: resource_aws_elb_refresh,