-
Notifications
You must be signed in to change notification settings - Fork 4k
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(core): CustomResourceProvider assets are staged in node_modules #20953
Changes from 1 commit
8ccee3d
440050c
30763a8
e1f5780
72ff242
9b71c18
84e4673
d664410
9a6186c
718204a
b7fd01f
d2bbc53
26aee0b
22564af
0c69e63
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
import * as fs from 'fs'; | ||
import * as os from 'os'; | ||
import * as path from 'path'; | ||
import * as cxapi from '@aws-cdk/cx-api'; | ||
import { Construct } from 'constructs'; | ||
|
@@ -200,16 +201,17 @@ export class CustomResourceProvider extends Construct { | |
|
||
const stack = Stack.of(scope); | ||
|
||
// copy the entry point to the code directory | ||
fs.copyFileSync(ENTRYPOINT_NODEJS_SOURCE, path.join(props.codeDirectory, `${ENTRYPOINT_FILENAME}.js`)); | ||
|
||
// verify we have an index file there | ||
if (!fs.existsSync(path.join(props.codeDirectory, 'index.js'))) { | ||
throw new Error(`cannot find ${props.codeDirectory}/index.js`); | ||
} | ||
|
||
const stagingDirectory = fs.mkdtempSync(path.join(os.tmpdir(), 'cdk-custom-resource')); | ||
fs.copyFileSync(path.join(props.codeDirectory, 'index.js'), path.join(stagingDirectory, 'index.js')); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Previously we were copying the For example https://github.com/aws/aws-cdk/tree/main/packages/%40aws-cdk/aws-iam/lib/oidc-provider There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're absolutely right! Done. |
||
fs.copyFileSync(ENTRYPOINT_NODEJS_SOURCE, path.join(stagingDirectory, `${ENTRYPOINT_FILENAME}.js`)); | ||
|
||
const staging = new AssetStaging(this, 'Staging', { | ||
sourcePath: props.codeDirectory, | ||
sourcePath: stagingDirectory, | ||
}); | ||
|
||
const assetFileName = staging.relativeStagedPath(stack); | ||
|
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.
using
import { FileSystem } from '../fs';
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.
It has the advantage of using the real temp dir even when it is a symlink like on OSx
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.
Done. Thanks!