-
Notifications
You must be signed in to change notification settings - Fork 104
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
Fix getRegion functions #1384
Fix getRegion functions #1384
Conversation
awsx/utils.ts
Outdated
const provider = res.getProvider ? res.getProvider("aws::") : undefined; | ||
return getRegionFromProvider(provider); | ||
// uses the provider from the parent resource to fetch the region | ||
return aws.getRegionOutput({}, { parent: res }).apply(region => region.name as aws.Region); |
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.
To confirm, as this inheritance is a little tricky, if res
uses a custom version of the AWS provider, { parent: res}
will inherit that custom version so we get the right thing here?
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.
Yes, that's my understanding. It actually retrieves the provider configured for the parent. If that one's using a custom version then this will also use that version.
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 see this is already shipped in aws-apigateway so that's nice! THank you.
@@ -16,7 +16,7 @@ import * as aws from "@pulumi/aws"; | |||
import * as pulumi from "@pulumi/pulumi"; | |||
import { ResourceOptions } from "@pulumi/pulumi"; | |||
import * as schema from "../schema-types"; | |||
import { getRegion, getRegionFromOpts, parseArn } from "../utils"; |
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.
Cleanup? Some missing liner rules?
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.
Yeah, I'm currently trying to see which one we're missing
awsx/utils.ts
Outdated
const provider = res.getProvider ? res.getProvider("aws::") : undefined; | ||
return getRegionFromProvider(provider); | ||
// uses the provider from the parent resource to fetch the region | ||
return aws.getRegionOutput({}, { parent: res }).apply(region => region.name as aws.Region); | ||
} | ||
|
||
function getRegionFromProvider(provider: pulumi.ProviderResource | undefined) { |
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.
Specify return type here please. I wonder what the "default" value was, aws.config.region. Now with this change it will pull the ambient AWS provider if provider=undefined, sounds like it's intended.
This PR has been shipped in release v2.16.0. |
The
getRegion
functions were incorrectly trying to extract the current region from the provider. This silently resolved to undefined in certain cases; e.g. when noAWS_REGION
ENV variable was set.In particular this caused ECS tasks to fail because they used
https://logs.undefined.amazonaws.com/
as the endpoint for cloudwatch.Instead we should use the
getRegion
data source to correctly identify the current region.Fixes #1112
Fixes #1279