Skip to content

Commit a10df23

Browse files
committed
docs: use dynamic region and clipboard buttons
1 parent f71461c commit a10df23

File tree

1 file changed

+57
-50
lines changed

1 file changed

+57
-50
lines changed

docs/index.md

+57-50
Original file line numberDiff line numberDiff line change
@@ -21,27 +21,21 @@ This project separates core utilities that will be available in other runtimes v
2121

2222
## Install
2323

24-
Powertools is available in PyPi. You can use your favourite dependency management tool to install it
24+
Powertools is available in the following formats:
2525

26-
* [poetry](https://python-poetry.org/): `poetry add aws-lambda-powertools`
27-
* [pip](https://pip.pypa.io/en/latest/index.html): `pip install aws-lambda-powertools`
26+
??? info "Lambda Layer is a .zip file archive with Lambda Powertools pre-packaged in every AWS region. See what's inside!"
27+
Change {region} to your AWS region, e.g. `eu-west-1`
2828

29-
**Quick hello world example using SAM CLI**
29+
**`aws lambda get-layer-version-by-arn --arn arn:aws:lambda:{region}:017000801446:layer:AWSLambdaPowertoolsPython:3 --region {region}`**
3030

31-
=== "shell"
32-
33-
```bash
34-
sam init --location https://github.com/aws-samples/cookiecutter-aws-sam-python
35-
```
31+
* **Lambda Layer**: [**arn:aws:lambda:{region}:017000801446:layer:AWSLambdaPowertoolsPython:3**](#){: .copyMe} :clipboard:
32+
* **PyPi**: **`pip install aws-lambda-powertools`**
3633

3734
### Lambda Layer
3835

39-
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.
40-
41-
#### Public ARNs
42-
43-
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.
36+
Include Lambda Powertools in your function using the [AWS Lambda Console](https://console.aws.amazon.com/lambda){target="_blank"} or your preferred deployment framework.
4437

38+
!!! note "The public layers do not contain the `pydantic` library that is required for the `parser` utility; See [SAR](#sar) option instead."
4539

4640
=== "SAM"
4741

@@ -50,7 +44,7 @@ We build, release and distribute packaged Lambda Powertools layers for each regi
5044
Type: AWS::Serverless::Function
5145
Properties:
5246
Layers:
53-
- arn:aws:lambda:us-east-1:017000801446:layer:AWSLambdaPowertoolsPython:3
47+
- !Sub arn:aws:lambda:${AWS::Region}:017000801446:layer:AWSLambdaPowertoolsPython:3
5448
```
5549

5650
=== "Serverless framework"
@@ -60,7 +54,7 @@ We build, release and distribute packaged Lambda Powertools layers for each regi
6054
main:
6155
handler: lambda_function.lambda_handler
6256
layers:
63-
- arn:aws:lambda:us-east-1:017000801446:layer:AWSLambdaPowertoolsPython:3
57+
- arn:aws:lambda:${aws:region}:017000801446:layer:AWSLambdaPowertoolsPython:3
6458
```
6559

6660
=== "CDK"
@@ -70,16 +64,16 @@ We build, release and distribute packaged Lambda Powertools layers for each regi
7064

7165
class SampleApp(core.Construct):
7266

73-
def __init__(self, scope: core.Construct, id_: str) -> None:
67+
def __init__(self, scope: core.Construct, id_: str, env: core.Environment) -> None:
7468
super().__init__(scope, id_)
7569

7670
aws_lambda.Function(self,
7771
'sample-app-lambda',
78-
runtime=aws_lambda.Runtime.PYTHON_3_8,
72+
runtime=aws_lambda.Runtime.PYTHON_3_9,
7973
function_name='sample-lambda',
8074
code=aws_lambda.Code.asset('./src'),
8175
handler='app.handler',
82-
layers: ["arn:aws:lambda:us-east-1:017000801446:layer:AWSLambdaPowertoolsPython:3"]
76+
layers: [f"arn:aws:lambda:{env.region}:017000801446:layer:AWSLambdaPowertoolsPython:3"]
8377
)
8478
```
8579

@@ -94,7 +88,7 @@ We build, release and distribute packaged Lambda Powertools layers for each regi
9488
}
9589

9690
provider "aws" {
97-
region = "us-east-1"
91+
region = "{region}"
9892
}
9993

10094
resource "aws_iam_role" "iam_for_lambda" {
@@ -109,21 +103,20 @@ We build, release and distribute packaged Lambda Powertools layers for each regi
109103
"Principal": {
110104
"Service": "lambda.amazonaws.com"
111105
},
112-
"Effect": "Allow",
113-
"Sid": ""
106+
"Effect": "Allow"
114107
}
115108
]
116109
}
117110
EOF
118-
}
111+
}
119112

120113
resource "aws_lambda_function" "test_lambda" {
121114
filename = "lambda_function_payload.zip"
122115
function_name = "lambda_function_name"
123116
role = aws_iam_role.iam_for_lambda.arn
124117
handler = "index.test"
125-
runtime = "python3.8"
126-
layers = ["arn:aws:lambda:us-east-1:017000801446:layer:AWSLambdaPowertoolsPython:3"]
118+
runtime = "python3.9"
119+
layers = ["arn:aws:lambda:{region}:017000801446:layer:AWSLambdaPowertoolsPython:3"]
127120

128121
source_code_hash = filebase64sha256("lambda_function_payload.zip")
129122
}
@@ -157,40 +150,44 @@ We build, release and distribute packaged Lambda Powertools layers for each regi
157150
? Do you want to edit the local lambda function now? No
158151
```
159152

160-
??? note "Layer ARN per region"
161-
162-
!!! tip "Click to copy to clipboard"
153+
??? note "Expand to copy any regional Lambda Layer ARN"
163154

164155
| Region | Layer ARN
165156
|--------------------------- | ---------------------------
166-
| `us-east-1` | [arn:aws:lambda:us-east-1:017000801446:layer:AWSLambdaPowertoolsPython:3](#) {: .copyMe}
167-
| `us-east-2` | [arn:aws:lambda:us-east-2:017000801446:layer:AWSLambdaPowertoolsPython:3](#) {: .copyMe}
168-
| `us-west-1` | [arn:aws:lambda:us-west-1:017000801446:layer:AWSLambdaPowertoolsPython:3](#) {: .copyMe}
169-
| `us-west-2` | [arn:aws:lambda:us-west-2:017000801446:layer:AWSLambdaPowertoolsPython:3](#) {: .copyMe}
170-
| `ap-south-1` | [arn:aws:lambda:ap-south-1:017000801446:layer:AWSLambdaPowertoolsPython:3](#) {: .copyMe}
171-
| `ap-northeast-1` | [arn:aws:lambda:ap-northeast-1:017000801446:layer:AWSLambdaPowertoolsPython:3](#) {: .copyMe}
172-
| `ap-northeast-2` | [arn:aws:lambda:ap-northeast-2:017000801446:layer:AWSLambdaPowertoolsPython:3](#) {: .copyMe}
173-
| `ap-northeast-3` | [arn:aws:lambda:ap-northeast-3:017000801446:layer:AWSLambdaPowertoolsPython:3](#) {: .copyMe}
174-
| `ap-southeast-1` | [arn:aws:lambda:ap-southeast-1:017000801446:layer:AWSLambdaPowertoolsPython:3](#) {: .copyMe}
175-
| `ap-southeast-2` | [arn:aws:lambda:ap-southeast-2:017000801446:layer:AWSLambdaPowertoolsPython:3](#) {: .copyMe}
176-
| `eu-central-1` | [arn:aws:lambda:eu-central-1:017000801446:layer:AWSLambdaPowertoolsPython:3](#) {: .copyMe}
177-
| `eu-west-1` | [arn:aws:lambda:eu-west-1:017000801446:layer:AWSLambdaPowertoolsPython:3](#) {: .copyMe}
178-
| `eu-west-2` | [arn:aws:lambda:eu-west-2:017000801446:layer:AWSLambdaPowertoolsPython:3](#) {: .copyMe}
179-
| `eu-west-3` | [arn:aws:lambda:eu-west-3:017000801446:layer:AWSLambdaPowertoolsPython:3](#) {: .copyMe}
180-
| `eu-north-1` | [arn:aws:lambda:eu-north-1:017000801446:layer:AWSLambdaPowertoolsPython:3](#) {: .copyMe}
181-
| `ca-central-1` | [arn:aws:lambda:ca-central-1:017000801446:layer:AWSLambdaPowertoolsPython:3](#) {: .copyMe}
182-
| `sa-east-1` | [arn:aws:lambda:sa-east-1:017000801446:layer:AWSLambdaPowertoolsPython:3](#) {: .copyMe}
157+
| `us-east-1` | [arn:aws:lambda:us-east-1:017000801446:layer:AWSLambdaPowertoolsPython:3](#){: .copyMe} :clipboard:
158+
| `us-east-2` | [arn:aws:lambda:us-east-2:017000801446:layer:AWSLambdaPowertoolsPython:3](#){: .copyMe} :clipboard:
159+
| `us-west-1` | [arn:aws:lambda:us-west-1:017000801446:layer:AWSLambdaPowertoolsPython:3](#){: .copyMe} :clipboard:
160+
| `us-west-2` | [arn:aws:lambda:us-west-2:017000801446:layer:AWSLambdaPowertoolsPython:3](#){: .copyMe} :clipboard:
161+
| `ap-south-1` | [arn:aws:lambda:ap-south-1:017000801446:layer:AWSLambdaPowertoolsPython:3](#){: .copyMe} :clipboard:
162+
| `ap-northeast-1` | [arn:aws:lambda:ap-northeast-1:017000801446:layer:AWSLambdaPowertoolsPython:3](#){: .copyMe} :clipboard:
163+
| `ap-northeast-2` | [arn:aws:lambda:ap-northeast-2:017000801446:layer:AWSLambdaPowertoolsPython:3](#){: .copyMe} :clipboard:
164+
| `ap-northeast-3` | [arn:aws:lambda:ap-northeast-3:017000801446:layer:AWSLambdaPowertoolsPython:3](#){: .copyMe} :clipboard:
165+
| `ap-southeast-1` | [arn:aws:lambda:ap-southeast-1:017000801446:layer:AWSLambdaPowertoolsPython:3](#){: .copyMe} :clipboard:
166+
| `ap-southeast-2` | [arn:aws:lambda:ap-southeast-2:017000801446:layer:AWSLambdaPowertoolsPython:3](#){: .copyMe} :clipboard:
167+
| `eu-central-1` | [arn:aws:lambda:eu-central-1:017000801446:layer:AWSLambdaPowertoolsPython:3](#){: .copyMe} :clipboard:
168+
| `eu-west-1` | [arn:aws:lambda:eu-west-1:017000801446:layer:AWSLambdaPowertoolsPython:3](#){: .copyMe} :clipboard:
169+
| `eu-west-2` | [arn:aws:lambda:eu-west-2:017000801446:layer:AWSLambdaPowertoolsPython:3](#){: .copyMe} :clipboard:
170+
| `eu-west-3` | [arn:aws:lambda:eu-west-3:017000801446:layer:AWSLambdaPowertoolsPython:3](#){: .copyMe} :clipboard:
171+
| `eu-north-1` | [arn:aws:lambda:eu-north-1:017000801446:layer:AWSLambdaPowertoolsPython:3](#){: .copyMe} :clipboard:
172+
| `ca-central-1` | [arn:aws:lambda:ca-central-1:017000801446:layer:AWSLambdaPowertoolsPython:3](#){: .copyMe} :clipboard:
173+
| `sa-east-1` | [arn:aws:lambda:sa-east-1:017000801446:layer:AWSLambdaPowertoolsPython:3](#){: .copyMe} :clipboard:
183174

184175
#### SAR
185176

177+
Serverless Application Repository (SAR) App deploys a CloudFormation stack with a copy of our Lambda Layer in your AWS account and region.
178+
179+
Despite having more steps compared to the [public Layer ARN](#lambda-layer) option, the benefit is that you can specify a semantic version you want to use.
180+
186181
| App | ARN | Description
187182
|----------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------
188-
| [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 | Core dependencies only; sufficient for nearly all utilities.
189-
| [aws-lambda-powertools-python-layer-extras](https://serverlessrepo.aws.amazon.com/applications/eu-west-1/057560766410/aws-lambda-powertools-python-layer-extras) | arn:aws:serverlessrepo:eu-west-1:057560766410:applications/aws-lambda-powertools-python-layer-extras | Core plus extra dependencies such as `pydantic` that is required by `parser` utility.
183+
| [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](#){: .copyMe} :clipboard: | Core dependencies only; sufficient for nearly all utilities.
184+
| [aws-lambda-powertools-python-layer-extras](https://serverlessrepo.aws.amazon.com/applications/eu-west-1/057560766410/aws-lambda-powertools-python-layer-extras) | [arn:aws:serverlessrepo:eu-west-1:057560766410:applications/aws-lambda-powertools-python-layer-extras](#){: .copyMe} :clipboard: | Core plus extra dependencies such as `pydantic` that is required by `parser` utility.
190185

191186
!!! warning
192187
**Layer-extras** does not support Python 3.6 runtime. This layer also includes all extra dependencies: `22.4MB zipped`, `~155MB unzipped`.
193188

189+
!!! tip "You can create a shared Lambda Layers stack and make this along with other account level layers stack."
190+
194191
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.
195192

196193
=== "SAM"
@@ -201,7 +198,7 @@ If using SAM, you can include this SAR App as part of your shared Layers stack,
201198
Properties:
202199
Location:
203200
ApplicationId: arn:aws:serverlessrepo:eu-west-1:057560766410:applications/aws-lambda-powertools-python-layer
204-
SemanticVersion: 1.17.0 # change to latest semantic version available in SAR
201+
SemanticVersion: 1.21.1 # change to latest semantic version available in SAR
205202

206203
MyLambdaFunction:
207204
Type: AWS::Serverless::Function
@@ -229,7 +226,7 @@ If using SAM, you can include this SAR App as part of your shared Layers stack,
229226
Location:
230227
ApplicationId: arn:aws:serverlessrepo:eu-west-1:057560766410:applications/aws-lambda-powertools-python-layer
231228
# Find latest from github.com/awslabs/aws-lambda-powertools-python/releases
232-
SemanticVersion: 1.17.0
229+
SemanticVersion: 1.21.1
233230
```
234231

235232
=== "CDK"
@@ -239,7 +236,7 @@ If using SAM, you can include this SAR App as part of your shared Layers stack,
239236

240237
POWERTOOLS_BASE_NAME = 'AWSLambdaPowertools'
241238
# Find latest from github.com/awslabs/aws-lambda-powertools-python/releases
242-
POWERTOOLS_VER = '1.17.0'
239+
POWERTOOLS_VER = '1.21.1'
243240
POWERTOOLS_ARN = 'arn:aws:serverlessrepo:eu-west-1:057560766410:applications/aws-lambda-powertools-python-layer'
244241

245242
class SampleApp(core.Construct):
@@ -391,6 +388,16 @@ You can fetch available versions via SAR API with:
391388
--application-id arn:aws:serverlessrepo:eu-west-1:057560766410:applications/aws-lambda-powertools-python-layer
392389
```
393390

391+
## Quick getting started
392+
393+
**Quick hello world example using SAM CLI**
394+
395+
=== "shell"
396+
397+
```bash
398+
sam init --location https://github.com/aws-samples/cookiecutter-aws-sam-python
399+
```
400+
394401
## Features
395402

396403
| Utility | Description

0 commit comments

Comments
 (0)