Skip to content

Commit b1bf128

Browse files
author
Michael Brewer
committed
docs(index): Extract and fix sam templates
1 parent 4e00e14 commit b1bf128

File tree

12 files changed

+46
-35
lines changed

12 files changed

+46
-35
lines changed

Makefile

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,19 +93,16 @@ mypy:
9393

9494
format-examples:
9595
poetry run isort docs/examples
96-
poetry run black docs/examples/*.py
9796
poetry run black docs/examples/*/*.py
9897
poetry run black docs/examples/*/*/*.py
9998
poetry run black docs/examples/*/*/*/*.py
10099
poetry run black docs/examples/*/*/*/*/*.py
101100

102101
lint-examples:
103-
poetry run python3 -m py_compile docs/examples/*.py
104102
poetry run python3 -m py_compile docs/examples/*/*.py
105103
poetry run python3 -m py_compile docs/examples/*/*/*.py
106104
poetry run python3 -m py_compile docs/examples/*/*/*/*.py
107105
poetry run python3 -m py_compile docs/examples/*/*/*/*/*.py
108-
cfn-lint docs/examples/*.yml
109106
cfn-lint docs/examples/*/*.yml
110107
cfn-lint docs/examples/*/*/*.yml
111108
cfn-lint docs/examples/*/*/*/*.yml

docs/examples/core/event_handler/api_gateway/layout/template.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Resources:
2323
CodeUri: src
2424
Layers:
2525
# Latest version: https://awslabs.github.io/aws-lambda-powertools-python/latest/#lambda-layer
26-
- !Sub arn:aws:lambda:${AWS::Region}:017000801446:layer:AWSLambdaPowertoolsPython:11
26+
- !Sub arn:aws:lambda:${AWS::Region}:017000801446:layer:AWSLambdaPowertoolsPython:13
2727
Events:
2828
ByUser:
2929
Type: Api

docs/examples/core/event_handler/api_gateway/template.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Globals:
1313
- '*~1*' # converts to */* for any binary type
1414
Function:
1515
Timeout: 5
16-
Runtime: python3.8
16+
Runtime: python3.9
1717
Tracing: Active
1818
Environment:
1919
Variables:

docs/examples/core/event_handler/appsync/template.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Description: Hello world Direct Lambda Resolver
55
Globals:
66
Function:
77
Timeout: 5
8-
Runtime: python3.8
8+
Runtime: python3.9
99
Tracing: Active
1010
Environment:
1111
Variables:
File renamed without changes.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
AWSTemplateFormatVersion: '2010-09-09'
2+
Transform: AWS::Serverless-2016-10-31
3+
Resources:
4+
MyLambdaFunction:
5+
Type: AWS::Serverless::Function
6+
Properties:
7+
CodeUri: src
8+
Handler: app.lambda_handler
9+
Runtime: python3.9
10+
Layers:
11+
- !Sub arn:aws:lambda:${AWS::Region}:017000801446:layer:AWSLambdaPowertoolsPython:13

docs/examples/sar_cdk_app.py renamed to docs/examples/index/sar_cdk_app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
POWERTOOLS_BASE_NAME = "AWSLambdaPowertools"
66
# Find latest from github.com/awslabs/aws-lambda-powertools-python/releases
7-
POWERTOOLS_VER = "1.23.0"
7+
POWERTOOLS_VER = "1.25.3"
88
POWERTOOLS_ARN = "arn:aws:serverlessrepo:eu-west-1:057560766410:applications/aws-lambda-powertools-python-layer"
99

1010

docs/examples/sar_main.tf renamed to docs/examples/index/sar_main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ data "aws_serverlessapplicationrepository_application" "sar_app" {
2727

2828
variable "aws_powertools_version" {
2929
type = string
30-
default = "1.20.2"
30+
default = "1.25.3"
3131
description = "The AWS Powertools release version"
3232
}
3333

docs/examples/index/sar_template.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
AWSTemplateFormatVersion: '2010-09-09'
2+
Transform: AWS::Serverless-2016-10-31
3+
Resources:
4+
AwsLambdaPowertoolsPythonLayer:
5+
Type: AWS::Serverless::Application
6+
Properties:
7+
Location:
8+
ApplicationId: arn:aws:serverlessrepo:eu-west-1:057560766410:applications/aws-lambda-powertools-python-layer
9+
SemanticVersion: 1.25.3 # change to latest semantic version available in SAR
10+
11+
MyLambdaFunction:
12+
Type: AWS::Serverless::Function
13+
Properties:
14+
CodeUri: src
15+
Handler: app.lambda_handler
16+
Runtime: python3.9
17+
Layers:
18+
# fetch Layer ARN from SAR App stack output
19+
- !GetAtt AwsLambdaPowertoolsPythonLayer.Outputs.LayerVersionArn

docs/index.md

Lines changed: 11 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,8 @@ You can include Lambda Powertools Lambda Layer using [AWS Lambda Console](https:
5757

5858
=== "SAM"
5959

60-
```yaml hl_lines="5"
61-
MyLambdaFunction:
62-
Type: AWS::Serverless::Function
63-
Properties:
64-
Layers:
65-
- !Sub arn:aws:lambda:${AWS::Region}:017000801446:layer:AWSLambdaPowertoolsPython:13
60+
```yaml hl_lines="11"
61+
--8<-- "docs/examples/index/lambda_layer_template.yml"
6662
```
6763

6864
=== "Serverless framework"
@@ -78,13 +74,13 @@ You can include Lambda Powertools Lambda Layer using [AWS Lambda Console](https:
7874
=== "CDK"
7975

8076
```python hl_lines="11 16"
81-
--8<-- "docs/examples/cdk_app.py"
77+
--8<-- "docs/examples/index/lambda_layer_cdk_app.py"
8278
```
8379

8480
=== "Terraform"
8581

8682
```terraform hl_lines="9 35"
87-
--8<-- "docs/examples/main.tf"
83+
--8<-- "docs/examples/index/lambda_layer_main.tf"
8884
```
8985

9086
=== "Amplify"
@@ -149,20 +145,8 @@ If using SAM, you can include this SAR App as part of your shared Layers stack,
149145

150146
=== "SAM"
151147

152-
```yaml hl_lines="5-6 12-13"
153-
AwsLambdaPowertoolsPythonLayer:
154-
Type: AWS::Serverless::Application
155-
Properties:
156-
Location:
157-
ApplicationId: arn:aws:serverlessrepo:eu-west-1:057560766410:applications/aws-lambda-powertools-python-layer
158-
SemanticVersion: 1.24.1 # change to latest semantic version available in SAR
159-
160-
MyLambdaFunction:
161-
Type: AWS::Serverless::Function
162-
Properties:
163-
Layers:
164-
# fetch Layer ARN from SAR App stack output
165-
- !GetAtt AwsLambdaPowertoolsPythonLayer.Outputs.LayerVersionArn
148+
```yaml hl_lines="8-9 18-19"
149+
--8<-- "docs/examples/index/sar_template.yml"
166150
```
167151

168152
=== "Serverless framework"
@@ -183,21 +167,21 @@ If using SAM, you can include this SAR App as part of your shared Layers stack,
183167
Location:
184168
ApplicationId: arn:aws:serverlessrepo:eu-west-1:057560766410:applications/aws-lambda-powertools-python-layer
185169
# Find latest from github.com/awslabs/aws-lambda-powertools-python/releases
186-
SemanticVersion: 1.24.1
170+
SemanticVersion: 1.25.3
187171
```
188172

189173
=== "CDK"
190174

191-
```python hl_lines="16 22-25 34"
192-
--8<-- "docs/examples/sar_cdk_app.py"
175+
```python hl_lines="19 22-25 34"
176+
--8<-- "docs/examples/index/sar_cdk_app.py"
193177
```
194178

195179
=== "Terraform"
196180

197181
> Credits to [Dani Comnea](https://github.com/DanyC97) for providing the Terraform equivalent.
198182

199183
```terraform hl_lines="12-13 15-20 23-25 40"
200-
--8<-- "docs/examples/sar_main.tf"
184+
--8<-- "docs/examples/index/sar_main.tf"
201185
```
202186

203187
??? example "Example: Least-privileged IAM permissions to deploy Layer"
@@ -209,7 +193,7 @@ If using SAM, you can include this SAR App as part of your shared Layers stack,
209193
=== "template.yml"
210194

211195
```yaml hl_lines="21-52"
212-
--8<-- "docs/examples/least_priviledged_template.yml"
196+
--8<-- "docs/examples/index/least_priviledged_template.yml"
213197
```
214198

215199
You can fetch available versions via SAR ListApplicationVersions API:

0 commit comments

Comments
 (0)