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

fix: some custom resources don't work in opt-in regions #22370

Merged
merged 9 commits into from
Oct 10, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const defaultEksClient: EksClient = {
console.log(JSON.stringify({ assumeRole: req }, undefined, 2));
const creds = new aws.ChainableTemporaryCredentials({
params: req,
stsConfig: { stsRegionalEndpoints: 'regional' },
});

eks = new aws.EKS({ credentials: creds });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ async function cfnEventHandler(props: ResourceProperties, isDeleteEvent: boolean
}

async function getCrossAccountCredentials(roleArn: string): Promise<Credentials> {
const sts = new STS();
const sts = new STS({ stsRegionalEndpoints: 'regional' });
const timestamp = (new Date()).getTime();

const { Credentials: assumedCredentials } = await sts
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,11 @@ export class CustomResourceProvider extends Construct {
return undefined;
}

env = { ...env }; // Copy

// Always use regional endpoints
env.AWS_STS_REGIONAL_ENDPOINTS = 'regional';

// Sort environment so the hash of the function used to create
// `currentVersion` is not affected by key order (this is how lambda does
// it)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,10 +282,10 @@ describe('custom resource provider', () => {
const template = toCloudFormation(stack);
const lambda = template.Resources.CustomMyResourceTypeCustomResourceProviderHandler29FBDD2A;
expect(lambda.Properties.Environment).toEqual({
Variables: {
Variables: expect.objectContaining({
A: 'a',
B: 'b',
},
}),
});

});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ export async function handler(event: AWSLambda.CloudFormationCustomResourceEvent

credentials = new AWS.ChainableTemporaryCredentials({
params: params,
stsConfig: { stsRegionalEndpoints: 'regional' },
});
}

Expand Down