diff --git a/docs/index.md b/docs/index.md index b79a2e7074f..7f58de4fe8a 100644 --- a/docs/index.md +++ b/docs/index.md @@ -36,7 +36,126 @@ Powertools is available in PyPi. You can use your favourite dependency managemen ### Lambda Layer -Powertools is also available as a Lambda Layer, and it is distributed via the [AWS Serverless Application Repository (SAR)](https://docs.aws.amazon.com/serverlessrepo/latest/devguide/what-is-serverlessrepo.html) to support semantic versioning. +Powertools is also available as a Lambda Layer with public ARNs in each region or distributed via the [AWS Serverless Application Repository (SAR)](https://docs.aws.amazon.com/serverlessrepo/latest/devguide/what-is-serverlessrepo.html) to support semantic versioning. + +#### Public ARNs + +We build, release and distribute packaged Lambda Powertools layers for each region. This means you can copy a specific ARN and use it in your Lambda deployment. The layer region must be equal to the region of your lambda function. The public layers do not contain the `pydantic` library that is required for the `parser` utility. + + +=== "SAM" + + ```yaml hl_lines="5" + MyLambdaFunction: + Type: AWS::Serverless::Function + Properties: + Layers: + - arn:aws:lambda:us-east-1:017000801446:layer:AWSLambdaPowertoolsPython:3 + ``` + +=== "Serverless framework" + + ```yaml hl_lines="5" + functions: + main: + handler: lambda_function.lambda_handler + layers: + - arn:aws:lambda:us-east-1:017000801446:layer:AWSLambdaPowertoolsPython:3 + ``` + +=== "CDK" + + ```python hl_lines="14" + from aws_cdk import core, aws_lambda + + class SampleApp(core.Construct): + + def __init__(self, scope: core.Construct, id_: str) -> None: + super().__init__(scope, id_) + + aws_lambda.Function(self, + 'sample-app-lambda', + runtime=aws_lambda.Runtime.PYTHON_3_8, + function_name='sample-lambda', + code=aws_lambda.Code.asset('./src'), + handler='app.handler', + layers: ["arn:aws:lambda:us-east-1:017000801446:layer:AWSLambdaPowertoolsPython:3"] + ) + ``` + +=== "Terraform" + + ```terraform hl_lines="9 38" + terraform { + required_version = "~> 1.0.5" + required_providers { + aws = "~> 3.50.0" + } + } + + provider "aws" { + region = "us-east-1" + } + + resource "aws_iam_role" "iam_for_lambda" { + name = "iam_for_lambda" + + assume_role_policy = < { +function copyToClipboard(e) { + e.preventDefault() + navigator.clipboard.writeText(e.target.textContent) + alert$.next("Copied to clipboard") +} + +function enableSearchOnBlurElement() { /* Register handler to log search on blur */ document.addEventListener("DOMContentLoaded", function () { recordPageView({ @@ -41,6 +47,18 @@ const attachListeners = () => { }; } +function enableClipboardElements() { + let copyElements = document.querySelectorAll('.copyMe'); + copyElements.forEach(element => { + element.addEventListener('click', copyToClipboard); + }) +} + +const attachListeners = () => { + enableSearchOnBlurElement() + enableClipboardElements() +} + const init = () => { Analytics.addPluggable(new KinesisFirehoseProvider()) Amplify.configure(awsconfig); diff --git a/docs/stylesheets/extra.css b/docs/stylesheets/extra.css index f24b32faa14..0d37af692cb 100644 --- a/docs/stylesheets/extra.css +++ b/docs/stylesheets/extra.css @@ -33,3 +33,8 @@ [data-md-color-scheme="slate"] { --md-typeset-a-color: rgb(28, 152, 152) } + +.copyMe { + cursor: pointer; + border-bottom: 0.1px dashed black; +} diff --git a/mkdocs.yml b/mkdocs.yml index b90ba4376de..fc51acb8b47 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -69,6 +69,7 @@ markdown_extensions: - attr_list - pymdownx.emoji - pymdownx.inlinehilite + - attr_list copyright: Copyright © 2021 Amazon Web Services