user1729210
user1729210

Reputation: 659

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 CloudFormation 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 CloudFormation 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 CloudFormation 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 CloudFormation?

Upvotes: 1

Views: 447

Answers (1)

brushtakopo
brushtakopo

Reputation: 1408

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

Upvotes: 3

Related Questions