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

New resource - aws_availability_zones #4848

Conversation

vancluever
Copy link
Contributor

This adds a new resource - aws_availability_zones - to get a list of availability zones that the account/region combination can use.

Precedent: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-getavailabilityzones.html

I've exposed the API parameters (docs in the PR).

One thing - the test is general, as depending on where you are set up, doing something like limiting your region to us-east-1, etc, will give no results. I've tested locally here though with the options and had success.

Also - buildEc2Filters is similar to the function I have in #4396, which I will move to use this if/when things are merged.

@vancluever
Copy link
Contributor Author

Note the the usefulness of this PR is kind of diminished by the fact that you currently can't splat nested resource attributes. I'd love to see this happen though, and if someone can tell me where to start, I might give it a go.

@radeksimko
Copy link
Member

I like the idea, there's a few notes:

  • it would be nice if we could limit the amount of zones returned (e.g. not everyone may want to use all 4 AZs in us-east-1, where 2 or 3 AZs would just do the job for cheap redundancy). Maybe introduce limit (TypeInt) would help here?
  • it would be nice if we could guarantee the ordering of zones, so that in case I deployed everything into us-east-1a + us-east-1b and API suddenly returns us-east1-a + us-east1-c, I would not suddenly redeploy everything to a different zone. Maybe we can just alphabetically sort the returned list?

Also this resource would hugely benefit from using #4705 when it's a real thing. I wouldn't want to block this PR on any of the above, but I just wanted to note that the linked PR may solve some of the issues users are likely going to hit as they're already hitting it with existing resources, e.g. terraform_remote_state (that works on the same principle).

After all you're probably well aware of that.

@jen20
Copy link
Contributor

jen20 commented Jan 27, 2016

I would be tempted to wait on this until #4705 is implemented. I see that @apparentlymart has started work on it, I have some type system work to do in core before turning my attention to it but hopefully it's something we can address soon!

@vancluever
Copy link
Contributor Author

@radeksimko:

it would be nice if we could limit the amount of zones returned (e.g. not everyone may want to use all 4 AZs in us-east-1, where 2 or 3 AZs would just do the job for cheap redundancy). Maybe introduce limit (TypeInt) would help here?

I think that this might be something we could leave up to the template/module author, no? If you know how many zones you need, then you could just limit your say, count to iterate over that number and leave the rest.

it would be nice if we could guarantee the ordering of zones, so that in case I deployed everything into us-east-1a + us-east-1b and API suddenly returns us-east1-a + us-east1-c, I would not suddenly redeploy everything to a different zone. Maybe we can just alphabetically sort the returned list?

I think this is a good idea for sure. Not too much work, and that way you can expect the same results back all the time. It could be how CloudFormation even behaves, The docs mention a sorted list in the sample results but I'm not too sure if that's just due to the example. I'll add this to the code.

And yeah, I've run into some limitations with these kinds of utility resources for sure in the way they are currently configured. The AMI search resource is kind of resistant to change in that if you change the search parameters it doesn't necessarily update any dependent resources in the next run (although it doesn't affect if the search returns a different AMI, ie: a new AMI is pushed with the same tag, etc). Since this resource is relatively static though, it should be pretty resilient to the shortcomings of the current architecture.

What would benefit this resource much more is if #2833 is addressed, as right now you can't use element on the returned AZs.

@radeksimko
Copy link
Member

I think that this might be something we could leave up to the template/module author, no? If you know how many zones you need, then you could just limit your say, count to iterate over that number and leave the rest.

True, that's also an elegant solution. 👍

Either way I think we should wait for #4705

@vancluever
Copy link
Contributor Author

Roger that. Also, just updated the code - I've simplified the results returned, so now it can be looked up on without having to splat, and also added sorting. Will wait for the LGTM, and/or feedback on if we should just stick with this structure (the value to TF on the other returned values (ie: status and status messages) are kind of debatable), and then will squash.

@josh-padnick
Copy link

Is there an update on this PR? This would be a useful feature since I'm still hardcoding availability zone lists into my templates since they vary by AWS account.

@vancluever vancluever force-pushed the paybyphone_aws_availability_zones branch from 4941507 to 9a740da Compare April 7, 2016 20:09
@vancluever
Copy link
Contributor Author

Everyone - it's been a while since this PR is in, and I'm still using it, so I figured I'd give it a rebase to make it easier to merge.

Would love to see this in upstream - even it it gets removed in 0.7 (and again, I would be totally fine with porting it over to a data source when that happens).

@vancluever vancluever force-pushed the paybyphone_aws_availability_zones branch from d38f2ba to 74e01c1 Compare May 16, 2016 20:34
@vancluever
Copy link
Contributor Author

vancluever commented May 30, 2016

Going to be closing this one shortly, as we have #6805 - going to take the tests from this one and port them over so that we have those.

@jen20 jen20 closed this in 2d65e9d May 30, 2016
@vancluever vancluever deleted the paybyphone_aws_availability_zones branch May 30, 2016 17:51
@ghost
Copy link

ghost commented Apr 25, 2020

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.

@ghost ghost locked and limited conversation to collaborators Apr 25, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants