Skip to content

Commit

Permalink
Add arn attribute to aws_elb resource (#2272)
Browse files Browse the repository at this point in the history
* Add arn attribute to aws_elb resource

* #2272 review: r/aws_elb: Remove Optional from arn attribute
  • Loading branch information
bflad authored and radeksimko committed Nov 15, 2017
1 parent 93b7cbc commit 7960eea
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
15 changes: 15 additions & 0 deletions aws/resource_aws_elb.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"time"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/arn"
"github.com/aws/aws-sdk-go/aws/awserr"
"github.com/aws/aws-sdk-go/service/ec2"
"github.com/aws/aws-sdk-go/service/elb"
Expand Down Expand Up @@ -44,6 +45,11 @@ func resourceAwsElb() *schema.Resource {
ValidateFunc: validateElbNamePrefix,
},

"arn": &schema.Schema{
Type: schema.TypeString,
Computed: true,
},

"internal": &schema.Schema{
Type: schema.TypeBool,
Optional: true,
Expand Down Expand Up @@ -330,6 +336,15 @@ func resourceAwsElbRead(d *schema.ResourceData, meta interface{}) error {
elbconn := meta.(*AWSClient).elbconn
elbName := d.Id()

arn := arn.ARN{
Partition: meta.(*AWSClient).partition,
Region: meta.(*AWSClient).region,
Service: "elasticloadbalancing",
AccountID: meta.(*AWSClient).accountid,
Resource: fmt.Sprintf("loadbalancer/%s", d.Id()),
}
d.Set("arn", arn.String())

// Retrieve the ELB properties for updating the state
describeElbOpts := &elb.DescribeLoadBalancersInput{
LoadBalancerNames: []*string{aws.String(elbName)},
Expand Down
1 change: 1 addition & 0 deletions aws/resource_aws_elb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ func TestAccAWSELB_basic(t *testing.T) {
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSELBExists("aws_elb.bar", &conf),
testAccCheckAWSELBAttributes(&conf),
resource.TestCheckResourceAttrSet("aws_elb.bar", "arn"),
resource.TestCheckResourceAttr(
"aws_elb.bar", "availability_zones.#", "3"),
resource.TestCheckResourceAttr(
Expand Down
1 change: 1 addition & 0 deletions website/docs/r/elb.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ browser.
The following attributes are exported:

* `id` - The name of the ELB
* `arn` - The ARN of the ELB
* `name` - The name of the ELB
* `dns_name` - The DNS name of the ELB
* `instances` - The list of instances in the ELB
Expand Down

0 comments on commit 7960eea

Please sign in to comment.