Skip to content

Commit

Permalink
add set func to data source
Browse files Browse the repository at this point in the history
  • Loading branch information
DrFaust92 committed Aug 12, 2020
1 parent 932fc47 commit c40e6d4
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions aws/data_source_aws_lb.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package aws

import (
"bytes"
"fmt"
"log"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/elbv2"
"github.com/hashicorp/terraform-plugin-sdk/helper/hashcode"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

Expand Down Expand Up @@ -73,6 +75,18 @@ func dataSourceAwsLb() *schema.Resource {
},
},
},
Set: func(v interface{}) int {
var buf bytes.Buffer
m := v.(map[string]interface{})
buf.WriteString(fmt.Sprintf("%s-", m["subnet_id"].(string)))
if m["allocation_id"] != "" {
buf.WriteString(fmt.Sprintf("%s-", m["allocation_id"].(string)))
}
if m["private_ipv4_address"] != "" {
buf.WriteString(fmt.Sprintf("%s-", m["private_ipv4_address"].(string)))
}
return hashcode.String(buf.String())
},
},

"access_logs": {
Expand Down

0 comments on commit c40e6d4

Please sign in to comment.