转换失败:部分目录没有执行权限

Conversion failed: Some directories do not have execute permissions

我正在尝试在 AWS CloudFormation 中创建一个 AWS Lambda 层,但发生错误:

Layer conversion failed: Some directories do not have execute permissions; (Service: AWSLambdaInternal; Status Code: 400; Error Code: InvalidParameterValueException; Request ID: eff63297-bf71-4578-a665-c493a9fbdb40)

CloudFormation 模板中的 Lambda 层定义:

LambdaLayerTest:
  Type: 'AWS::Lambda::LayerVersion'
  Properties:
    CompatibleRuntimes: 
      - nodejs8.10
    Content:
      S3Bucket: cf-us-west-2-test
      S3Key: LambdaLayerTest.zip
    Description: Lambda Layer Test
    LayerName: lambdalayertest

LambdaLayerTest.zip 是一个名为 "nodejs" 的文件夹,其中包含 node_modules 个文件夹、package.json 个文件和 yarn.lock 个文件。

package.json:

{
  "name": "mylayertest",
  "version": "1.0.0",
  "main": "index.js",
  "license": "ISC",
  "dependencies": {
     "aws-sdk": "2.307.0"
}

您的压缩文件夹中的文件权限对于 AWS Lambda 可能过于严格:

Permissions Policies on Lambda Deployment Packages

运行 chmod -R 755 <directory>递归修改所有子目录和文件的读、写和执行权限。