-
Notifications
You must be signed in to change notification settings - Fork 5
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
chore: add example of looking up availability zones #248
base: main
Are you sure you want to change the base?
Conversation
This change is part of the following stack: Change managed by git-spice. |
145ba8e
to
4d93a76
Compare
// Here I have specified that I want 3 availability zones. This uses Intrinsics, which | ||
// behind the scenes are backed by Pulumi functions (e.g. aws_native.getAzs()). | ||
// This allows us to get around the limitation of not being able to use Output values here. | ||
get availabilityZones(): string[] { |
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.
I feel like we could achieve CDKs behavior by building a small resource that takes an input property, but then just returns the value from state indefinitely (unless recreated).
Overkill for now, but maybe something for the future if we see this being annoying for users.
da1e74e
to
efd3750
Compare
5230b0d
to
6c3c7b8
Compare
If you provide an explicit environment to the stack (there are a lot of reasons to do this) then you have to enable lookups in order for the stack to lookup the availability zones. It would be nice if you could just use Pulumi functions to lookup the AZs and provide that, but the values have to be strings (can't be promises/outputs). An easy workaround for this is to use the `getAzs` intrinsic to defer the lookup and allow the intrinsic to be converted to a Pulumi function. I am adding an example of how to do this. The reason we don't want to do this by default is that the number of availability zones is not something that should every change without the user knowing about it. CDK handles that by having the lookup store the value in the `cdk.context.json` file so the lookup is never re-run.
6c3c7b8
to
a08fb92
Compare
If you provide an explicit environment to the stack (there are a lot of
reasons to do this) then you have to enable lookups in order for the
stack to lookup the availability zones.
It would be nice if you could just use Pulumi functions to lookup the
AZs and provide that, but the values have to be strings (can't be
promises/outputs). An easy workaround for this is to use the
getAzs
intrinsic to defer the lookup and allow the intrinsic to be converted to
a Pulumi function.
I am adding an example of how to do this. The reason we don't want to do
this by default is that the number of availability zones is not
something that should every change without the user knowing about it.
CDK handles that by having the lookup store the value in the
cdk.context.json
file so the lookup is never re-run.