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

Add arn attribute to aws_elb resource #2272

Merged
merged 2 commits into from
Nov 15, 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
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 @@ -329,6 +335,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