-
Notifications
You must be signed in to change notification settings - Fork 9k
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
d/lb - add private_ipv4_address
attribute to subnet mapping
#14545
Merged
+77
−59
Merged
Changes from 5 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
f237250
add `private_ipv4_address` attribute to subnet mapping
DrFaust92 932fc47
test pairs against original resource
DrFaust92 c40e6d4
add set func to data source
DrFaust92 5c79926
Update data_source_aws_lb.go
DrFaust92 df76eba
lint
DrFaust92 09141e8
Update aws/data_source_aws_lb.go
DrFaust92 fd3c04f
remove sets
DrFaust92 21837f7
add extra tests
DrFaust92 File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
) | ||
|
||
|
@@ -61,14 +63,30 @@ func dataSourceAwsLb() *schema.Resource { | |
Schema: map[string]*schema.Schema{ | ||
"subnet_id": { | ||
Type: schema.TypeString, | ||
Required: true, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you for fixing these. 😄 |
||
Computed: true, | ||
}, | ||
"allocation_id": { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
Computed: true, | ||
}, | ||
"private_ipv4_address": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
}, | ||
}, | ||
}, | ||
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()) | ||
}, | ||
DrFaust92 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}, | ||
|
||
"access_logs": { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This import was very recently moved as part of our Terraform Plugin SDK v1 removal: #14593
It now lives at:
"github.com/terraform-providers/terraform-provider-aws/aws/internal/hashcode"
That being said, adding
Set
functions to data sources should generally not be necessary and especially after this fix in SDK version 2: hashicorp/terraform-plugin-sdk#197If this is rebased against the current commit on the main branch, which is all up to date with SDK v2, the
Set
function can hopefully be removed.