@@ -36,7 +36,126 @@ Powertools is available in PyPi. You can use your favourite dependency managemen
36
36
37
37
### Lambda Layer
38
38
39
- 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.
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.
44
+
45
+
46
+ === "SAM"
47
+
48
+ ```yaml hl_lines="5"
49
+ MyLambdaFunction:
50
+ Type: AWS::Serverless::Function
51
+ Properties:
52
+ Layers:
53
+ - arn:aws:lambda:us-east-1:017000801446:layer:AWSLambdaPowertoolsPython:3
54
+ ```
55
+
56
+ === "Serverless framework"
57
+
58
+ ```yaml hl_lines="5"
59
+ functions:
60
+ main:
61
+ handler: lambda_function.lambda_handler
62
+ layers:
63
+ - arn:aws:lambda:us-east-1:017000801446:layer:AWSLambdaPowertoolsPython:3
64
+ ```
65
+
66
+ === "CDK"
67
+
68
+ ```python hl_lines="14"
69
+ from aws_cdk import core, aws_lambda
70
+
71
+ class SampleApp(core.Construct):
72
+
73
+ def __init__(self, scope: core.Construct, id_: str) -> None:
74
+ super().__init__(scope, id_)
75
+
76
+ aws_lambda.Function(self,
77
+ 'sample-app-lambda',
78
+ runtime=aws_lambda.Runtime.PYTHON_3_8,
79
+ function_name='sample-lambda',
80
+ code=aws_lambda.Code.asset('./src'),
81
+ handler='app.handler',
82
+ layers: ["arn:aws:lambda:us-east-1:017000801446:layer:AWSLambdaPowertoolsPython:3"]
83
+ )
84
+ ```
85
+
86
+ === "Terraform"
87
+
88
+ ```terraform hl_lines="9 38"
89
+ terraform {
90
+ required_version = "~> 1.0.5"
91
+ required_providers {
92
+ aws = "~> 3.50.0"
93
+ }
94
+ }
95
+
96
+ provider "aws" {
97
+ region = "us-east-1"
98
+ }
99
+
100
+ resource "aws_iam_role" "iam_for_lambda" {
101
+ name = "iam_for_lambda"
102
+
103
+ assume_role_policy = <<EOF
104
+ {
105
+ "Version": "2012-10-17",
106
+ "Statement": [
107
+ {
108
+ "Action": "sts:AssumeRole",
109
+ "Principal": {
110
+ "Service": "lambda.amazonaws.com"
111
+ },
112
+ "Effect": "Allow",
113
+ "Sid": ""
114
+ }
115
+ ]
116
+ }
117
+ EOF
118
+ }
119
+
120
+ resource "aws_lambda_function" "test_lambda" {
121
+ filename = "lambda_function_payload.zip"
122
+ function_name = "lambda_function_name"
123
+ role = aws_iam_role.iam_for_lambda.arn
124
+ handler = "index.test"
125
+ runtime = "python3.8"
126
+ layers = ["arn:aws:lambda:us-east-1:017000801446:layer:AWSLambdaPowertoolsPython:3"]
127
+
128
+ source_code_hash = filebase64sha256("lambda_function_payload.zip")
129
+ }
130
+
131
+
132
+ ```
133
+
134
+ ??? note "Layer ARN per region"
135
+
136
+ !!! tip "Click to copy to clipboard"
137
+
138
+ | Region | Version | Layer ARN
139
+ |---------------------------| ---------------------------| ---------------------------
140
+ | `us-east-1` | `1.21.0` |[arn:aws:lambda:us-east-1:017000801446:layer:AWSLambdaPowertoolsPython:3](#) {: .copyMe}
141
+ | `us-east-2` | `1.21.0` |[arn:aws:lambda:us-east-2:017000801446:layer:AWSLambdaPowertoolsPython:3](#) {: .copyMe}
142
+ | `us-west-1` | `1.21.0` |[arn:aws:lambda:us-west-1:017000801446:layer:AWSLambdaPowertoolsPython:3](#) {: .copyMe}
143
+ | `us-west-2` | `1.21.0` |[arn:aws:lambda:us-west-2:017000801446:layer:AWSLambdaPowertoolsPython:3](#) {: .copyMe}
144
+ | `ap-south-1` | `1.21.0` |[arn:aws:lambda:ap-south-1:017000801446:layer:AWSLambdaPowertoolsPython:3](#) {: .copyMe}
145
+ | `ap-northeast-1` | `1.21.0` |[arn:aws:lambda:ap-northeast-1:017000801446:layer:AWSLambdaPowertoolsPython:3](#) {: .copyMe}
146
+ | `ap-northeast-2` | `1.21.0` |[arn:aws:lambda:ap-northeast-2:017000801446:layer:AWSLambdaPowertoolsPython:3](#) {: .copyMe}
147
+ | `ap-northeast-3` | `1.21.0` |[arn:aws:lambda:ap-northeast-3:017000801446:layer:AWSLambdaPowertoolsPython:3](#) {: .copyMe}
148
+ | `ap-southeast-1` | `1.21.0` |[arn:aws:lambda:ap-southeast-1:017000801446:layer:AWSLambdaPowertoolsPython:3](#) {: .copyMe}
149
+ | `ap-southeast-2` | `1.21.0` |[arn:aws:lambda:ap-southeast-2:017000801446:layer:AWSLambdaPowertoolsPython:3](#) {: .copyMe}
150
+ | `eu-central-1` | `1.21.0` |[arn:aws:lambda:eu-central-1:017000801446:layer:AWSLambdaPowertoolsPython:3](#) {: .copyMe}
151
+ | `eu-west-1` | `1.21.0` |[arn:aws:lambda:eu-west-1:017000801446:layer:AWSLambdaPowertoolsPython:3](#) {: .copyMe}
152
+ | `eu-west-2` | `1.21.0` |[arn:aws:lambda:eu-west-2:017000801446:layer:AWSLambdaPowertoolsPython:3](#) {: .copyMe}
153
+ | `eu-west-3` | `1.21.0` |[arn:aws:lambda:eu-west-3:017000801446:layer:AWSLambdaPowertoolsPython:3](#) {: .copyMe}
154
+ | `eu-north-1` | `1.21.0` |[arn:aws:lambda:eu-north-1:017000801446:layer:AWSLambdaPowertoolsPython:3](#) {: .copyMe}
155
+ | `ca-central-1` | `1.21.0` |[arn:aws:lambda:ca-central-1:017000801446:layer:AWSLambdaPowertoolsPython:3](#) {: .copyMe}
156
+ | `sa-east-1` | `1.21.0` |[arn:aws:lambda:sa-east-1:017000801446:layer:AWSLambdaPowertoolsPython:3](#) {: .copyMe}
157
+
158
+ #### SAR
40
159
41
160
| App | ARN | Description
42
161
|----------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------
0 commit comments