如何解决修剪失败后的 aws cloudformation 包
我在 NodeJS 中有一个应用程序,我正在使用 AWS CodeBuild 构建该应用程序,然后使用 AWS Cloudformation 部署到 AWS lambda。在我的 buildspec.yaml
中,我安装节点应用程序并运行测试,然后,在发出 aws cloudformation package
命令之前,我执行了一个 prune 命令,以便只保留生产依赖项:
npm prune --production
当我发出 aws cloudformation package
命令时,它失败并显示以下错误:
Error: Unable to upload artifact nodejs/. referenced by ContentUri parameter of CommonLayer resource.
[Errno 2] No such file or directory: '/codebuild/output/src609569331/src/common/nodejs/node_modules/.bin/watch'
我的构建规范文件:
version: 0.2
phases:
install:
runtime-versions:
nodejs: 12.x
commands:
- echo INSTALL STARTED on `date`
- cd common/nodejs
- npm install -g npm
- npm ci
# Prevent files from having a timestamp before 1980!!!
# Without this the build fails with "zip does not support timestamps before 1980"!
- find ./node_modules -mtime +10950 -exec touch {} \;
# Upgrade AWS CLI to the latest version
- pip install --upgrade awscli
- echo INSTALL COMPLETED on `date`
pre_build:
commands:
- echo PRE_BUILD STARTED on `date`
- npm run lint
- npm test
- npm prune --production
- cd ..
- echo PRE_BUILD COMPLETED on `date`
build:
commands:
- echo BUILD STARTED on `date`
- aws cloudformation package --template-file lambda-template.yaml
--output-template-file packaged-common-deployment.yaml
--s3-bucket "${BUILD_BUCKET}"
- echo BUILD COMPLETED on `date`
artifacts:
type: zip
files:
- "**/*"
base-directory: common
discard-paths: no
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。