Skip to content

Commit

Permalink
fix: change scope of change detection for python layers (aws-amplify#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Attila Hajdrik authored and cjihrig-aws committed Jul 12, 2021
1 parent 2628b76 commit f676b68
Showing 1 changed file with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ const layerResourceGlobs = [parametersFileName, `*${cfnTemplateSuffix}`];
const libPathName = 'lib';
const optPathName = 'opt';
const packageJson = 'package.json';
const pipfile = 'Pipfile';
const pipfileLock = 'Pipfile.lock';

export interface LayerInputParams {
layerPermissions?: PermissionEnum[];
Expand Down Expand Up @@ -343,7 +345,28 @@ const getLayerGlobs = async (

result.push(...contentFilePaths);
} else if (runtimeId === 'python') {
// No special treatment needed for python yet.
// Add to hashable files/folders
const pipfileFilePath = path.join(layerCodePath, pipfile);

if (fs.existsSync(pipfileFilePath)) {
result.push(path.join(libPathName, layerExecutablePath, pipfile));
}

// If lock file is present, add to hashable files/folders
const pipfileLockFilePath = path.join(layerCodePath, pipfileLock);

if (fs.existsSync(pipfileLockFilePath)) {
result.push(path.join(libPathName, layerExecutablePath, pipfileLockFilePath));
}

// Add layer direct content from lib/python and exclude well known files from list.
// files must be relative to resource folder as that will be used as a base path for hashing.
const contentFilePaths = await globby([path.join(libPathName, layerExecutablePath, '**', '*')], {
cwd: resourcePath,
ignore: ['lib', pipfile, pipfileLock].map(name => path.join(libPathName, layerExecutablePath, name)),
});

result.push(...contentFilePaths);
} else {
const error = new Error(`Unsupported layer runtime: ${runtimeId} for resource: ${resourceName}`);
error.stack = undefined;
Expand Down

0 comments on commit f676b68

Please sign in to comment.