Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add workflow to trigger external pipeline for publishing lambda layers #129

Merged
merged 14 commits into from
Aug 25, 2020
Merged

Conversation

am29d
Copy link
Contributor

@am29d am29d commented Aug 23, 2020

Issue # , if available: #25

Description of changes:

Add workflow to publish latest release to Serverless Application Repository. This workflow will pass the release version parameter to ssm and start the pipeline within an internal AWS account. The GitHub secrets will be added separately. The code pipeline will package and publish the layer under the name aws-lambda-powertools-python-layer.

I would like to add documentation where to find the layer in SAR, how to find the right version, deploy and use it, but I am not sure to where to put the content. Docs, README.md or a dedicated .md file with a link in README.md?

Checklist

Breaking change checklist

RFC issue #:

  • Migration process documented
  • Implement warnings (if it can live side by side)

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@am29d am29d added the feature-request feature request label Aug 23, 2020
@am29d am29d changed the title Feat/lambda layers feat: add workflow to trigger external pipeline for publishing lambda layers Aug 23, 2020
@codecov-commenter
Copy link

codecov-commenter commented Aug 23, 2020

Codecov Report

Merging #129 into develop will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##           develop      #129   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           24        24           
  Lines          706       706           
  Branches        66        66           
=========================================
  Hits           706       706           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 96b7b8f...607904c. Read the comment docs.

@heitorlessa heitorlessa added enhancement and removed feature-request feature request labels Aug 23, 2020
@heitorlessa
Copy link
Contributor

This is awesome - Thanks for doing that ;)

As to the docs, you can add that in the homepage under Installation: https://github.com/awslabs/aws-lambda-powertools-python/blob/develop/docs/content/index.mdx

Create a sub-heading called Lambda Layer to give customers a dedicated heading to link to, and space to expand instructions you may need.

@am29d am29d requested a review from heitorlessa August 25, 2020 11:47
Comment on lines +64 to +75
Create the layer via API with:

```bash:title=bash-script
aws serverlessrepo create-cloud-formation-change-set --application-id arn:aws:serverlessrepo:eu-west-1:057560766410:applications/aws-lambda-powertools-python-layer --stack-name YOUR_STACK_NAME --capabilities CAPABILITY_NAMED_IAM
CHANGE_SET_ID=$(aws cloudformation list-change-sets --stack-name YOUR_STACK_NAME --query 'Summaries[*].ChangeSetId' --output text)
aws cloudformation wait change-set-create-complete --change-set-name $CHANGE_SET_ID
aws cloudformation execute-change-set --change-set-name $CHANGE_SET_ID
```

this will create a CloudFormation stack with the powertools layer in a specific region where you run this commands.
Keep in mind that layers are regional resources and you need to create the layer in every region where you need it.
Alternatively, you can deploy the layer from the AWS Console by navigating to Serverless Application Repository and search for `aws-lambda-powertools-python-layer` and follow the deploy steps from there.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Create the layer via API with:
```bash:title=bash-script
aws serverlessrepo create-cloud-formation-change-set --application-id arn:aws:serverlessrepo:eu-west-1:057560766410:applications/aws-lambda-powertools-python-layer --stack-name YOUR_STACK_NAME --capabilities CAPABILITY_NAMED_IAM
CHANGE_SET_ID=$(aws cloudformation list-change-sets --stack-name YOUR_STACK_NAME --query 'Summaries[*].ChangeSetId' --output text)
aws cloudformation wait change-set-create-complete --change-set-name $CHANGE_SET_ID
aws cloudformation execute-change-set --change-set-name $CHANGE_SET_ID
```
this will create a CloudFormation stack with the powertools layer in a specific region where you run this commands.
Keep in mind that layers are regional resources and you need to create the layer in every region where you need it.
Alternatively, you can deploy the layer from the AWS Console by navigating to Serverless Application Repository and search for `aws-lambda-powertools-python-layer` and follow the deploy steps from there.
SAR App | ARN
------------------------------------------------- | ---------------------------------------------------------------------------------
[aws-lambda-powertools-python-layer](https://serverlessrepo.aws.amazon.com/applications/eu-west-1/057560766410/aws-lambda-powertools-python-layer) | arn:aws:serverlessrepo:eu-west-1:057560766410:applications/aws-lambda-powertools-python-layer
If using SAM, you can include this SAR App as part of your shared Layers stack, and lock to a specific semantic version. Once deployed, it'll be available across the account this is deployed to.
```yaml
AwsLambdaPowertoolsPythonLayer:
Type: AWS::Serverless::Application
Properties:
Location:
ApplicationId: arn:aws:serverlessrepo:eu-west-1:057560766410:applications/aws-lambda-powertools-python-layer
SemanticVersion: 1.3.0 # change to latest semantic version available in SAR

Customers typically use SAR within their SAM stack, or the Console, but rarely using the CLI as it's quite a lot of steps. Added a table as well as a snippet of this SAR App

@@ -58,6 +58,22 @@ from aws_lambda_powertools.logging.logger import set_package_logger
set_package_logger()
```

## Lambda Layer

Powertools is also available as a layer and is distributed via the [Serverless Application Repository](https://docs.aws.amazon.com/serverlessrepo/latest/devguide/what-is-serverlessrepo.html).
Copy link
Contributor

@heitorlessa heitorlessa Aug 25, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Powertools is also available as a layer and is distributed via the [Serverless Application Repository](https://docs.aws.amazon.com/serverlessrepo/latest/devguide/what-is-serverlessrepo.html).
Powertools is also available as a Lambda Layer. It is distributed via the [AWS Serverless Application Repository (SAR)](https://docs.aws.amazon.com/serverlessrepo/latest/devguide/what-is-serverlessrepo.html).

Copy link
Contributor

@heitorlessa heitorlessa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simplified the installation part, and a suggested a fix

@heitorlessa
Copy link
Contributor

I seem to not have access to commit these changes while Alex is off... I'm merging as-is, and will submit the changes in a separate commit to develop branch directly

@heitorlessa heitorlessa merged commit 50ad7de into aws-powertools:develop Aug 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants