代码管道无法使用 sam 模板在 Lambda 中创建层
Code Pipeline not able to create Layers in Lambda using sam template
我有下面的sam模板
AWSTemplateFormatVersion: '2010-09-09'
Transform: 'AWS::Serverless-2016-10-31'
Description: An AWS Serverless Specification template describing lambda 1 function.
Resources:
awstransformedcurlambdafn:
Type: 'AWS::Serverless::Function'
Properties:
FunctionName: lambda1
Handler: index.handler
Runtime: nodejs12.x
CodeUri: .
Description: ''
MemorySize: 256
Timeout: 300
Role: 'arn:aws:iam::11111111:role/Role1'
Tracing: Active
transformedcurNodeModulesLayer:
Type: AWS::Serverless::LayerVersion
Properties:
LayerName: layer-lambda1
Description: layers with log4js library
ContentUri: ./layers/nodejs/
CompatibleRuntimes:
- nodejs12.x
LicenseInfo: 'Available under the MIT-0 license.'
RetentionPolicy: Retain
现在我的层文件夹中包含所有节点 js 包
文件夹结构。
layers ----> nodejs ---> package.json & node_modules --> log4j ....
现在在 运行 代码管道之后它获得了成功,但是看到没有创建层但是 sam 模板部署成功,甚至我的新代码也是如此。
我根据上面的代码看到,函数资源中没有设置 Layers 选项
Resources:
awstransformedcurlambdafn:
Type: 'AWS::Serverless::Function'
Properties:
FunctionName: lambda1
Handler: index.handler
Runtime: nodejs12.x
CodeUri: .
Description: ''
MemorySize: 256
Timeout: 300
Role: 'arn:aws:iam::11111111:role/Role1'
Tracing: Active
Layers:
- !Ref transformedcurNodeModulesLayer
transformedcurNodeModulesLayer:
Type: AWS::Serverless::LayerVersion
Properties:
LayerName: layer-lambda1
Description: layers with log4js library
ContentUri: ./layers/
CompatibleRuntimes:
- nodejs12.x
LicenseInfo: 'Available under the MIT-0 license.'
RetentionPolicy: Retain
能否尝试在您的“awstransformedcurlambdafn”函数资源中添加以上 属性?
我有下面的sam模板
AWSTemplateFormatVersion: '2010-09-09'
Transform: 'AWS::Serverless-2016-10-31'
Description: An AWS Serverless Specification template describing lambda 1 function.
Resources:
awstransformedcurlambdafn:
Type: 'AWS::Serverless::Function'
Properties:
FunctionName: lambda1
Handler: index.handler
Runtime: nodejs12.x
CodeUri: .
Description: ''
MemorySize: 256
Timeout: 300
Role: 'arn:aws:iam::11111111:role/Role1'
Tracing: Active
transformedcurNodeModulesLayer:
Type: AWS::Serverless::LayerVersion
Properties:
LayerName: layer-lambda1
Description: layers with log4js library
ContentUri: ./layers/nodejs/
CompatibleRuntimes:
- nodejs12.x
LicenseInfo: 'Available under the MIT-0 license.'
RetentionPolicy: Retain
现在我的层文件夹中包含所有节点 js 包
文件夹结构。
layers ----> nodejs ---> package.json & node_modules --> log4j ....
现在在 运行 代码管道之后它获得了成功,但是看到没有创建层但是 sam 模板部署成功,甚至我的新代码也是如此。
我根据上面的代码看到,函数资源中没有设置 Layers 选项
Resources:
awstransformedcurlambdafn:
Type: 'AWS::Serverless::Function'
Properties:
FunctionName: lambda1
Handler: index.handler
Runtime: nodejs12.x
CodeUri: .
Description: ''
MemorySize: 256
Timeout: 300
Role: 'arn:aws:iam::11111111:role/Role1'
Tracing: Active
Layers:
- !Ref transformedcurNodeModulesLayer
transformedcurNodeModulesLayer:
Type: AWS::Serverless::LayerVersion
Properties:
LayerName: layer-lambda1
Description: layers with log4js library
ContentUri: ./layers/
CompatibleRuntimes:
- nodejs12.x
LicenseInfo: 'Available under the MIT-0 license.'
RetentionPolicy: Retain
能否尝试在您的“awstransformedcurlambdafn”函数资源中添加以上 属性?