-
Notifications
You must be signed in to change notification settings - Fork 9.2k
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/aws_prefix_list: fixes and enhancements #14109
Conversation
…tching multiple prefix lists
792047f
to
a35c88c
Compare
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.
Hi @roberth-k 👋 Thank you for submitting this! Overall this is good stuff, but I marked this as breaking changes for now since we would want to hold off on purposefully introducing changes that effect practitioner experience until a major version update. We can split this up into fixing the name versus filter bug now and separately introducing the other changes.
Please reach out if you have any questions. 😄
|
||
log.Printf("[DEBUG] Reading Prefix List: %s", req) | ||
resp, err := conn.DescribePrefixLists(req) | ||
if err != nil { | ||
switch { |
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.
The predominate coding style for the codebase is if
conditionals with early return
s rather than bare switch
conditionals. Can you please change this back rather than introducing a different coding style? Thanks!
case len(resp.PrefixLists) > 1: | ||
return fmt.Errorf("more than one prefix list matched the given set of criteria") |
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.
While this is a perfectly valid change for consistency with most other data sources, we should only perform this change during a major version upgrade to align with practitioner versioning expectations, which the next one will be a few months away. It would be best to remove this change here and create a separate GitHub bug report so we can mark it for that future milestone. 👍 You're more than welcome to submit this change as well separately.
for i, v := range pl.Cidrs { | ||
cidrs[i] = *v | ||
cidrs := aws.StringValueSlice(pl.Cidrs) | ||
sort.Strings(cidrs) |
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.
Similarly here with respect to introducing a breaking change which should be removed for now.
In this case though, if the ordering of the CIDR Blocks is not significant (which it likely is not), the cidr_blocks
attribute should be changed to TypeSet
instead of attempting to add ordering that is inconsistent with the semantics of the upstream API. Terraform configurations can and should use built in language support such as resource for_each
for handling all elements of an attribute like this to avoid ordering concerns.
At some point in the future we may go back through many of the TypeList
attributes and convert them to TypeSet
to ensure that Terraform configurations are not depending on ordering where its not guaranteed or semantically correct.
|
||
const testAccDataSourceAwsPrefixListConfig_nameDoesNotOverrideFilter = ` | ||
data "aws_prefix_list" "test" { | ||
name = "com.amazonaws.us-west-2.s3" |
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.
Some of our newer codebase linting will likely pick this up on rebase/merge for not being AWS Region agnostic. Similar to the website example you added (👍 ) we should use the aws_region
data source here so the configuration can be applied in anywhere. This also means we'll need to remove the hardcoded EC2 Prefix List identifier. Something like this should get you close:
data "aws_region" "current" {}
data "aws_prefix_list" "dynamodb" {
name = "com.amazonaws.${data.aws_region.current.name}.dynamodb"
}
data "aws_prefix_list" "test" {
name = "com.amazonaws.${data.aws_region.current.name}.s3"
filter {
name = "prefix-list-id"
values = [data.aws_prefix_list.dynamodb.id]
}
}
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks! |
Community Note
Relates #14068, #13986
Contains bugfixes and enhancements to the
aws_prefix_list
data source discovered while implementing support for Managed Prefix Lists.Users may be affected by the following changes in behavior:
cidr_blocks[0]
), the result may now be a different CIDR block.Release note for CHANGELOG:
Output from acceptance testing: