EventBridge
EventBridge event handler implementation.
Handler
Handles EventBridge events by calling an external API and persisting the response.
Source code in templates/eventbridge/handler.py
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | |
__init__(secret_manager, repository)
Initialize the Handler.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
secret_manager
|
SecretManager
|
Manager for AWS Secrets Manager. |
required |
repository
|
Repository
|
Repository for DynamoDB access. |
required |
Source code in templates/eventbridge/handler.py
35 36 37 38 39 40 41 42 43 | |
handle(event)
Process an EventBridge event.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event
|
EventBridgeModel
|
The parsed EventBridge event. |
required |
Returns:
| Type | Description |
|---|---|
ApiResponse
|
The validated API response. |
Source code in templates/eventbridge/handler.py
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | |
main(event, context)
Lambda entry point for the EventBridge handler.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event
|
EventBridgeModel
|
The EventBridge event. |
required |
context
|
LambdaContext
|
The Lambda execution context. |
required |
Source code in templates/eventbridge/handler.py
73 74 75 76 77 78 79 80 81 82 83 84 | |
Data models for the EventBridge template.
ApiResponse
Bases: Entity
Represents the response from the external API.
Source code in templates/eventbridge/models.py
8 9 10 11 | |
Secrets management for the EventBridge template.
SecretManager
Wrapper around SecretsProvider with configurable retries and caching.
Source code in templates/eventbridge/secrets.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | |
__init__(max_retries=3, max_age=60)
Initialize the SecretManager.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
max_retries
|
int
|
Maximum number of retry attempts for AWS service calls. |
3
|
max_age
|
int
|
Maximum age of the cached secret in seconds. |
60
|
Source code in templates/eventbridge/secrets.py
12 13 14 15 16 17 18 19 20 21 | |
get(name)
Retrieve a secret by name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The name of the secret to retrieve. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The secret value as a string. |
Source code in templates/eventbridge/secrets.py
23 24 25 26 27 28 29 30 31 32 | |
HTTP session management for the EventBridge template.
ApiSession
Manages a configured requests Session with retries and connection pooling.
Source code in templates/eventbridge/session.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | |
__init__(max_retries=3, backoff_factor=0.3, timeout=10, status_forcelist=None, pool_connections=10, pool_maxsize=10)
Initialize the ApiSession.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
max_retries
|
int
|
Maximum number of retries. |
3
|
backoff_factor
|
float
|
Backoff factor for retries. |
0.3
|
timeout
|
int
|
Preset timeout for requests in seconds. |
10
|
status_forcelist
|
list[int] | None
|
List of HTTP status codes to retry on. |
None
|
pool_connections
|
int
|
Number of connection pools to cache. |
10
|
pool_maxsize
|
int
|
Maximum number of connections to save in the pool. |
10
|
Source code in templates/eventbridge/session.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | |
get(url, **kwargs)
Perform a GET request with the preset timeout.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url
|
str
|
The URL to request. |
required |
**kwargs
|
Any
|
Additional arguments passed to the session.get call. |
{}
|
Returns:
| Type | Description |
|---|---|
Response
|
The Response object. |
Source code in templates/eventbridge/session.py
47 48 49 50 51 52 53 54 55 56 57 58 | |
Configuration settings for the EventBridge template.
Settings
Bases: CommonSettings
Configuration settings for the EventBridge template.
Source code in templates/eventbridge/settings.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | |