Skip to content

Commit 0485d06

Browse files
committed
docs(lint): adjust markdownlint to our current conventions
1 parent 7f927aa commit 0485d06

17 files changed

+101
-122
lines changed

.markdownlint.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ MD006: true
3232
# MD007/ul-indent - Unordered list indentation
3333
MD007:
3434
# Spaces for indent
35-
indent: 2
35+
indent: 4
3636
# Whether to indent the first level of the list
3737
start_indented: false
3838
# Spaces for first level indent (when start_indented is set)
@@ -66,7 +66,7 @@ MD013:
6666
# Number of characters for headings
6767
heading_line_length: 80
6868
# Number of characters for code blocks
69-
code_block_line_length: 180
69+
code_block_line_length: 265
7070
# Include code blocks
7171
code_blocks: true
7272
# Include tables

docs/changelog.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
[comment]: <> (Includes Changelog content entire file as a snippet)
2+
<!-- changelog is partially generated, so it doesn't follow headings and required structure, so we disable it. -->
3+
<!-- markdownlint-disable -->
24
--8<-- "CHANGELOG.md"

docs/core/event_handler/api_gateway.md

+24-20
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,12 @@ Event handler for Amazon API Gateway REST and HTTP APIs, and Application Loader
1818

1919
### Required resources
2020

21-
You must have an existing [API Gateway Proxy integration](https://docs.aws.amazon.com/apigateway/latest/developerguide/set-up-lambda-proxy-integrations.html){target="_blank"} or [ALB](https://docs.aws.amazon.com/elasticloadbalancing/latest/application/lambda-functions.html){target="_blank"} configured to invoke your Lambda function. There is no additional permissions or dependencies required to use this utility.
21+
You must have an existing [API Gateway Proxy integration](https://docs.aws.amazon.com/apigateway/latest/developerguide/set-up-lambda-proxy-integrations.html){target="_blank"} or [ALB](https://docs.aws.amazon.com/elasticloadbalancing/latest/application/lambda-functions.html){target="_blank"} configured to invoke your Lambda function.
2222

2323
This is the sample infrastructure for API Gateway we are using for the examples in this documentation.
2424

25+
???+ info "There is no additional permissions or dependencies required to use this utility."
26+
2527
```yaml title="AWS Serverless Application Model (SAM) example"
2628
AWSTemplateFormatVersion: '2010-09-09'
2729
Transform: AWS::Serverless-2016-10-31
@@ -35,7 +37,7 @@ Globals:
3537
AllowHeaders: "'Content-Type,Authorization,X-Amz-Date'"
3638
MaxAge: "'300'"
3739
BinaryMediaTypes: # see Binary responses section
38-
- '*~1*' # converts to */* for any binary type
40+
- '*~1*' # converts to */* for any binary type
3941
Function:
4042
Timeout: 5
4143
Runtime: python3.8
@@ -59,8 +61,11 @@ Resources:
5961
ApiEvent:
6062
Type: Api
6163
Properties:
62-
Path: /{proxy+} # Send requests on any path to the lambda function
63-
Method: ANY # Send requests using any http method to the lambda function
64+
# NOTE: this is a catch-all rule to simply the documentation.
65+
# explicit routes and methods are recommended for prod instead
66+
# for example, Path: /hello, Method: GET
67+
Path: /{proxy+} # Send requests on any path to the lambda function
68+
Method: ANY # Send requests using any http method to the lambda function
6469
```
6570

6671
### Event Resolvers
@@ -355,7 +360,9 @@ You can also combine nested paths with greedy regex to catch in between routes.
355360
...
356361
}
357362
```
363+
358364
### HTTP Methods
365+
359366
You can use named decorators to specify the HTTP method that should be handled in your functions. As well as the
360367
`get` method already shown above, you can use `post`, `put`, `patch`, `delete`, and `patch`.
361368

@@ -487,7 +494,6 @@ def lambda_handler(event, context):
487494
return app.resolve(event, context)
488495
```
489496

490-
491497
### Handling not found routes
492498

493499
By default, we return `404` for any unmatched route.
@@ -528,7 +534,6 @@ def lambda_handler(event, context):
528534
return app.resolve(event, context)
529535
```
530536

531-
532537
### Exception handling
533538

534539
You can use **`exception_handler`** decorator with any Python exception. This allows you to handle a common exception outside your route, for example validation errors.
@@ -754,13 +759,13 @@ For convenience, these are the default values when using `CORSConfig` to enable
754759
???+ warning
755760
Always configure `allow_origin` when using in production.
756761

757-
Key | Value | Note
758-
------------------------------------------------- | --------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------
759-
**[allow_origin](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Origin){target="_blank"}**: `str` | `*` | Only use the default value for development. **Never use `*` for production** unless your use case requires it
760-
**[allow_headers](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Headers){target="_blank"}**: `List[str]` | `[Authorization, Content-Type, X-Amz-Date, X-Api-Key, X-Amz-Security-Token]` | Additional headers will be appended to the default list for your convenience
761-
**[expose_headers](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Expose-Headers){target="_blank"}**: `List[str]` | `[]` | Any additional header beyond the [safe listed by CORS specification](https://developer.mozilla.org/en-US/docs/Glossary/CORS-safelisted_response_header){target="_blank"}.
762-
**[max_age](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Max-Age){target="_blank"}**: `int` | `` | Only for pre-flight requests if you choose to have your function to handle it instead of API Gateway
763-
**[allow_credentials](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Credentials){target="_blank"}**: `bool` | `False` | Only necessary when you need to expose cookies, authorization headers or TLS client certificates.
762+
| Key | Value | Note |
763+
| -------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
764+
| **[allow_origin](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Origin){target="_blank"}**: `str` | `*` | Only use the default value for development. **Never use `*` for production** unless your use case requires it |
765+
| **[allow_headers](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Headers){target="_blank"}**: `List[str]` | `[Authorization, Content-Type, X-Amz-Date, X-Api-Key, X-Amz-Security-Token]` | Additional headers will be appended to the default list for your convenience |
766+
| **[expose_headers](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Expose-Headers){target="_blank"}**: `List[str]` | `[]` | Any additional header beyond the [safe listed by CORS specification](https://developer.mozilla.org/en-US/docs/Glossary/CORS-safelisted_response_header){target="_blank"}. |
767+
| **[max_age](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Max-Age){target="_blank"}**: `int` | `` | Only for pre-flight requests if you choose to have your function to handle it instead of API Gateway |
768+
| **[allow_credentials](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Credentials){target="_blank"}**: `bool` | `False` | Only necessary when you need to expose cookies, authorization headers or TLS client certificates. |
764769

765770
### Fine grained responses
766771

@@ -1132,7 +1137,6 @@ This sample project contains a Users function with two distinct set of routes, `
11321137

11331138
=== "Project layout"
11341139

1135-
11361140
```python hl_lines="1 8 10 12-15"
11371141
.
11381142
├── Pipfile # project app & dev dependencies; poetry, pipenv, etc.
@@ -1308,7 +1312,7 @@ _**Downsides**_
13081312

13091313
* **Cold starts**. Frequent deployments and/or high load can diminish the benefit of monolithic functions depending on your latency requirements, due to [Lambda scaling model](https://docs.aws.amazon.com/lambda/latest/dg/invocation-scaling.html){target="_blank"}. Always load test to pragmatically balance between your customer experience and development cognitive load.
13101314
* **Granular security permissions**. The micro function approach enables you to use fine-grained permissions & access controls, separate external dependencies & code signing at the function level. Conversely, you could have multiple functions while duplicating the final code artifact in a monolithic approach.
1311-
- Regardless, least privilege can be applied to either approaches.
1315+
* Regardless, least privilege can be applied to either approaches.
13121316
* **Higher risk per deployment**. A misconfiguration or invalid import can cause disruption if not caught earlier in automated testing. Multiple functions can mitigate misconfigurations but they would still share the same code artifact. You can further minimize risks with multiple environments in your CI/CD pipeline.
13131317

13141318
#### Micro function
@@ -1317,20 +1321,20 @@ _**Downsides**_
13171321

13181322
A micro function means that your final code artifact will be different to each function deployed. This is generally the approach to start if you're looking for fine-grain control and/or high load on certain parts of your service.
13191323

1320-
_**Benefits**_
1324+
**Benefits**
13211325

13221326
* **Granular scaling**. A micro function can benefit from the [Lambda scaling model](https://docs.aws.amazon.com/lambda/latest/dg/invocation-scaling.html){target="_blank"} to scale differently depending on each part of your application. Concurrency controls and provisioned concurrency can also be used at a granular level for capacity management.
13231327
* **Discoverability**. Micro functions are easier do visualize when using distributed tracing. Their high-level architectures can be self-explanatory, and complexity is highly visible — assuming each function is named to the business purpose it serves.
13241328
* **Package size**. An independent function can be significant smaller (KB vs MB) depending on external dependencies it require to perform its purpose. Conversely, a monolithic approach can benefit from [Lambda Layers](https://docs.aws.amazon.com/lambda/latest/dg/invocation-layers.html){target="_blank"} to optimize builds for external dependencies.
13251329

1326-
_**Downsides**_
1330+
**Downsides**
13271331

1328-
* **Upfront investment**. Python ecosystem doesn't use a bundler — you need a custom build tooling to ensure each function only has what it needs and account for [C bindings for runtime compatibility](https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html){target="_blank"}. Operations become more elaborate — you need to standardize tracing labels/annotations, structured logging, and metrics to pinpoint root causes.
1329-
- Engineering discipline is necessary for both approaches. Micro-function approach however requires further attention in consistency as the number of functions grow, just like any distributed system.
1332+
* **Upfront investment**. You need custom build tooling to bundle assets, including [C bindings for runtime compatibility](https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html){target="_blank"}. `Operations become more elaborate — you need to standardize tracing labels/annotations, structured logging, and metrics to pinpoint root causes.
1333+
* Engineering discipline is necessary for both approaches. Micro-function approach however requires further attention in consistency as the number of functions grow, just like any distributed system.
13301334
* **Harder to share code**. Shared code must be carefully evaluated to avoid unnecessary deployments when that changes. Equally, if shared code isn't a library,
13311335
your development, building, deployment tooling need to accommodate the distinct layout.
13321336
* **Slower safe deployments**. Safely deploying multiple functions require coordination — AWS CodeDeploy deploys and verifies each function sequentially. This increases lead time substantially (minutes to hours) depending on the deployment strategy you choose. You can mitigate it by selectively enabling it in prod-like environments only, and where the risk profile is applicable.
1333-
- Automated testing, operational and security reviews are essential to stability in either approaches.
1337+
* Automated testing, operational and security reviews are essential to stability in either approaches.
13341338

13351339
## Testing your code
13361340

docs/core/event_handler/appsync.md

-1
Original file line numberDiff line numberDiff line change
@@ -770,7 +770,6 @@ Let's assume you have `app.py` as your Lambda function entrypoint and routes in
770770
app.resolve(event, context)
771771
```
772772

773-
774773
## Testing your code
775774

776775
You can test your resolvers by passing a mocked or actual AppSync Lambda event that you're expecting.

docs/core/logger.md

-3
Original file line numberDiff line numberDiff line change
@@ -736,7 +736,6 @@ You might want to continue to use the same date formatting style, or override `l
736736

737737
Logger allows you to either change the format or suppress the following keys altogether at the initialization: `location`, `timestamp`, `level`, `xray_trace_id`.
738738

739-
740739
=== "lambda_handler.py"
741740
```python hl_lines="7 10"
742741
from aws_lambda_powertools import Logger
@@ -902,7 +901,6 @@ For exceptional cases where you want to completely replace our formatter logic,
902901
???+ warning
903902
You will need to implement `append_keys`, `clear_state`, override `format`, and optionally `remove_keys` to keep the same feature set Powertools Logger provides. This also means keeping state of logging keys added.
904903

905-
906904
=== "collect.py"
907905

908906
```python hl_lines="5 7 9-10 13 17 21 24 35"
@@ -1084,7 +1082,6 @@ def handler(event: Dict, context: LambdaContext) -> List:
10841082

10851083
You can copy the Logger setup to all or sub-sets of registered external loggers. Use the `copy_config_to_registered_logger` method to do this. By default all registered loggers will be modified. You can change this behaviour by providing `include` and `exclude` attributes. You can also provide optional `log_level` attribute external loggers will be configured with.
10861084

1087-
10881085
```python hl_lines="10" title="Cloning Logger config to all other registered standard loggers"
10891086
import logging
10901087

docs/core/metrics.md

-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ Metric has two global settings that will be used across all metrics emitted:
6666
metrics = Metrics(namespace="ServerlessAirline", service="orders") # Sets metric namespace, and service as a metric dimension
6767
```
6868

69-
7069
### Creating metrics
7170

7271
You can create metrics using `add_metric`, and you can create dimensions for all your aggregate metrics using `add_dimension` method.

docs/core/tracer.md

-2
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ def collect_payment(charge_id):
101101
The serialization is performed by aws-xray-sdk via `jsonpickle` module. This can cause
102102
side effects for file-like objects like boto S3 <a href="https://botocore.amazonaws.com/v1/documentation/api/latest/reference/response.html#botocore.response.StreamingBody">`StreamingBody`</a>, where its response will be read only once during serialization.
103103

104-
105104
### Asynchronous and generator functions
106105

107106
???+ warning
@@ -246,7 +245,6 @@ def handler(event, context):
246245
ec2_api_calls()
247246
```
248247

249-
250248
### Tracing aiohttp requests
251249

252250
???+ info

docs/index.md

+1-5
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ A suite of utilities for AWS Lambda functions to ease adopting best practices su
99

1010
Check out [this detailed blog post](https://aws.amazon.com/blogs/opensource/simplifying-serverless-best-practices-with-lambda-powertools/) with a practical example.
1111

12-
1312
## Install
1413

1514
Powertools is available in the following formats:
@@ -22,7 +21,6 @@ Powertools is available in the following formats:
2221

2322
When using Layers, you can add Lambda Powertools as a dev dependency (or as part of your virtual env) to not impact the development process.
2423

25-
2624
### Lambda Layer
2725

2826
[Lambda Layer](https://docs.aws.amazon.com/lambda/latest/dg/configuration-layers.html){target="_blank"} is a .zip file archive that can contain additional code, pre-packaged dependencies, data, or configuration files. Layers promote code sharing and separation of responsibilities so that you can iterate faster on writing business logic.
@@ -187,7 +185,6 @@ You can include Lambda Powertools Lambda Layer using [AWS Lambda Console](https:
187185

188186
Lambda Powertools Lambda Layer do not include `pydantic` library - required dependency for the `parser` utility. See [SAR](#sar) option instead.
189187

190-
191188
#### SAR
192189

193190
Serverless Application Repository (SAR) App deploys a CloudFormation stack with a copy of our Lambda Layer in your AWS account and region.
@@ -205,7 +202,6 @@ Despite having more steps compared to the [public Layer ARN](#lambda-layer) opti
205202
???+ tip
206203
You can create a shared Lambda Layers stack and make this along with other account level layers stack.
207204

208-
209205
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.
210206

211207
=== "SAM"
@@ -460,7 +456,7 @@ from aws_lambda_powertools.logging.logger import set_package_logger
460456
set_package_logger() # (1)
461457
```
462458

463-
1. :information_source: this will configure our `aws_lambda_powertools` logger with debug.
459+
1. :information_source: this will configure our `aws_lambda_powertools` logger with debug.
464460

465461
## Tenets
466462

0 commit comments

Comments
 (0)