-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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
provider/aws: data sources for AWS network planning #6819
Conversation
2937298
to
8665a9c
Compare
8f02623
to
65d17c4
Compare
Note to self: once this is more complete, consider doing a little bit of rework of the code from #6911 to use the general |
A different patch introduced Since this is just some new data sources and doc updates I'm going to hold this until after 0.7 is out and try to land it for the first patch release after that. |
65d17c4
to
393c6aa
Compare
b97fd97
to
5174aa4
Compare
Since 0.7 was delayed, maybe this can get in before that after all... I'm going to optimistically add the release-0.7 tag here but happy to remove it if this patch requires more iterations, rather than having those iterations block the release. |
@apparentlymart For now I'm going to remove |
Totally fine @jen20, and sorry for the delayed reply. |
Can you rebase this? :) P. |
5174aa4
to
2444553
Compare
@stack72... rebased as requested. 😀 |
LOL @apparentlymart we need another rebase please :) |
2444553
to
bd5c78e
Compare
Rebased again. These conflicts have just been other changes to the data source list in the provider, so don't actually affect the implementations of these data sources... if someone could review the main implementation then I can resolve any minor conflicts myself before merging. 😀 |
bd5c78e
to
04356f7
Compare
return fmt.Errorf("bad cidr_block %s", attr["cidr_block"]) | ||
} | ||
if attr["availability_zone"] != "us-west-2a" { | ||
return fmt.Errorf("bad cidr_block %s", attr["cidr_block"]) |
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 should be printing out availablility_zone
, not cidr_block
.
Overall this looks good to me, however... I don’t care for the The method itself is also undocumented, so how/when I would use this and how/when I would not isn't so clear, and there are no tests for it either. Is it only applicable for data sources? Or is it meant to start being used throughout the AWS provider? I feel like a better method would be one that just accepts a req.Filter = buildEC2FilterList(map[string]interface{}{
"cidr": d.Get("cidr").(string),
"tags": d.Get("tags"),
}) This would need some special tweaking for the It is more explicit (read: more work for implementers), but I think that's good and as a result you get more clarity as to what's happening. At least in my mind, there are less surprises. I hope this feedback doesn't come off too much as a bikeshed argument, as the vast majority of this PR looks great! Thoughts? |
@stack72: any chance we can have this in 0.7.5? |
@zms I have a bit more work to do first, to respond to the review feedback... I hope to get to this soon. |
In an attempt to always show "id" as computed we were producing a synthetic diff for it, but this causes problems when the id attribute for a particular data source is actually settable in configuration, since it masks the setting from the config and forces it to always be empty. Instead, we'll set it conditionally so that a value provided in the config can shine through when available.
04356f7
to
31ac79e
Compare
These functions can be used within various EC2 data sources to support querying by filter. The following cases are supported: - Filtering by exact equality with single attribute values - Filtering by EC2 tag key/value pairs - Explicitly specifying raw EC2 filters in config This should cover most of the filter use-cases for Terraform data sources that are built on EC2's 'Describe...' family of functions.
This adds a singular data source in addition to the existing plural one. This allows retrieving data about a specific AZ. As a helper for writing reusable modules, the AZ letter (without its usual region name prefix) is exposed so that it can be used in region-agnostic mappings where a different value is used per AZ, such as for subnet numbering schemes.
The primary purpose of this data source is to ask the question "what is my current region?", but it can also be used to retrieve the endpoint hostname for a particular (possibly non-current) region, should that be useful for some esoteric case.
This example demonstrates both creating a network architecture *and* the use of data resources to minimize the number of variables needed for a child module by discovering additional data automatically.
31ac79e
to
0e3256b
Compare
Hi @catsby! Thanks for the review and sorry for the delay in following up. I have reorganized what was originally the
I loosely modeled this after how EC2 tags are handled in All three of these now have basic unit tests and hopefully-comprehensive-enough documentation. Hopefully this new structure is easier to follow and makes the individual data source implementations more readable. |
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.
LGTM, thank you!
I'm fairly sure the answer is no but.... is it possible to utilize this and the aws_vpc resource to ensure the default VPC is deleted in an account? |
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 have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
This is a bit of a grab-bag of AWS provider data sources that are aimed at a particular use-case: building and using VPCs and Subnets easily.
Some of the data sources in this set are not directly towards that goal, but enable it.
Here we have:
aws_subnet
aws_vpc
aws_region
aws_availability_zone
andaws_availability_zones
Here is a simple example showing how a module can take a subnet id and automatically find the associated VPC:
This is an initial implementation of some conventions I came up with for mapping EC2
Describe
actions to data sources. It includesec2_filters.go
, which is a re-usable helper function for easily implementing EC2 data sources that fit these conventions.