Search code examples
amazon-web-servicesaws-lambdaaws-cliaws-cdkaws-appsync

always getting stack.regionalFact error in aws-cdk


On any cdk command like cdk-deploy i get this error. I have created this project with cdk innit app --language typescript. my cdk version is 1.121.0

D:\Unicorn\cdk\step03_graphQl\node_modules\@aws-cdk\aws-iam\lib\principals.ts:775
    return stack.regionalFact(
                 ^
TypeError: Resolution error: Resolution error: Resolution error: Resolution error: stack.regionalFact is not a function.
Object creation stack:
  at stack traces disabled.
Object creation stack:
  at stack traces disabled..
    at ServicePrincipalToken.resolve (D:\Unicorn\cdk\step03_graphQl\node_modules\@aws-cdk\aws-iam\lib\principals.ts:775:18)
    at RememberingTokenResolver.resolveToken (D:\Unicorn\cdk\step03_graphQl\node_modules\@aws-cdk\core\lib\resolvable.ts:80:24)
    at RememberingTokenResolver.resolveToken (D:\Unicorn\cdk\step03_graphQl\node_modules\@aws-cdk\core\lib\private\resolve.ts:286:18)
    at resolve (D:\Unicorn\cdk\step03_graphQl\node_modules\@aws-cdk\core\lib\private\resolve.ts:212:51)
    at Object.resolve [as mapToken] (D:\Unicorn\cdk\step03_graphQl\node_modules\@aws-cdk\core\lib\private\resolve.ts:119:77)
    at TokenizedStringFragments.mapTokens (D:\Unicorn\cdk\step03_graphQl\node_modules\@aws-cdk\core\lib\string-fragments.ts:65:33)
    at RememberingTokenResolver.resolveString (D:\Unicorn\cdk\step03_graphQl\node_modules\@aws-cdk\core\lib\resolvable.ts:99:22)
    at RememberingTokenResolver.resolveString (D:\Unicorn\cdk\step03_graphQl\node_modules\@aws-cdk\core\lib\private\resolve.ts:290:23)
    at resolve (D:\Unicorn\cdk\step03_graphQl\node_modules\@aws-cdk\core\lib\private\resolve.ts:170:48)
    at Object.resolve (D:\Unicorn\cdk\step03_graphQl\node_modules\@aws-cdk\core\lib\private\resolve.ts:119:77)
Subprocess exited with error 1

I'm just creating a graphQl api with AppSync and invoking lambda fucntion with it.

I have pin point where my error occurs by commenting all code and then uncommenting each construct one by one and then running cdk deploy

so this is the construct which gives error (when uncommented this, error occured)

const lambda_function = new lambda.Function(this, "LambdaFucntion", {
  runtime: lambda.Runtime.NODEJS_14_X, ///set nodejs runtime environment
  code: lambda.Code.fromAsset("lambda"), ///path for lambda function directory
  handler: "index.handler", ///specfic fucntion in specific file
  // timeout: cdk.Duration.seconds(10), ///Time for function to break. limit upto 15 mins
});

Solution

  • "@aws-cdk/core": "1.121.0" is missing the ^ before the version number, causing a CDK package versioning conflict. The other packages (with the carat symbol) have been updated to the latest minor release (when you last ran npm update), but core is stuck at v1.121.0.