Skip to content

Commit

Permalink
fix(lambda-layer-node-proxy-agent): Replace use of package.json with …
Browse files Browse the repository at this point in the history
…Dockerfile command `npm install [package]@[version]` (aws#17078)

## Summary

This PR fixes an issue where the package.json file used in `lambda-layer-node-proxy-agent` was not being bundled into monocdk / CDK v2. This is due to limitations of Ubergen. Ubergen only copies .ts  files, README.md  files and some special .json files.

This PR:
- Removes the package.json from `packages/@aws-cdk/lambda-layer-node-proxy-agent/layer`
- Adds a step in the layer's Dockerfile to install a specific version of `proxy-agent` i.e. `npm install [package]@[version]`. This is so that we can do without the `package.json` file while still managing which version we bundle with the layer.

Fixes: aws#17061

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
ryparker authored and TikiTDO committed Feb 21, 2022
1 parent 002efa9 commit 567e7ed
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
build.sh
.no-packagejson-validator
Empty file.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# base lambda image
FROM public.ecr.aws/lambda/nodejs:latest

ARG PROXY_AGENT_VERSION=5.0.0

USER root
RUN mkdir -p /opt
WORKDIR /tmp
Expand All @@ -17,8 +19,7 @@ RUN yum update -y \
#

RUN mkdir -p /opt/nodejs
COPY package.json /opt/nodejs
RUN cd /opt/nodejs && npm install
RUN cd /opt/nodejs && npm install proxy-agent@${PROXY_AGENT_VERSION}

#
# create the bundle
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ export class NodeProxyAgentLayer extends lambda.LayerVersion {
constructor(scope: Construct, id: string) {
super(scope, id, {
code: lambda.Code.fromAsset(path.join(__dirname, 'layer.zip'), {
// we hash the package.json (it contains the tools versions) because hashing the zip is non-deterministic
assetHash: hashFile(path.join(__dirname, '..', 'layer', 'package.json')),
// we hash the Dockerfile (it contains the tools versions) because hashing the zip is non-deterministic
assetHash: hashFile(path.join(__dirname, '..', 'layer', 'Dockerfile')),
}),
description: '/opt/nodejs/node_modules/proxy-agent',
});
Expand Down

0 comments on commit 567e7ed

Please sign in to comment.