aws-powertools / powertools-lambda

MIT No Attribution
73 stars 4 forks source link

Public Lambda Layers ARN instead of SAR App #2

Closed heitorlessa closed 3 years ago

heitorlessa commented 3 years ago

Original author: @ecolban

Runtime e.g. Python, Java, all of them. All of them

Is your feature request related to a problem? Please describe.

As described in the Lambda Powertools Python discussion, Layers are currently available as a Serverless Application Repository (SAR) App and not as a public Lambda Layer ARN.

While this allows customers to selectively deploy the semantic version they're interested in it does require deploying a SAR App before they can use the Lambda Layer.

Describe the solution you'd like

Make Lambda Layer ARN publicly available per region. This will make it easier to add Lambda Powertools to existing projects.

Some examples: https://github.com/mthenw/awesome-layers

Describe alternatives you've considered

Building and publishing own Lambda Layer though that adds operational overhead in maintaining.

Is this something you'd like to contribute if you had guidance?

Additional context

stephenbawks commented 3 years ago

Would love to have this as a layer. Been using Serverless Framework but I see this appears to be only available in eu-west-1. I am in the US so having layers here as well would be great.

heitorlessa commented 3 years ago

Absolutely - one misconception though is that we're using Serverless Application Repository (SAR) Application as a layer, and while its ARN is EU-West-1 it can be deployed anywhere globally.

Once deployed, it'll create a Lambda Layer in the region you deployed, and that's the ARN you can use.

I'll create a sample in the docs on how to do it for Serverless framework, as @am29d continurs to work on the public ARN folks will be able to use directly in Lambda with any framework

stephenbawks commented 3 years ago

Ahh gotcha. Yah sadly I have not used a ton of SAR yet but I guess I will need to check this out.

I am using Serverless Framework for this and being able to add it as a layer would be by far the easy path.

stephenbawks commented 3 years ago

I guess maybe a follow up question then now that I think about it. Since I am using a container for my lambda, are there some install commands where I can pull this in since a layer is not going to work for a container deployment.

mwarkentin commented 3 years ago

@stephenbawks doesn't help with your container question, but here's how you can configure this through serverless:

resources:
  Transform: AWS::Serverless-2016-10-31
  Resources:
    AwsLambdaPowertoolsPythonLayer:
      Type: AWS::Serverless::Application
      Properties:
        Location:
          ApplicationId: arn:aws:serverlessrepo:eu-west-1:057560766410:applications/aws-lambda-powertools-python-layer
          SemanticVersion: # Add latest version from https://github.com/awslabs/aws-lambda-powertools-python/releases

Which can then be used to define the layer:

functions:
  main:
    handler: lambda_function.lambda_handler
    layers:
      - !GetAtt AwsLambdaPowertoolsPythonLayer.Outputs.LayerVersionArn
dreamorosi commented 3 years ago

What about publishing it as an extension in the newly released CloudFormation Registry? The resource (layer) could be deployed by Customers in their own account and we could also consider the Stack to accept a parameter from the user to specify semver of the layer to deploy.

heitorlessa commented 3 years ago

That’s a neat idea, Andrea!!!

I think that still requires additional steps to use it (activate), and also requires extra steps for us to publish it — As Alex frees up bandwidth, his work in creating a CI/CD Pipeline for publishing layers in every region will also allow us to bring Lambda Powertools Layer in the Console at some point … hence why it’s taking much longer than expected

On Mon, 28 Jun 2021 at 12:04, Andrea Amorosi @.***> wrote:

What about publishing it as an extension in the newly released CloudFormation Registry https://aws.amazon.com/blogs/aws/introducing-a-public-registry-for-aws-cloudformation/? The resource (layer) could be deployed by Customers in their own account and we could also consider the Stack to accept a parameter from the user to specify semver of the layer to deploy.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/awslabs/aws-lambda-powertools-roadmap/issues/2#issuecomment-869552272, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAZPQBFDS2ML5L6PKFECSM3TVBCJHANCNFSM442OIG7A .

DanyC97 commented 3 years ago

What about publishing it as an extension in the newly released CloudFormation Registry? The resource (layer) could be deployed by Customers in their own account and we could also consider the Stack to accept a parameter from the user to specify semver of the layer to deploy.

i guess this is a nice idea but what about those who are on TF land? imo just publish public layers will cover a wider audience rather than cloudformation only.

dreamorosi commented 3 years ago

Good point, Lambda Layers seems to reach a wider audience at the moment; we can re-evaluate in the future in case any Customer mentions it.

kimmoahokas commented 3 years ago

Is there any estimation if this will be implemented and when? We have been using third-party layer from https://github.com/keithrozario/Klayers but that is obviously not as good as having these officially published by AWS. As we are using terraform to deploy this without SAM, we can't use the layers from SAR or CloudFormation registry.

am29d commented 3 years ago

Hey @kimmoahokas thanks for the follow up, I am currently working on shipping this feature. I can't provide any dates, because there are still things out of my control or influence that might delay it. I can't wait to release it asap and make layers more accessable.

heitorlessa commented 3 years ago

Yes @kimmoahokas - @am29d is on it.

We've had some challenges on making this work flawlessly across all regions, hence the delay

Edit: Align with Alex's expectations

kimmoahokas commented 3 years ago

Thank you very much @am29d and @heitorlessa for the status update. We appreciate your effort on this and all of the lambda powertools :)

DanyC97 commented 3 years ago

@am29d @heitorlessa i suspect this can be closed now following the recent release?

am29d commented 3 years ago

@DanyC97 the public layer is only available for python. I guess we would need to remove the Java label, and can close this issue.

michaelbrewer commented 3 years ago

@heitorlessa can we mark this one as done?