是否可以从 AWS CodeBuild build.yml 文件的"预构建"部分跳过"npm install"命令



我有一个lambda函数,它是通过aws代码构建部署的。

我当前的yml配置看起来像这个

version: 0.1
phases:
pre_build:
commands:
- FUNCTION_NAME=$FUNCTION_NAME
- ZIP_NAME=$ZIP_NAME
- BUCKET_NAME=$BUCKET_NAME
- npm install --silent --no-progress
- zip -r $ZIP_NAME.zip .
- aws s3 cp $ZIP_NAME.zip s3://$BUCKET_NAME/
build:
commands:
- echo $FUNCTION_NAME Deployment started!!!
- aws lambda update-function-code --function-name $FUNCTION_NAME --s3-bucket $BUCKET_NAME --s3-key $ZIP_NAME.zip
artifacts:
files: $ZIP_NAME.zip

在部署时,由于我的文件超过了的最大大小限制,出现了构建错误

An error occurred (InvalidParameterValueException) when calling the UpdateFunctionCode operation: Unzipped size must be smaller than 262144000 bytes

所以有任何方法可以在不从我的实际代码中删除任何内容的情况下解决这个问题

可以从预构建部分删除"npm install"并添加到构建部分吗?

根据AWS Lambda限制

  • 解压缩限制为250 MB,压缩限制为50MB

将lambda转换为基于docker的解决方案之一,因为lambda接受高达10GB的docker映像,但您最初需要构建docker映像。这将增加CI/CD管理和构建成本+ECR存储。

  • lambda还需要IAM权限才能进行ECR拉取

最新更新