Coder Social home page Coder Social logo

Property 'multiOwner' is missing in type 'ResourceAuthorizationData' when using a.allow.resource(functionWithDataAccess) as authorization about amplify-js HOT 4 CLOSED

gpavlov2016 avatar gpavlov2016 commented on June 12, 2024
Property 'multiOwner' is missing in type 'ResourceAuthorizationData' when using a.allow.resource(functionWithDataAccess) as authorization

from amplify-js.

Comments (4)

chrisbonifacio avatar chrisbonifacio commented on June 12, 2024

Hey @gpavlov2016 thanks for raising this issue and providing reproduction steps. We will reproduce this internally and provide an update soon.

from amplify-js.

chrisbonifacio avatar chrisbonifacio commented on June 12, 2024

I was able to reproduce the issue but it seems to be expected behavior. The a.allow.resource method is expected to be used on the schema level rather than the model level to grant a resource, in this case a lambda function, permission to perform Query, Mutation, and Subscription operations against the GraphQL API.

You can correct your schema code to this and it should work:

const schema = a
  .schema({
    Video: a
      .model({
        title: a.string(),
        timeOfDayStart: a.time(),
        timeOfDayEnd: a.time(),
        dateStart: a.date(),
        dateEnd: a.date(),
        impressionsTarget: a.integer(),
        zipCode: a.string(),
        s3Key: a.string(),
        thumbnail: a.string(),
        isRunning: a.boolean(),
      })
      .authorization([a.allow.owner()]),
  })
  .authorization([a.allow.resource(functionWithDataAccess)]);

Let me know if this unblocks you or if you run into an issue with this example as well

from amplify-js.

chrisbonifacio avatar chrisbonifacio commented on June 12, 2024

Hi 👋 Closing this as we have not heard back from you. If you are still experiencing this issue and in need of assistance, please feel free to comment and provide us with any information previously requested by our team members so we can re-open this issue and be better able to assist you.

Thank you!

from amplify-js.

gpavlov2016 avatar gpavlov2016 commented on June 12, 2024

Applying the authorization to the schema as suggested does remove the type error however it results in a new error during deployment of the sandbox as follows:

const schema = a
  .schema({
    Video: a
      .model({
        title: a.string(),
        timeOfDayStart: a.time(),
        timeOfDayEnd: a.time(),
        dateStart: a.date(),
        dateEnd: a.date(),
        impressionsTarget: a.integer(),
        zipCode: a.string(),
        s3Key: a.string(),
        thumbnail: a.string(),
        isRunning: a.boolean(),
      })
      .authorization([a.allow.owner()]),
  })
  .authorization([a.allow.resource(getPresignedUrl)]);

Error:

[

[Sandbox] Detected file changes while previous deployment was in progress. Invoking 'sandbox' again

Error: WARNING: owners may reassign ownership for the following model(s) and role(s): Video: [owner]. If this is not intentional, you may want to apply field-level authorization rules to these fields. To read more: https://docs.amplify.aws/cli/graphql/authorization-rules/#per-user--owner-based-data-access.
Bundling asset amplify-nextamplifygen2-GuyPavlov-sandbox-5763ff2c4a/function/presigned-url-lambda/Code/Stage...
X [ERROR] Must use "outdir" when there are multiple input files

1 error
node:child_process:929
throw err;
^

Error: Command failed: C:\Users\Guy Pavlov\UpWork\ad-platform\ad-portal\node_modules@esbuild\win32-x64\esbuild.exe --bundle C:\Users\Guy Pavlov\UpWork\ad-platform\ad-portal\amplify\functions\presigned-url\handler.ts --target=node18 --platform=node --format=esm --outfile=C:\Users\Guy Pavlov\UpWork\ad-platform\ad-portal.amplify\artifacts\cdk.out\bundling-temp-e9230d152b0810080159375cfbc0a4ef95e64e8e4cd66a766f288da9cc5dba82\index.mjs --external:@aws-sdk/* --loader:.node=file --banner:js=/** * This code loads environment values from SSM and places them in their corresponding environment variables. * If there are no SSM environment values for this function, this is a noop. /import { SSM } from '@aws-sdk/client-ssm';/* * Reads SSM environment context from a known Amplify environment variable, * fetches values from SSM and places those values in the corresponding environment variables */export const internalAmplifyFunctionResolveSsmParams = async (client = new SSM()) => { const envPathObject = JSON.parse(process.env.AMPLIFY_SSM_ENV_CONFIG ?? '{}'); const paths = Object.keys(envPathObject); if (paths.length === 0) { return; } const resolveSecrets = async (paths) => { const response = await client.getParameters({ Names: paths, WithDecryption: true, }); if (response.Parameters && response.Parameters.length > 0) { for (const parameter of response.Parameters) { if (parameter.Name) { const envKey = Object.keys(envPathObject).find((key) => envPathObject[key].sharedPath === parameter.Name); const envName = envKey ? envPathObject[envKey].name : envPathObject[parameter.Name]?.name; process.env[envName] = parameter.Value; } } } return response; }; const response = await resolveSecrets(paths); const sharedPaths = (response?.InvalidParameters || []) .map((invalidParam) => envPathObject[invalidParam].sharedPath) .filter((sharedParam) => !!sharedParam); if (sharedPaths.length > 0) { await resolveSecrets(sharedPaths); }};await internalAmplifyFunctionResolveSsmParams();const SSM_PARAMETER_REFRESH_MS = 1000 * 60;setInterval(() => { void internalAmplifyFunctionResolveSsmParams();}, SSM_PARAMETER_REFRESH_MS);export {}; --inject:C:\Users\Guy Pavlov\UpWork\ad-platform\ad-portal\node_modules@aws-amplify\backend-function\lib\lambda-shims\cjs_shim.js
at checkExecSyncError (node:child_process:890:11)
at Object.execFileSync (node:child_process:926:15)
at Object. (C:\Users\Guy Pavlov\UpWork\ad-platform\ad-portal\node_modules\esbuild\bin\esbuild:221:28)
at Module._compile (node:internal/modules/cjs/loader:1356:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1414:10)
at Module.load (node:internal/modules/cjs/loader:1197:32)
at Module._load (node:internal/modules/cjs/loader:1013:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:128:12)
at node:internal/main/run_main_module:28:49 {
status: 1,
signal: null,
output: [ null, null, null ],
pid: 34788,
stdout: null,
stderr: null
}

Node.js v18.19.1
C:\Users\Guy Pavlov\UpWork\ad-platform\ad-portal\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.134.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 when outputis 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 amplify-nextamplifygen2-GuyPavlov-sandbox-5763ff2c4a/function/presigned-url-lambda/Code/Stage, bundle output is located at C:\Users\Guy Pavlov\UpWork\ad-platform\ad-portal.amplify\artifacts\cdk.out\bundling-temp-e9230d152b0810080159375cfbc0a4ef95e64e8e4cd66a766f288da9cc5dba82-error: Error: cmd /c npx.cmd --no-install esbuild --bundle "C:\Users\Guy Pavlov\UpWork\ad-platform\ad-portal\amplify\functions\presigned-url\handler.ts" --target=node18 --platform=node --format=esm --outfile="C:\Users\Guy Pavlov\UpWork\ad-platform\ad-portal.amplify\artifacts\cdk.out\bundling-temp-e9230d152b0810080159375cfbc0a4ef95e64e8e4cd66a766f288da9cc5dba82\index.mjs" --external:@aws-sdk/* --loader:.node=file --banner:js="/** * This code loads environment values from SSM and places them in their corresponding environment variables. * If there are no SSM environment values for this function, this is a noop. /import { SSM } from '@aws-sdk/client-ssm';/* * Reads SSM environment context from a known Amplify environment variable, * fetches values from SSM and places those values in the corresponding environment variables */export const internalAmplifyFunctionResolveSsmParams = async (client = new SSM()) => { const envPathObject = JSON.parse(process.env.AMPLIFY_SSM_ENV_CONFIG ?? '{}'); const paths = Object.keys(envPathObject); if (paths.length === 0) { return; } const resolveSecrets = async (paths) => { const response = await client.getParameters({ Names: paths, WithDecryption: true, }); if (response.Parameters && response.Parameters.length > 0) { for (const parameter of response.Parameters) { if (parameter.Name) {
const envKey = Object.keys(envPathObject).find((key) => envPathObject[key].sharedPath === parameter.Name); const envName = envKey ? envPathObject[envKey].name : envPathObject[parameter.Name]?.name; process.env[envName] = parameter.Value; } } } return response; }; const response = await resolveSecrets(paths); const sharedPaths = (response?.InvalidParameters || []) .map((invalidParam) => envPathObject[invalidParam].sharedPath) .filter((sharedParam) => !!sharedParam); if (sharedPaths.length > 0) { await resolveSecrets(sharedPaths); }};await internalAmplifyFunctionResolveSsmParams();const SSM_PARAMETER_REFRESH_MS = 1000 * 60;setInterval(() => { void internalAmplifyFunctionResolveSsmParams();}, SSM_PARAMETER_REFRESH_MS);export {};" --inject:C:\Users\Guy Pavlov\UpWork\ad-platform\ad-portal\node_modules@aws-amplify\backend-function\lib\lambda-shims\cjs_shim.js run in directory C:\Users\Guy Pavlov\UpWork\ad-platform\ad-portal exited with status 1
at AssetStaging.bundle (C:\Users\Guy Pavlov\UpWork\ad-platform\ad-portal\node_modules\aws-cdk-lib\core\lib\asset-staging.js:2:619)
at AssetStaging.stageByBundling (C:\Users\Guy Pavlov\UpWork\ad-platform\ad-portal\node_modules\aws-cdk-lib\core\lib\asset-staging.js:1:5297)
at stageThisAsset (C:\Users\Guy Pavlov\UpWork\ad-platform\ad-portal\node_modules\aws-cdk-lib\core\lib\asset-staging.js:1:2728)
at Cache.obtain (C:\Users\Guy Pavlov\UpWork\ad-platform\ad-portal\node_modules\aws-cdk-lib\core\lib\private\cache.js:1:242)
at new AssetStaging (C:\Users\Guy Pavlov\UpWork\ad-platform\ad-portal\node_modules\aws-cdk-lib\core\lib\asset-staging.js:1:3125)
at new Asset (C:\Users\Guy Pavlov\UpWork\ad-platform\ad-portal\node_modules\aws-cdk-lib\aws-s3-assets\lib\asset.js:1:1080)
at AssetCode.bind (C:\Users\Guy Pavlov\UpWork\ad-platform\ad-portal\node_modules\aws-cdk-lib\aws-lambda\lib\code.js:1:4881)
at new Function (C:\Users\Guy Pavlov\UpWork\ad-platform\ad-portal\node_modules\aws-cdk-lib\aws-lambda\lib\function.js:1:9422)
at new NodejsFunction (C:\Users\Guy Pavlov\UpWork\ad-platform\ad-portal\node_modules\aws-cdk-lib\aws-lambda-nodejs\lib\function.js:1:1669)
at AmplifyFunction (C:\Users\Guy Pavlov\UpWork\ad-platform\ad-portal\node_modules@aws-amplify\backend-function\src\factory.ts:292:28)

Node.js v18.19.1
Subprocess exited with error 1

Caused By: WARNING: owners may reassign ownership for the following model(s) and role(s): Video: [owner]. If this is not intentional, you may want to apply field-level authorization rules to these fields. To read more: https://docs.amplify.aws/cli/graphql/authorization-rules/#per-user--owner-based-data-access.
Bundling asset amplify-nextamplifygen2-GuyPavlov-sandbox-5763ff2c4a/function/presigned-url-lambda/Code/Stage...
X [ERROR] Must use "outdir" when there are multiple input files

1 error
node:child_process:929
throw err;
^

Error: Command failed: C:\Users\Guy Pavlov\UpWork\ad-platform\ad-portal\node_modules@esbuild\win32-x64\esbuild.exe --bundle C:\Users\Guy Pavlov\UpWork\ad-platform\ad-portal\amplify\functions\presigned-url\handler.ts --target=node18 --platform=node --format=esm --outfile=C:\Users\Guy Pavlov\UpWork\ad-platform\ad-portal.amplify\artifacts\cdk.out\bundling-temp-e9230d152b0810080159375cfbc0a4ef95e64e8e4cd66a766f288da9cc5dba82\index.mjs --external:@aws-sdk/* --loader:.node=file --banner:js=/** * This code loads environment values from SSM and places them in their corresponding environment variables. * If there are no SSM environment values for this function, this is a noop. /import { SSM } from '@aws-sdk/client-ssm';/* * Reads SSM environment context from a known Amplify environment variable, * fetches values from SSM and places those values in the corresponding environment variables */export const internalAmplifyFunctionResolveSsmParams = async (client = new SSM()) => { const envPathObject = JSON.parse(process.env.AMPLIFY_SSM_ENV_CONFIG ?? '{}'); const paths = Object.keys(envPathObject); if (paths.length === 0) { return; } const resolveSecrets = async (paths) => { const response = await client.getParameters({ Names: paths, WithDecryption: true, }); if (response.Parameters && response.Parameters.length > 0) { for (const parameter of response.Parameters) { if (parameter.Name) { const envKey = Object.keys(envPathObject).find((key) => envPathObject[key].sharedPath === parameter.Name); const envName = envKey ? envPathObject[envKey].name : envPathObject[parameter.Name]?.name; process.env[envName] = parameter.Value; } } } return response; }; const response = await resolveSecrets(paths); const sharedPaths = (response?.InvalidParameters || []) .map((invalidParam) => envPathObject[invalidParam].sharedPath) .filter((sharedParam) => !!sharedParam); if (sharedPaths.length > 0) { await resolveSecrets(sharedPaths); }};await internalAmplifyFunctionResolveSsmParams();const SSM_PARAMETER_REFRESH_MS = 1000 * 60;setInterval(() => { void internalAmplifyFunctionResolveSsmParams();}, SSM_PARAMETER_REFRESH_MS);export {}; --inject:C:\Users\Guy Pavlov\UpWork\ad-platform\ad-portal\node_modules@aws-amplify\backend-function\lib\lambda-shims\cjs_shim.js
at checkExecSyncError (node:child_process:890:11)
at Object.execFileSync (node:child_process:926:15)
at Object. (C:\Users\Guy Pavlov\UpWork\ad-platform\ad-portal\node_modules\esbuild\bin\esbuild:221:28)
at Module._compile (node:internal/modules/cjs/loader:1356:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1414:10)
at Module.load (node:internal/modules/cjs/loader:1197:32)
at Module._load (node:internal/modules/cjs/loader:1013:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:128:12)
at node:internal/main/run_main_module:28:49 {
status: 1,
signal: null,
output: [ null, null, null ],
pid: 34788,
stdout: null,
stderr: null
}

Node.js v18.19.1
C:\Users\Guy Pavlov\UpWork\ad-platform\ad-portal\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.134.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 when outputis 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 amplify-nextamplifygen2-GuyPavlov-sandbox-5763ff2c4a/function/presigned-url-lambda/Code/Stage, bundle output is located at C:\Users\Guy Pavlov\UpWork\ad-platform\ad-portal.amplify\artifacts\cdk.out\bundling-temp-e9230d152b0810080159375cfbc0a4ef95e64e8e4cd66a766f288da9cc5dba82-error: Error: cmd /c npx.cmd --no-install esbuild --bundle "C:\Users\Guy Pavlov\UpWork\ad-platform\ad-portal\amplify\functions\presigned-url\handler.ts" --target=node18 --platform=node --format=esm --outfile="C:\Users\Guy Pavlov\UpWork\ad-platform\ad-portal.amplify\artifacts\cdk.out\bundling-temp-e9230d152b0810080159375cfbc0a4ef95e64e8e4cd66a766f288da9cc5dba82\index.mjs" --external:@aws-sdk/* --loader:.node=file --banner:js="/** * This code loads environment values from SSM and places them in their corresponding environment variables. * If there are no SSM environment values for this function, this is a noop. /import { SSM } from '@aws-sdk/client-ssm';/* * Reads SSM environment context from a known Amplify environment variable, * fetches values from SSM and places those values in the corresponding environment variables */export const internalAmplifyFunctionResolveSsmParams = async (client = new SSM()) => { const envPathObject = JSON.parse(process.env.AMPLIFY_SSM_ENV_CONFIG ?? '{}'); const paths = Object.keys(envPathObject); if (paths.length === 0) { return; } const resolveSecrets = async (paths) => { const response = await client.getParameters({ Names: paths, WithDecryption: true, }); if (response.Parameters && response.Parameters.length > 0) { for (const parameter of response.Parameters) { if (parameter.Name) {
const envKey = Object.keys(envPathObject).find((key) => envPathObject[key].sharedPath === parameter.Name); const envName = envKey ? envPathObject[envKey].name : envPathObject[parameter.Name]?.name; process.env[envName] = parameter.Value; } } } return response; }; const response = await resolveSecrets(paths); const sharedPaths = (response?.InvalidParameters || []) .map((invalidParam) => envPathObject[invalidParam].sharedPath) .filter((sharedParam) => !!sharedParam); if (sharedPaths.length > 0) { await resolveSecrets(sharedPaths); }};await internalAmplifyFunctionResolveSsmParams();const SSM_PARAMETER_REFRESH_MS = 1000 * 60;setInterval(() => { void internalAmplifyFunctionResolveSsmParams();}, SSM_PARAMETER_REFRESH_MS);export {};" --inject:C:\Users\Guy Pavlov\UpWork\ad-platform\ad-portal\node_modules@aws-amplify\backend-function\lib\lambda-shims\cjs_shim.js run in directory C:\Users\Guy Pavlov\UpWork\ad-platform\ad-portal exited with status 1
at AssetStaging.bundle (C:\Users\Guy Pavlov\UpWork\ad-platform\ad-portal\node_modules\aws-cdk-lib\core\lib\asset-staging.js:2:619)
at AssetStaging.stageByBundling (C:\Users\Guy Pavlov\UpWork\ad-platform\ad-portal\node_modules\aws-cdk-lib\core\lib\asset-staging.js:1:5297)
at stageThisAsset (C:\Users\Guy Pavlov\UpWork\ad-platform\ad-portal\node_modules\aws-cdk-lib\core\lib\asset-staging.js:1:2728)
at Cache.obtain (C:\Users\Guy Pavlov\UpWork\ad-platform\ad-portal\node_modules\aws-cdk-lib\core\lib\private\cache.js:1:242)
at new AssetStaging (C:\Users\Guy Pavlov\UpWork\ad-platform\ad-portal\node_modules\aws-cdk-lib\core\lib\asset-staging.js:1:3125)
at new Asset (C:\Users\Guy Pavlov\UpWork\ad-platform\ad-portal\node_modules\aws-cdk-lib\aws-s3-assets\lib\asset.js:1:1080)
at AssetCode.bind (C:\Users\Guy Pavlov\UpWork\ad-platform\ad-portal\node_modules\aws-cdk-lib\aws-lambda\lib\code.js:1:4881)
at new Function (C:\Users\Guy Pavlov\UpWork\ad-platform\ad-portal\node_modules\aws-cdk-lib\aws-lambda\lib\function.js:1:9422)
at new NodejsFunction (C:\Users\Guy Pavlov\UpWork\ad-platform\ad-portal\node_modules\aws-cdk-lib\aws-lambda-nodejs\lib\function.js:1:1669)
at AmplifyFunction (C:\Users\Guy Pavlov\UpWork\ad-platform\ad-portal\node_modules@aws-amplify\backend-function\src\factory.ts:292:28)

Node.js v18.19.1
Subprocess exited with error 1

[Sandbox] Watching for file changes...

from amplify-js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.