如何将 AWS 公共扩展添加到 AWS Lambda 云形成模板?

huangapple go评论64阅读模式
英文:

How to add a AWS public extension to a AWS Lambda cloud formation template?

问题

I want to add the 'AWS-Parameters-and-Secrets-Lambda-Extension' public extension to the cloud formation template of my AWS Lambda function. Everything I found so far adds the public extension either by i) the AWS lambda console or ii) the AWS cli. The cloud formation doc itself states that the AWS::Lambda::LayerVersion only allows to create lambda layers from a zip archive. I've also tried to export the cloud formation template of a function where I've added the extension using the AWS Lambda console, but that doesn't seem to do the trick. How do I add this extension to cloud formation?

英文:

I want to add the 'AWS-Parameters-and-Secrets-Lambda-Extension' public extension to the cloud formation template of my AWS Lambda function.

Everything I found so far adds the public extension either by i) the AWS lambda console or ii) the AWS cli. The cloud formation doc itself states that the AWS::Lambda::LayerVersion only allows to create lambda layers from a zip archive. I've also tried to export the cloud formation template of a function where I've added the extension using the AWS Lambda console, but that doesn't seem to do the trick.

How do I add this extension to cloud formation?

答案1

得分: 2

这一层是 AWS::Lambda::Function 的一部分,查看文档这里

然后,层的 ARN 取决于您要部署 Lambda 的区域。这里是基于区域的列表。

对于 eu-west-1,可以类似这样:

Resources:
  Function:
    Type: AWS::Lambda::Function
    Properties:
      Handler: index.handler
      Role: arn:aws:iam::123456789012:role/lambda-role
      Layers:
        - arn:aws:lambda:eu-west-1:015030872274:layer:AWS-Parameters-and-Secrets-Lambda-Extension:4
      Code:
        S3Bucket: my-bucket
        S3Key: function.zip
      Runtime: nodejs12.x
      Timeout: 5
      TracingConfig:
        Mode: Active
英文:

The layer is part of AWS::Lambda::Function, see the doc here.

Then the layer ARN depending on the region you want to deploy your lambda. Here is the list based on the region.

Something like this for eu-west-1:

Resources:
  Function:
    Type: AWS::Lambda::Function
    Properties:
      Handler: index.handler
      Role: arn:aws:iam::123456789012:role/lambda-role
      Layers:
        - arn:aws:lambda:eu-west-1:015030872274:layer:AWS-Parameters-and-Secrets-Lambda-Extension:4
      Code:
        S3Bucket: my-bucket
        S3Key: function.zip
      Runtime: nodejs12.x
      Timeout: 5
      TracingConfig:
        Mode: Active

huangapple
  • 本文由 发表于 2023年5月11日 15:59:16
  • 转载请务必保留本文链接:https://go.coder-hub.com/76225324.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定