Skip to content

Commit 682052c

Browse files
fix: Checks for npm instead of runtime when building nodejs packages (#364)
Co-authored-by: Anton Babenko <[email protected]>
1 parent eb4ca20 commit 682052c

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

examples/build-package/main.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,8 @@ module "package_with_docker" {
219219
docker_pip_cache = true
220220
docker_with_ssh_agent = true
221221
# docker_file = "${path.module}/../fixtures/python3.8-app1/docker/Dockerfile"
222-
docker_build_root = "${path.module}/../../docker"
223-
docker_image = "public.ecr.aws/sam/build-python3.8"
222+
docker_build_root = "${path.module}/../fixtures/python3.8-app1/docker"
223+
docker_image = "public.ecr.aws/sam/build-python3.8:latest"
224224
}
225225

226226
# Create zip-archive of a single directory where "npm install" will also be executed (default for nodejs runtime)
@@ -278,7 +278,7 @@ module "lambda_layer" {
278278

279279
build_in_docker = true
280280
runtime = "python3.8"
281-
docker_image = "public.ecr.aws/sam/build-python3.8"
281+
docker_image = "public.ecr.aws/sam/build-python3.8:latest"
282282
docker_file = "${path.module}/../fixtures/python3.8-app1/docker/Dockerfile"
283283
}
284284

package.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -649,6 +649,7 @@ def plan(self, source_path, query):
649649
hash = source_paths.append
650650

651651
def pip_requirements_step(path, prefix=None, required=False, tmp_dir=None):
652+
command = runtime
652653
requirements = path
653654
if os.path.isdir(path):
654655
requirements = os.path.join(path, 'requirements.txt')
@@ -657,16 +658,17 @@ def pip_requirements_step(path, prefix=None, required=False, tmp_dir=None):
657658
raise RuntimeError(
658659
'File not found: {}'.format(requirements))
659660
else:
660-
if not query.docker and not shutil.which(runtime):
661+
if not query.docker and not shutil.which(command):
661662
raise RuntimeError(
662663
"Python interpreter version equal "
663664
"to defined lambda runtime ({}) should be "
664-
"available in system PATH".format(runtime))
665+
"available in system PATH".format(command))
665666

666667
step('pip', runtime, requirements, prefix, tmp_dir)
667668
hash(requirements)
668669

669670
def npm_requirements_step(path, prefix=None, required=False, tmp_dir=None):
671+
command = "npm"
670672
requirements = path
671673
if os.path.isdir(path):
672674
requirements = os.path.join(path, 'package.json')
@@ -675,11 +677,10 @@ def npm_requirements_step(path, prefix=None, required=False, tmp_dir=None):
675677
raise RuntimeError(
676678
'File not found: {}'.format(requirements))
677679
else:
678-
if not query.docker and not shutil.which(runtime):
680+
if not query.docker and not shutil.which(command):
679681
raise RuntimeError(
680-
"Nodejs interpreter version equal "
681-
"to defined lambda runtime ({}) should be "
682-
"available in system PATH".format(runtime))
682+
"Nodejs package manager ({}) should be "
683+
"available in system PATH".format(command))
683684

684685
step('npm', runtime, requirements, prefix, tmp_dir)
685686
hash(requirements)

0 commit comments

Comments
 (0)