Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions docs/template/agent.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,9 @@ Field | Type | Description

### Environment variables

Variable | Description
--- | ---
`TABLE_NAME` | DynamoDB table name
`SERVICE_NAME` | Powertools service name
`METRICS_NAMESPACE` | Powertools metrics namespace
Variable | Description | Required | Default
--- | --- | --- | ---
`TABLE_NAME` | DynamoDB table name | Yes | -
`SERVICE_NAME` | Powertools service name | No | `bedrock-agent`
`METRICS_NAMESPACE` | Powertools metrics namespace | No | `BedrockAgent`
`LOG_LEVEL` | Log level for the Lambda Logger | No | `INFO`
11 changes: 6 additions & 5 deletions docs/template/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ Field | Type | Description

### Environment variables

Variable | Description
--- | ---
`TABLE_NAME` | DynamoDB table name
`SERVICE_NAME` | Powertools service name
`METRICS_NAMESPACE` | Powertools metrics namespace
Variable | Description | Required | Default
--- | --- | --- | ---
`TABLE_NAME` | DynamoDB table name | Yes | -
`SERVICE_NAME` | Powertools service name | No | `rest-api`
`METRICS_NAMESPACE` | Powertools metrics namespace | No | `RestApi`
`LOG_LEVEL` | Log level for the Lambda Logger | No | `INFO`
15 changes: 8 additions & 7 deletions docs/template/eventbridge.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,11 @@ Field | Type | Description

### Environment variables

Variable | Description
--- | ---
`API_URL` | URL of the external HTTP API to call
`SECRET_NAME` | AWS Secrets Manager secret name holding the API token
`SERVICE_NAME` | Powertools service name
`METRICS_NAMESPACE` | CloudWatch metrics namespace
`TABLE_NAME` | DynamoDB table name for persisting API responses
Variable | Description | Required | Default
--- | --- | --- | ---
`API_URL` | URL of the external HTTP API to call | Yes | -
`TABLE_NAME` | DynamoDB table name for persisting API responses | Yes | -
`SECRET_NAME` | AWS Secrets Manager secret name holding the API token | Yes | -
`SERVICE_NAME` | Powertools service name | No | `eventbridge`
`METRICS_NAMESPACE` | CloudWatch metrics namespace | No | `EventBridge`
`LOG_LEVEL` | Log level for the Lambda Logger | No | `INFO`
9 changes: 9 additions & 0 deletions docs/template/graphql.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,12 @@ Field | Type | Description
--- | --- | ---
`id` | UUID string | Unique item identifier (auto-generated, 1-50 chars)
`name` | string | Human-readable item name (1-100 chars)

### Environment variables

Variable | Description | Required | Default
--- | --- | --- | ---
`TABLE_NAME` | DynamoDB table name | Yes | -
`SERVICE_NAME` | Powertools service name | No | `graphql-api`
`METRICS_NAMESPACE` | Powertools metrics namespace | No | `GraphQLApi`
`LOG_LEVEL` | Log level for the Lambda Logger | No | `INFO`
11 changes: 6 additions & 5 deletions docs/template/s3.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ Field | Type | Description

### Environment variables

Variable | Description
--- | ---
`SQS_QUEUE_URL` | SQS queue URL to publish processed messages to
`SERVICE_NAME` | Powertools service name
`LOG_LEVEL` | Log level for the Lambda Logger
Variable | Description | Required | Default
--- | --- | --- | ---
`SQS_QUEUE_URL` | SQS queue URL to publish processed messages to | Yes | -
`SERVICE_NAME` | Powertools service name | No | `s3-processor`
`METRICS_NAMESPACE` | CloudWatch Metrics namespace | No | `S3Processor`
`LOG_LEVEL` | Log level for the Lambda Logger | No | `INFO`
11 changes: 6 additions & 5 deletions docs/template/sqs.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@ Field | Type | Description

### Environment variables

Variable | Description
--- | ---
`TABLE_NAME` | Destination DynamoDB table name
`SERVICE_NAME` | Powertools service name
`METRICS_NAMESPACE` | Powertools metrics namespace
Variable | Description | Required | Default
--- | --- | --- | ---
`TABLE_NAME` | Destination DynamoDB table name | Yes | -
`SERVICE_NAME` | Powertools service name | No | `sqs-processor`
`METRICS_NAMESPACE` | Powertools metrics namespace | No | `SqsProcessor`
`LOG_LEVEL` | Log level for the Lambda Logger | No | `INFO`
13 changes: 7 additions & 6 deletions docs/template/stream.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,10 @@ Field | Type | Description

### Environment variables

Variable | Description
--- | ---
`SOURCE_TABLE_NAME` | Source DynamoDB table name (stream source)
`DESTINATION_TABLE_NAME` | Destination DynamoDB table name
`SERVICE_NAME` | Powertools service name
`METRICS_NAMESPACE` | Powertools metrics namespace
Variable | Description | Required | Default
--- | --- | --- | ---
`SOURCE_TABLE_NAME` | Source DynamoDB table name (stream source) | Yes | -
`DESTINATION_TABLE_NAME` | Destination DynamoDB table name | Yes | -
`SERVICE_NAME` | Powertools service name | No | `dynamodb-stream`
`METRICS_NAMESPACE` | Powertools metrics namespace | No | `DynamoDBStream`
`LOG_LEVEL` | Log level for the Lambda Logger | No | `INFO`
9 changes: 5 additions & 4 deletions templates/agent/settings.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
from pydantic import Field
from pydantic_settings import BaseSettings

from templates.settings import CommonSettings

class Settings(BaseSettings, case_sensitive=False):

class Settings(CommonSettings):
"""Configuration settings for the Bedrock Agent Lambda function."""

table_name: str = Field(description="Name of the DynamoDB table to store agent items.")
service_name: str = Field(description="Name of the service for logging and tracing.", default="bedrock-agent")
metrics_namespace: str = Field(description="Namespace for custom CloudWatch metrics.", default="BedrockAgent")
service_name: str = "bedrock-agent"
metrics_namespace: str = "BedrockAgent"
9 changes: 5 additions & 4 deletions templates/api/settings.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from pydantic import Field
from pydantic_settings import BaseSettings

from templates.settings import CommonSettings

class Settings(BaseSettings):

class Settings(CommonSettings):
table_name: str = Field(description="DynamoDB table name")
service_name: str = Field(description="Powertools service name")
metrics_namespace: str = Field(description="Powertools metrics namespace")
service_name: str = "rest-api"
metrics_namespace: str = "RestApi"
9 changes: 5 additions & 4 deletions templates/eventbridge/settings.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
from pydantic import Field
from pydantic_settings import BaseSettings

from templates.settings import CommonSettings

class Settings(BaseSettings, case_sensitive=False):

class Settings(CommonSettings):
api_url: str = Field(description="URL of the external HTTP API to call")
api_timeout_seconds: int = Field(description="Timeout for the external API call in seconds", default=10)
secret_name: str = Field(description="AWS Secrets Manager secret name holding the API token")
table_name: str = Field(description="DynamoDB table name for persisting API responses")
service_name: str = Field(description="Powertools service name used for Logger and Tracer")
metrics_namespace: str = Field(description="CloudWatch namespace for Powertools Metrics")
service_name: str = "eventbridge"
metrics_namespace: str = "EventBridge"
9 changes: 5 additions & 4 deletions templates/graphql/settings.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
from pydantic import Field
from pydantic_settings import BaseSettings

from templates.settings import CommonSettings

class Settings(BaseSettings):

class Settings(CommonSettings):
"""Configuration settings for the GraphQL Lambda function."""

table_name: str = Field(description="The name of the DynamoDB table.")
service_name: str = Field(description="The name of the service.", default="graphql-api")
metrics_namespace: str = Field(description="The CloudWatch Metrics namespace.", default="GraphQLApi")
service_name: str = "graphql-api"
metrics_namespace: str = "GraphQLApi"
12 changes: 5 additions & 7 deletions templates/s3/settings.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
from typing import Optional

from pydantic import Field, field_validator
from pydantic_settings import BaseSettings

from templates.settings import CommonSettings


class Settings(BaseSettings, case_sensitive=False):
class Settings(CommonSettings):
queue_url: str = Field(description="SQS queue URL to publish processed messages to")
queue_region: str = Field(default="us-east-1", description="AWS region for the SQS client")
service_name: Optional[str] = Field(default="s3-processor", description="Powertools service name")
metrics_namespace: Optional[str] = Field(default="S3Processor", description="CloudWatch Metrics namespace")
log_level: str = Field(default="INFO", description="Log level for the Lambda Logger")
service_name: str = "s3-processor"
metrics_namespace: str = "S3Processor"

@field_validator("queue_url")
@classmethod
Expand Down
10 changes: 10 additions & 0 deletions templates/settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from pydantic import Field
from pydantic_settings import BaseSettings


class CommonSettings(BaseSettings):
"""Common settings shared by all Lambda functions."""

service_name: str = Field(description="Powertools service name")
metrics_namespace: str = Field(description="Powertools metrics namespace")
log_level: str = Field(description="Logging level", default="INFO")
9 changes: 5 additions & 4 deletions templates/sqs/settings.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
from pydantic import Field
from pydantic_settings import BaseSettings

from templates.settings import CommonSettings

class Settings(BaseSettings, case_sensitive=False):

class Settings(CommonSettings):
"""Configuration settings for the SQS Lambda function."""

table_name: str = Field(description="Name of the DynamoDB table to store processed items.")
service_name: str = Field(description="Name of the service for logging and tracing.", default="sqs-processor")
metrics_namespace: str = Field(description="Namespace for custom CloudWatch metrics.", default="SqsProcessor")
service_name: str = "sqs-processor"
metrics_namespace: str = "SqsProcessor"
9 changes: 5 additions & 4 deletions templates/stream/settings.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from pydantic import Field
from pydantic_settings import BaseSettings

from templates.settings import CommonSettings

class Settings(BaseSettings, case_sensitive=False):

class Settings(CommonSettings):
destination_table_name: str = Field(description="Destination DynamoDB table name")
service_name: str = Field(description="Powertools service name")
metrics_namespace: str = Field(description="Powertools metrics namespace")
service_name: str = "dynamodb-stream"
metrics_namespace: str = "DynamoDBStream"
2 changes: 1 addition & 1 deletion tests/eventbridge/test_properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ def test_api_failure_propagates(mocker, status_code) -> None:


# Feature: eventbridge-api-caller, Property 7: Missing required env var raises ValidationError
@given(var_name=st.sampled_from(["API_URL", "SECRET_NAME", "SERVICE_NAME", "METRICS_NAMESPACE", "TABLE_NAME"]))
@given(var_name=st.sampled_from(["API_URL", "SECRET_NAME", "TABLE_NAME"]))
@h_settings(max_examples=100, suppress_health_check=[HealthCheck.function_scoped_fixture])
def test_missing_env_var_raises(monkeypatch, var_name) -> None:
from pydantic import ValidationError
Expand Down