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

provider/aws: Add support for Network Loadbalancers #1806

Merged
merged 1 commit into from
Oct 4, 2017
Merged
Show file tree
Hide file tree
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
172 changes: 0 additions & 172 deletions aws/data_source_aws_alb_target_group_test.go

This file was deleted.

124 changes: 0 additions & 124 deletions aws/data_source_aws_alb_test.go

This file was deleted.

48 changes: 35 additions & 13 deletions aws/data_source_aws_alb.go → aws/data_source_aws_lb.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import (
"github.com/hashicorp/terraform/helper/schema"
)

func dataSourceAwsAlb() *schema.Resource {
func dataSourceAwsLb() *schema.Resource {
return &schema.Resource{
Read: dataSourceAwsAlbRead,
Read: dataSourceAwsLbRead,
Schema: map[string]*schema.Schema{
"arn": {
Type: schema.TypeString,
Expand All @@ -35,6 +35,11 @@ func dataSourceAwsAlb() *schema.Resource {
Computed: true,
},

"load_balancer_type": {
Type: schema.TypeString,
Computed: true,
},

"security_groups": {
Type: schema.TypeSet,
Elem: &schema.Schema{Type: schema.TypeString},
Expand All @@ -49,6 +54,23 @@ func dataSourceAwsAlb() *schema.Resource {
Set: schema.HashString,
},

"subnet_mapping": {
Type: schema.TypeSet,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"subnet_id": {
Type: schema.TypeString,
Required: true,
},
"allocation_id": {
Type: schema.TypeString,
Optional: true,
},
},
},
},

"access_logs": {
Type: schema.TypeList,
Computed: true,
Expand Down Expand Up @@ -101,27 +123,27 @@ func dataSourceAwsAlb() *schema.Resource {
}
}

func dataSourceAwsAlbRead(d *schema.ResourceData, meta interface{}) error {
func dataSourceAwsLbRead(d *schema.ResourceData, meta interface{}) error {
elbconn := meta.(*AWSClient).elbv2conn
albArn := d.Get("arn").(string)
albName := d.Get("name").(string)
lbArn := d.Get("arn").(string)
lbName := d.Get("name").(string)

describeAlbOpts := &elbv2.DescribeLoadBalancersInput{}
describeLbOpts := &elbv2.DescribeLoadBalancersInput{}
switch {
case albArn != "":
describeAlbOpts.LoadBalancerArns = []*string{aws.String(albArn)}
case albName != "":
describeAlbOpts.Names = []*string{aws.String(albName)}
case lbArn != "":
describeLbOpts.LoadBalancerArns = []*string{aws.String(lbArn)}
case lbName != "":
describeLbOpts.Names = []*string{aws.String(lbName)}
}

describeResp, err := elbconn.DescribeLoadBalancers(describeAlbOpts)
describeResp, err := elbconn.DescribeLoadBalancers(describeLbOpts)
if err != nil {
return errwrap.Wrapf("Error retrieving ALB: {{err}}", err)
return errwrap.Wrapf("Error retrieving LB: {{err}}", err)
}
if len(describeResp.LoadBalancers) != 1 {
return fmt.Errorf("Search returned %d results, please revise so only one is returned", len(describeResp.LoadBalancers))
}
d.SetId(*describeResp.LoadBalancers[0].LoadBalancerArn)

return flattenAwsAlbResource(d, meta, describeResp.LoadBalancers[0])
return flattenAwsLbResource(d, meta, describeResp.LoadBalancers[0])
}
Loading