-
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
(@aws-cdk/aws-cognito): import 'punycode/' #14290
Comments
Actually, the trailing slash is crucial. See #11099 (comment) I'm not sure I understand what issue you're running into. Can you describe your actual issue? |
I understand. I solved my issue by creating Lambda Layer for punycode module. informationI was tring to deploy CDK's stack from within Lambda function handler. sample code (Lambda function handler)import { App, Stack } from '@aws-cdk/core'
import { UserPool } from '@aws-cdk/aws-cognito'
import { SdkProvider } from 'aws-cdk/lib/api/aws-auth'
import { CloudFormationDeployments } from 'aws-cdk/lib/api/cloudformation-deployments'
exports.handler = async (event: any) => {
const app = new App()
const stack = new Stack(app, 'SampleStack')
new UserPool(stack, 'SampleUserPool')
const deployer = new CloudFormationDeployments({
sdkProvider: await SdkProvider.withAwsCliCompatibleDefaults()
})
await deployer.deployStack({
stack: app.synth().stacks[0],
quiet: true
})
return {
statusCode: 200,
body: 'ok'
}
} It remains esbuild result...
var punycode_1 = require("punycode/");
... I understood that |
|
I had this error as well and was able to fix it through some code changes. For me it was an error in my code organisation. In my case it was to do with mixing devDependencies/cdk code with my runtime lambda code. e.g. I had some files similar to:
{
...
"devDependencies": {
"@aws-cdk/aws-lambda-nodejs": "^1.114.0",
"@aws-cdk/aws-cognito": "^1.114.0",
...
}
}
export { default as Construct } from "./construct";
export { default as getViewerResolver } from "./getViewerResolver";
import { UserPool } "@aws-cdk/aws-cognito"
// ...
// ...
class ApiConstruct extends Construct {
constructor() {
//...
const defaultResolverLambda = new NodejsFunction(
this,
"DefaultGraphQlResolver",
{
runtime: Runtime.NODEJS_14_X,
entry: path.join(__dirname, "..", "users", "index.ts"),
handler: "getViewerResolver"
}
);
}
} including that So the fix was to make sure my construct/cdk code was completely separate from my runtime lambda code. |
Thanks for posting this @danielholmes, I had the same issue. We had some Custom::Trigger that would run to populate user data on deploy. Unfortunately, the lambda handler was thrown in the same module as some CDK code that was loosely related. This caused esbuild to bundle This popped up on upgrade to CDK v2 after working with CDK v1 with an error like The answer for me was to isolate the lambda code so that NO CDK code was referenced (even transitively) by module imports. |
❓ General Issue
The Question
about "@aws-cdk/aws-cognito/lib/user-pool.ts".
I don't think punycode's trailing slash is necessary.
current code
expected code
Environment
Other information
An error occurred when importing '@aws-cdk/aws-cognito' in the Lambda function handler.
Lambda Runtime Error
The text was updated successfully, but these errors were encountered: