aws-samples / aws-fault-injection-simulator-workshop-v2

MIT No Attribution
11 stars 10 forks source link

Getting could not resolve ✘ [ERROR] Could not resolve "@smithy/core" while running deploy command #95

Open nasiaullas opened 19 hours ago

nasiaullas commented 19 hours ago

After following all the pre-requisites while running below command

cdk deploy --context admin_role=$EKS_ADMIN_ARN Services --context dashboard_role_arn=$CONSOLE_ROLE_ARN --require-approval never

get this error, in macOS (M3) as well as while running with an EC2 linux server.

============ => => exporting layers 0.1s => => writing image sha256:675110893b34701af0affc7d12f7572d5acf28ae073a26a2e6c35fa3e63ae0cb 0.0s => => naming to docker.io/library/cdk-27475b41497483cd009099c6f6867e2e8dc2c8ab55dde5c2e44d3dec82cf181c 0.0s

What's next: View a summary of image vulnerabilities and recommendations → docker scout quickview Bundling asset Services/status-updater-service/lambdafn/Code/Stage... esbuild cannot run locally. Switching to Docker bundling. WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested ✘ [ERROR] Could not resolve "@smithy/core"

var/runtime/node_modules/@aws-sdk/lib-dynamodb/dist-cjs/index.js:983:26:
  983 │ var import_core = require("@smithy/core");
      ╵                           ~~~~~~~~~~~~~~

The module "./dist-es/index.js" was not found on the file system:

var/runtime/node_modules/@aws-sdk/node_modules/@smithy/core/package.json:21:16:
  21 │       "module": "./dist-es/index.js",
     ╵                 ~~~~~~~~~~~~~~~~~~~~

You can mark the path "@smithy/core" as external to exclude it from the bundle, which will remove this error and leave the unresolved path in the bundle. You can also surround this "require" call with a try/catch block to handle this failure at run-time instead of bundle-time.

✘ [ERROR] Could not resolve "@smithy/core"

var/runtime/node_modules/@aws-sdk/client-dynamodb/dist-cjs/index.js:178:27:
  178 │ var import_core2 = require("@smithy/core");
      ╵                            ~~~~~~~~~~~~~~

The module "./dist-es/index.js" was not found on the file system:

var/runtime/node_modules/@aws-sdk/node_modules/@smithy/core/package.json:21:16:
  21 │       "module": "./dist-es/index.js",
     ╵                 ~~~~~~~~~~~~~~~~~~~~

You can mark the path "@smithy/core" as external to exclude it from the bundle, which will remove this error and leave the unresolved path in the bundle. You can also surround this "require" call with a try/catch block to handle this failure at run-time instead of bundle-time.

✘ [ERROR] Could not resolve "@aws-sdk/core"

var/runtime/node_modules/@aws-sdk/client-dynamodb/dist-cjs/index.js:207:26:
  207 │ var import_core = require("@aws-sdk/core");
      ╵                           ~~~~~~~~~~~~~~~

The module "./dist-es/index.js" was not found on the file system:

var/runtime/node_modules/@aws-sdk/core/package.json:22:16:
  22 │       "module": "./dist-es/index.js",
     ╵                 ~~~~~~~~~~~~~~~~~~~~

You can mark the path "@aws-sdk/core" as external to exclude it from the bundle, which will remove this error and leave the unresolved path in the bundle. You can also surround this "require" call with a try/catch block to handle this failure at run-time instead of bundle-time.

✘ [ERROR] Could not resolve "@aws-sdk/core"

var/runtime/node_modules/@aws-sdk/client-dynamodb/dist-cjs/auth/httpAuthSchemeProvider.js:4:23:
  4 │ const core_1 = require("@aws-sdk/core");
    ╵                        ~~~~~~~~~~~~~~~

The module "./dist-es/index.js" was not found on the file system:

var/runtime/node_modules/@aws-sdk/core/package.json:22:16:
  22 │       "module": "./dist-es/index.js",
     ╵                 ~~~~~~~~~~~~~~~~~~~~

You can mark the path "@aws-sdk/core" as external to exclude it from the bundle, which will remove this error and leave the unresolved path in the bundle. You can also surround this "require" call with a try/catch block to handle this failure at run-time instead of bundle-time.

✘ [ERROR] Could not resolve "@aws-sdk/core"

var/runtime/node_modules/@aws-sdk/client-dynamodb/dist-cjs/runtimeConfig.js:6:23:
  6 │ const core_1 = require("@aws-sdk/core");
    ╵                        ~~~~~~~~~~~~~~~

The module "./dist-es/index.js" was not found on the file system:

var/runtime/node_modules/@aws-sdk/core/package.json:22:16:
  22 │       "module": "./dist-es/index.js",
     ╵                 ~~~~~~~~~~~~~~~~~~~~

You can mark the path "@aws-sdk/core" as external to exclude it from the bundle, which will remove this error and leave the unresolved path in the bundle. You can also surround this "require" call with a try/catch block to handle this failure at run-time instead of bundle-time.

✘ [ERROR] Could not resolve "@aws-sdk/core"

var/runtime/node_modules/@aws-sdk/client-dynamodb/dist-cjs/runtimeConfig.shared.js:4:23:
  4 │ const core_1 = require("@aws-sdk/core");
    ╵                        ~~~~~~~~~~~~~~~

The module "./dist-es/index.js" was not found on the file system:

var/runtime/node_modules/@aws-sdk/core/package.json:22:16:
  22 │       "module": "./dist-es/index.js",
     ╵                 ~~~~~~~~~~~~~~~~~~~~

You can mark the path "@aws-sdk/core" as external to exclude it from the bundle, which will remove this error and leave the unresolved path in the bundle. You can also surround this "require" call with a try/catch block to handle this failure at run-time instead of bundle-time.

6 of 25 errors shown (disable the message limit with --log-limit=0) /Users/nasiaullas/fis-workshop/aws-fault-injection-simulator-workshop-v2/PetAdoptions/cdk/pet_stack/fis-workshop/aws-fault-injection-simulator-workshop-v2/PetAdoptions/cdk/pet_stack/node_modules/aws-cdk-lib/core/lib/asset-staging.js:2 ),localBundling=options.local?.tryBundle(bundleDir,options),!localBundling){const assetStagingOptions={sourcePath:this.sourcePath,bundleDir,...options};switch(options.bundlingFileAccess){case bundling_1().BundlingFileAccess.VOLUME_COPY:new(asset_staging_1()).AssetBundlingVolumeCopy(assetStagingOptions).run();break;case bundling_1().BundlingFileAccess.BIND_MOUNT:default:new(asset_staging_1()).AssetBundlingBindMount(assetStagingOptions).run();break}}}catch(err){const bundleErrorDir=bundleDir+"-error";throw fs().existsSync(bundleErrorDir)&&fs().removeSync(bundleErrorDir),fs().renameSync(bundleDir,bundleErrorDir),new Error(Failed to bundle asset ${this.node.path}, bundle output is located at ${bundleErrorDir}: ${err})}if(fs_1().FileSystem.isEmpty(bundleDir)){const outputDir=localBundling?bundleDir:AssetStaging.BUNDLING_OUTPUT_DIR;throw new Error(Bundling did not produce any output. Check that content is written to ${outputDir}.)}}calculateHash(hashType,bundling,outputDir){if(hashType==assets_1().AssetHashType.CUSTOM||hashType==assets_1().AssetHashType.SOURCE&&bundling){const hash=crypto().createHash("sha256");return hash.update(this.customSourceFingerprint??fs_1().FileSystem.fingerprint(this.sourcePath,this.fingerprintOptions)),bundling&&hash.update(JSON.stringify(bundling,sanitizeHashValue)),hash.digest("hex")}switch(hashType){case assets_1().AssetHashType.SOURCE:return fs_1().FileSystem.fingerprint(this.sourcePath,this.fingerprintOptions);case assets_1().AssetHashType.BUNDLE:case assets_1().AssetHashType.OUTPUT:if(!outputDir)throw new Error(Cannot use `${hashType}` hash type when `bundling` is not specified.);return fs_1().FileSystem.fingerprint(outputDir,this.fingerprintOptions);default:throw new Error("Unknown asset hash type.")}}}exports.AssetStaging=AssetStaging,_a=JSII_RTTI_SYMBOL_1,AssetStaging[_a]={fqn:"aws-cdk-lib.AssetStaging",version:"2.156.0"},AssetStaging.BUNDLING_INPUT_DIR="/asset-input",AssetStaging.BUNDLING_OUTPUT_DIR="/asset-output",AssetStaging.assetCache=new(cache_1()).Cache;function renderAssetFilename(assetHash,extension=""){returnasset.${assetHash}${extension}}function determineHashType(assetHashType,customSourceFingerprint){const hashType=customSourceFingerprint?assetHashType??assets_1().AssetHashType.CUSTOM:assetHashType??assets_1().AssetHashType.SOURCE;if(customSourceFingerprint&&hashType!==assets_1().AssetHashType.CUSTOM)throw new Error(Cannot specify `${assetHashType}` for `assetHashType` when `assetHash` is specified. Use `CUSTOM` or leave `undefined`.);if(hashType===assets_1().AssetHashType.CUSTOM&&!customSourceFingerprint)throw new Error("assetHashmust be specified whenassetHashTypeis set toAssetHashType.CUSTOM.");return hashType}function calculateCacheKey(props){return crypto().createHash("sha256").update(JSON.stringify(sortObject(props),sanitizeHashValue)).digest("hex")}function sortObject(object){if(typeof object!="object"||object instanceof Array)return object;const ret={};for(const key of Object.keys(object).sort())ret[key]=sortObject(object[key]);return ret}function sanitizeHashValue(key,value){if(key==="PIP_INDEX_URL"||key==="PIP_EXTRA_INDEX_URL")try{let url=new URL(value);if(url.password)return url.password="",url.toString()}catch(e){throw e.name==="TypeError"?new Error(${key} must be a valid URL, got ${value}.):e}return value}function findSingleFile(directory,archiveOnly){if(!fs().existsSync(directory))throw new Error(Directory ${directory} does not exist.);if(!fs().statSync(directory).isDirectory())throw new Error(${directory} is not a directory.);const content=fs().readdirSync(directory);if(content.length===1){const file=path().join(directory,content[0]),extension=getExtension(content[0]).toLowerCase();if(fs().statSync(file).isFile()&&(!archiveOnly||ARCHIVE_EXTENSIONS.includes(extension)))return file}}function determineBundledAsset(bundleDir,outputType){const archiveFile=findSingleFile(bundleDir,outputType!==bundling_1().BundlingOutput.SINGLE_FILE);switch(outputType===bundling_1().BundlingOutput.AUTO_DISCOVER&&(outputType=archiveFile?bundling_1().BundlingOutput.ARCHIVED:bundling_1().BundlingOutput.NOT_ARCHIVED),outputType){case bundling_1().BundlingOutput.NOT_ARCHIVED:return{path:bundleDir,packaging:assets_1().FileAssetPackaging.ZIP_DIRECTORY};case bundling_1().BundlingOutput.ARCHIVED:case bundling_1().BundlingOutput.SINGLE_FILE:if(!archiveFile)throw new Error("Bundling output directory is expected to include only a single file whenoutputis set toARCHIVEDorSINGLE_FILE`");return{path:archiveFile,packaging:assets_1().FileAssetPackaging.FILE,extension:getExtension(archiveFile)}}}function getExtension(source){for(const ext of ARCHIVE_EXTENSIONS)if(source.toLowerCase().endsWith(ext))return ext;return path().extname(source)} ^ Error: Failed to bundle asset Services/status-updater-service/lambdafn/Code/Stage, bundle output is located at /Users/nasiaullas/fis-workshop/aws-fault-injection-simulator-workshop-v2/PetAdoptions/cdk/pet_stack/fis-workshop/aws-fault-injection-simulator-workshop-v2/PetAdoptions/cdk/pet_stack/cdk.out/bundling-temp-fb12950cef4e334d5579295a3c6bd60de039be460322216a51a51f50a092db65-error: Error: docker exited with status 1 --> Command: docker run --rm -u "501:20" -v "/Users/nasiaullas/fis-workshop/aws-fault-injection-simulator-workshop-v2/PetAdoptions/cdk/pet_stack/fis-workshop/aws-fault-injection-simulator-workshop-v2/PetAdoptions/petstatusupdater:/asset-input:delegated" -v "/Users/nasiaullas/fis-workshop/aws-fault-injection-simulator-workshop-v2/PetAdoptions/cdk/pet_stack/fis-workshop/aws-fault-injection-simulator-workshop-v2/PetAdoptions/cdk/pet_stack/cdk.out/bundling-temp-fb12950cef4e334d5579295a3c6bd60de039be460322216a51a51f50a092db65:/asset-output:delegated" -w "/" cdk-27475b41497483cd009099c6f6867e2e8dc2c8ab55dde5c2e44d3dec82cf181c bash -c "esbuild --bundle \"/asset-input/index.js\" --target=node18 --platform=node --outfile=\"/asset-output/index.js\" --external:aws-sdk --external:aws-xray-sdk && echo '{\"dependencies\":{\"aws-xray-sdk\":\"^3.3.3\"}}' > \"/asset-output/package.json\" && cp \"/asset-input/package-lock.json\" \"/asset-output/package-lock.json\" && cd \"/asset-output\" && npm ci" at AssetStaging.bundle (/Users/nasiaullas/fis-workshop/aws-fault-injection-simulator-workshop-v2/PetAdoptions/cdk/pet_stack/fis-workshop/aws-fault-injection-simulator-workshop-v2/PetAdoptions/cdk/pet_stack/node_modules/aws-cdk-lib/core/lib/asset-staging.js:2:619) at AssetStaging.stageByBundling (/Users/nasiaullas/fis-workshop/aws-fault-injection-simulator-workshop-v2/PetAdoptions/cdk/pet_stack/fis-workshop/aws-fault-injection-simulator-workshop-v2/PetAdoptions/cdk/pet_stack/node_modules/aws-cdk-lib/core/lib/asset-staging.js:1:5297) at stageThisAsset (/Users/nasiaullas/fis-workshop/aws-fault-injection-simulator-workshop-v2/PetAdoptions/cdk/pet_stack/fis-workshop/aws-fault-injection-simulator-workshop-v2/PetAdoptions/cdk/pet_stack/node_modules/aws-cdk-lib/core/lib/asset-staging.js:1:2728) at Cache.obtain (/Users/nasiaullas/fis-workshop/aws-fault-injection-simulator-workshop-v2/PetAdoptions/cdk/pet_stack/fis-workshop/aws-fault-injection-simulator-workshop-v2/PetAdoptions/cdk/pet_stack/node_modules/aws-cdk-lib/core/lib/private/cache.js:1:242) at new AssetStaging (/Users/nasiaullas/fis-workshop/aws-fault-injection-simulator-workshop-v2/PetAdoptions/cdk/pet_stack/fis-workshop/aws-fault-injection-simulator-workshop-v2/PetAdoptions/cdk/pet_stack/node_modules/aws-cdk-lib/core/lib/asset-staging.js:1:3125) at new Asset (/Users/nasiaullas/fis-workshop/aws-fault-injection-simulator-workshop-v2/PetAdoptions/cdk/pet_stack/fis-workshop/aws-fault-injection-simulator-workshop-v2/PetAdoptions/cdk/pet_stack/node_modules/aws-cdk-lib/aws-s3-assets/lib/asset.js:1:1141) at AssetCode.bind (/Users/nasiaullas/fis-workshop/aws-fault-injection-simulator-workshop-v2/PetAdoptions/cdk/pet_stack/fis-workshop/aws-fault-injection-simulator-workshop-v2/PetAdoptions/cdk/pet_stack/node_modules/aws-cdk-lib/aws-lambda/lib/code.js:5:3487) at new Function (/Users/nasiaullas/fis-workshop/aws-fault-injection-simulator-workshop-v2/PetAdoptions/cdk/pet_stack/fis-workshop/aws-fault-injection-simulator-workshop-v2/PetAdoptions/cdk/pet_stack/node_modules/aws-cdk-lib/aws-lambda/lib/function.js:1:10003) at new NodejsFunction (/Users/nasiaullas/fis-workshop/aws-fault-injection-simulator-workshop-v2/PetAdoptions/cdk/pet_stack/fis-workshop/aws-fault-injection-simulator-workshop-v2/PetAdoptions/cdk/pet_stack/node_modules/aws-cdk-lib/aws-lambda-nodejs/lib/function.js:1:2111) at new StatusUpdaterService (/Users/nasiaullas/fis-workshop/aws-fault-injection-simulator-workshop-v2/PetAdoptions/cdk/pet_stack/fis-workshop/aws-fault-injection-simulator-workshop-v2/PetAdoptions/cdk/pet_stack/lib/services/status-updater-service.ts:35:28) Subprocess exited with error 1

richardmilnerwatts commented 5 hours ago

Same issue here, I'm trying to deploy the workshop into a fresh AWS account for a customer demo. I work for AWS, if you want me to reproduce this for you, you can reach out to milnerwa@

mrvladis commented 1 hour ago

Thank you for reporting. This has been fixed via the https://github.com/aws-samples/aws-fault-injection-simulator-workshop-v2/pull/97

Can you please test the latest version?