nui-lambda-shared-utils 1.0.3__tar.gz → 1.1.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- nui_lambda_shared_utils-1.1.1/.markdownlint-cli2.yaml +47 -0
- {nui_lambda_shared_utils-1.0.3 → nui_lambda_shared_utils-1.1.1}/CLAUDE.md +117 -7
- {nui_lambda_shared_utils-1.0.3 → nui_lambda_shared_utils-1.1.1}/CONTRIBUTING.md +11 -2
- {nui_lambda_shared_utils-1.0.3 → nui_lambda_shared_utils-1.1.1}/PKG-INFO +83 -4
- {nui_lambda_shared_utils-1.0.3 → nui_lambda_shared_utils-1.1.1}/README.md +77 -3
- {nui_lambda_shared_utils-1.0.3 → nui_lambda_shared_utils-1.1.1}/docs/README.md +34 -5
- {nui_lambda_shared_utils-1.0.3 → nui_lambda_shared_utils-1.1.1}/docs/development/testing.md +12 -0
- {nui_lambda_shared_utils-1.0.3 → nui_lambda_shared_utils-1.1.1}/docs/getting-started/configuration.md +3 -13
- {nui_lambda_shared_utils-1.0.3 → nui_lambda_shared_utils-1.1.1}/docs/getting-started/installation.md +10 -1
- {nui_lambda_shared_utils-1.0.3 → nui_lambda_shared_utils-1.1.1}/docs/getting-started/quickstart.md +66 -1
- nui_lambda_shared_utils-1.1.1/docs/guides/cli-tools.md +270 -0
- nui_lambda_shared_utils-1.1.1/docs/guides/powertools-integration.md +593 -0
- {nui_lambda_shared_utils-1.0.3 → nui_lambda_shared_utils-1.1.1}/docs/guides/slack-integration.md +6 -0
- {nui_lambda_shared_utils-1.0.3 → nui_lambda_shared_utils-1.1.1}/nui_lambda_shared_utils/__init__.py +9 -2
- nui_lambda_shared_utils-1.1.1/nui_lambda_shared_utils/cli.py +225 -0
- {nui_lambda_shared_utils-1.0.3 → nui_lambda_shared_utils-1.1.1}/nui_lambda_shared_utils/db_client.py +2 -107
- nui_lambda_shared_utils-1.1.1/nui_lambda_shared_utils/powertools_helpers.py +240 -0
- {nui_lambda_shared_utils-1.0.3 → nui_lambda_shared_utils-1.1.1}/nui_lambda_shared_utils/slack_client.py +27 -13
- {nui_lambda_shared_utils-1.0.3 → nui_lambda_shared_utils-1.1.1}/nui_lambda_shared_utils/slack_formatter.py +3 -21
- {nui_lambda_shared_utils-1.0.3 → nui_lambda_shared_utils-1.1.1}/nui_lambda_shared_utils/slack_setup/__init__.py +1 -1
- {nui_lambda_shared_utils-1.0.3 → nui_lambda_shared_utils-1.1.1}/nui_lambda_shared_utils/slack_setup/channel_creator.py +1 -1
- {nui_lambda_shared_utils-1.0.3 → nui_lambda_shared_utils-1.1.1}/nui_lambda_shared_utils/slack_setup/channel_definitions.py +1 -1
- {nui_lambda_shared_utils-1.0.3 → nui_lambda_shared_utils-1.1.1}/nui_lambda_shared_utils/slack_setup/setup_helpers.py +4 -4
- {nui_lambda_shared_utils-1.0.3 → nui_lambda_shared_utils-1.1.1}/nui_lambda_shared_utils.egg-info/SOURCES.txt +6 -1
- {nui_lambda_shared_utils-1.0.3 → nui_lambda_shared_utils-1.1.1}/pyproject.toml +8 -2
- {nui_lambda_shared_utils-1.0.3 → nui_lambda_shared_utils-1.1.1}/tests/test_db_client.py +0 -79
- nui_lambda_shared_utils-1.1.1/tests/test_powertools_helpers.py +371 -0
- {nui_lambda_shared_utils-1.0.3 → nui_lambda_shared_utils-1.1.1}/tests/test_slack_formatter.py +6 -19
- nui_lambda_shared_utils-1.0.3/nui_lambda_shared_utils/slack_setup_cli.py +0 -194
- {nui_lambda_shared_utils-1.0.3 → nui_lambda_shared_utils-1.1.1}/.editorconfig +0 -0
- {nui_lambda_shared_utils-1.0.3 → nui_lambda_shared_utils-1.1.1}/.github/workflows/ci.yml +0 -0
- {nui_lambda_shared_utils-1.0.3 → nui_lambda_shared_utils-1.1.1}/.github/workflows/publish.yml +0 -0
- {nui_lambda_shared_utils-1.0.3 → nui_lambda_shared_utils-1.1.1}/.github/workflows/test.yml +0 -0
- {nui_lambda_shared_utils-1.0.3 → nui_lambda_shared_utils-1.1.1}/LICENSE +0 -0
- {nui_lambda_shared_utils-1.0.3 → nui_lambda_shared_utils-1.1.1}/MANIFEST.in +0 -0
- {nui_lambda_shared_utils-1.0.3 → nui_lambda_shared_utils-1.1.1}/mypy.ini +0 -0
- {nui_lambda_shared_utils-1.0.3 → nui_lambda_shared_utils-1.1.1}/nui_lambda_shared_utils/base_client.py +0 -0
- {nui_lambda_shared_utils-1.0.3 → nui_lambda_shared_utils-1.1.1}/nui_lambda_shared_utils/cloudwatch_metrics.py +0 -0
- {nui_lambda_shared_utils-1.0.3 → nui_lambda_shared_utils-1.1.1}/nui_lambda_shared_utils/config.py +0 -0
- {nui_lambda_shared_utils-1.0.3 → nui_lambda_shared_utils-1.1.1}/nui_lambda_shared_utils/error_handler.py +0 -0
- {nui_lambda_shared_utils-1.0.3 → nui_lambda_shared_utils-1.1.1}/nui_lambda_shared_utils/es_client.py +0 -0
- {nui_lambda_shared_utils-1.0.3 → nui_lambda_shared_utils-1.1.1}/nui_lambda_shared_utils/es_query_builder.py +0 -0
- {nui_lambda_shared_utils-1.0.3 → nui_lambda_shared_utils-1.1.1}/nui_lambda_shared_utils/secrets_helper.py +0 -0
- {nui_lambda_shared_utils-1.0.3 → nui_lambda_shared_utils-1.1.1}/nui_lambda_shared_utils/timezone.py +0 -0
- {nui_lambda_shared_utils-1.0.3 → nui_lambda_shared_utils-1.1.1}/nui_lambda_shared_utils/utils.py +0 -0
- {nui_lambda_shared_utils-1.0.3 → nui_lambda_shared_utils-1.1.1}/pytest.ini +0 -0
- {nui_lambda_shared_utils-1.0.3 → nui_lambda_shared_utils-1.1.1}/requirements-test.txt +0 -0
- {nui_lambda_shared_utils-1.0.3 → nui_lambda_shared_utils-1.1.1}/setup.cfg +0 -0
- {nui_lambda_shared_utils-1.0.3 → nui_lambda_shared_utils-1.1.1}/setup.py +0 -0
- {nui_lambda_shared_utils-1.0.3 → nui_lambda_shared_utils-1.1.1}/tests/__init__.py +0 -0
- {nui_lambda_shared_utils-1.0.3 → nui_lambda_shared_utils-1.1.1}/tests/test_aws_utils.py +0 -0
- {nui_lambda_shared_utils-1.0.3 → nui_lambda_shared_utils-1.1.1}/tests/test_base_client.py +0 -0
- {nui_lambda_shared_utils-1.0.3 → nui_lambda_shared_utils-1.1.1}/tests/test_cloudwatch_metrics.py +0 -0
- {nui_lambda_shared_utils-1.0.3 → nui_lambda_shared_utils-1.1.1}/tests/test_config.py +0 -0
- {nui_lambda_shared_utils-1.0.3 → nui_lambda_shared_utils-1.1.1}/tests/test_error_handler.py +0 -0
- {nui_lambda_shared_utils-1.0.3 → nui_lambda_shared_utils-1.1.1}/tests/test_es_client.py +0 -0
- {nui_lambda_shared_utils-1.0.3 → nui_lambda_shared_utils-1.1.1}/tests/test_es_query_builder.py +0 -0
- {nui_lambda_shared_utils-1.0.3 → nui_lambda_shared_utils-1.1.1}/tests/test_secrets_helper.py +0 -0
- {nui_lambda_shared_utils-1.0.3 → nui_lambda_shared_utils-1.1.1}/tests/test_slack_client.py +0 -0
- {nui_lambda_shared_utils-1.0.3 → nui_lambda_shared_utils-1.1.1}/tests/test_timezone.py +0 -0
- {nui_lambda_shared_utils-1.0.3 → nui_lambda_shared_utils-1.1.1}/tests/test_utils.py +0 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# Markdownlint configuration for nui-lambda-shared-utils
|
|
2
|
+
# Extends workspace config with project-specific overrides
|
|
3
|
+
|
|
4
|
+
config:
|
|
5
|
+
# Enable all rules by default
|
|
6
|
+
default: true
|
|
7
|
+
|
|
8
|
+
# MD013: Line length - disabled (technical docs need long lines for URLs/commands)
|
|
9
|
+
MD013: false
|
|
10
|
+
|
|
11
|
+
# MD033: Inline HTML - allowed (needed for complex formatting)
|
|
12
|
+
MD033: false
|
|
13
|
+
|
|
14
|
+
# MD036: No emphasis as heading - disabled (acceptable in planning docs)
|
|
15
|
+
MD036: false
|
|
16
|
+
|
|
17
|
+
# MD040: Fenced code language - disabled (not all code blocks need language tags)
|
|
18
|
+
MD040: false
|
|
19
|
+
|
|
20
|
+
# MD041: First line heading - disabled (docs may start with metadata)
|
|
21
|
+
MD041: false
|
|
22
|
+
|
|
23
|
+
# MD024: Multiple headings with same content - allowed with different levels
|
|
24
|
+
MD024:
|
|
25
|
+
siblings_only: true
|
|
26
|
+
|
|
27
|
+
# MD034: Bare URLs - allowed (sometimes intentional)
|
|
28
|
+
MD034: false
|
|
29
|
+
|
|
30
|
+
# MD046: Code block style - prefer fenced
|
|
31
|
+
MD046:
|
|
32
|
+
style: "fenced"
|
|
33
|
+
|
|
34
|
+
# MD060: Table column style - disabled (minor formatting preference)
|
|
35
|
+
MD060: false
|
|
36
|
+
|
|
37
|
+
# File patterns to check
|
|
38
|
+
globs:
|
|
39
|
+
- "**/*.md"
|
|
40
|
+
|
|
41
|
+
# Exclusions
|
|
42
|
+
ignores:
|
|
43
|
+
- "node_modules/**"
|
|
44
|
+
- "vendor/**"
|
|
45
|
+
- ".git/**"
|
|
46
|
+
- "venv/**"
|
|
47
|
+
- ".venv/**"
|
|
@@ -5,6 +5,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
|
|
|
5
5
|
## Quick Links
|
|
6
6
|
|
|
7
7
|
📚 **Documentation**: See [docs/README.md](docs/README.md) for comprehensive guides
|
|
8
|
+
|
|
8
9
|
- [Quick Start Guide](docs/getting-started/quickstart.md) - Usage patterns and examples
|
|
9
10
|
- [Configuration Guide](docs/getting-started/configuration.md) - Environment setup and credentials
|
|
10
11
|
- [Slack Integration](docs/guides/slack-integration.md) - Messaging, formatting, and file uploads
|
|
@@ -15,6 +16,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
|
|
|
15
16
|
## Navigation Guide
|
|
16
17
|
|
|
17
18
|
**Are you...**
|
|
19
|
+
|
|
18
20
|
- 🆕 **New to this package?** → Start with [docs/getting-started/quickstart.md](docs/getting-started/quickstart.md)
|
|
19
21
|
- 🔧 **Contributing code?** → See [Development Commands](#development-commands) below
|
|
20
22
|
- 🧪 **Writing tests?** → See [docs/development/testing.md](docs/development/testing.md)
|
|
@@ -23,11 +25,12 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
|
|
|
23
25
|
|
|
24
26
|
## Project Overview
|
|
25
27
|
|
|
26
|
-
This is `nui-lambda-shared-utils`, a Python package providing
|
|
28
|
+
This is `nui-lambda-shared-utils`, a Python package providing production-ready utilities for AWS Lambda functions. Built and battle-tested on the NUI platform, it offers standardized integrations for Slack, Elasticsearch, database operations, CloudWatch metrics, and error handling patterns. The package is designed to be generic and configurable for any AWS Lambda environment.
|
|
27
29
|
|
|
28
30
|
## Architecture
|
|
29
31
|
|
|
30
32
|
### Core Module Structure
|
|
33
|
+
|
|
31
34
|
- **Configuration System** (`config.py`) - Environment-aware configuration with AWS Secrets Manager integration
|
|
32
35
|
- **Secrets Management** (`secrets_helper.py`) - Centralized credential handling with caching
|
|
33
36
|
- **Slack Integration** (`slack_client.py`, `slack_formatter.py`) - Rich messaging, threading, and file uploads
|
|
@@ -35,25 +38,74 @@ This is `nui-lambda-shared-utils`, a Python package providing enterprise-grade u
|
|
|
35
38
|
- **Database** (`db_client.py`) - Connection pooling with retry logic
|
|
36
39
|
- **Metrics** (`cloudwatch_metrics.py`) - Batched CloudWatch publishing with decorators
|
|
37
40
|
- **Error Handling** (`error_handler.py`) - Retry patterns with exponential backoff
|
|
38
|
-
- **Timezone Utils** (`timezone.py`) -
|
|
41
|
+
- **Timezone Utils** (`timezone.py`) - Timezone conversion and formatting utilities
|
|
39
42
|
|
|
40
43
|
### Optional Dependencies
|
|
44
|
+
|
|
41
45
|
The package uses optional extras to minimize Lambda bundle size:
|
|
46
|
+
|
|
42
47
|
- `elasticsearch` - Elasticsearch client and query builders
|
|
43
48
|
- `database` - MySQL/PostgreSQL drivers
|
|
44
49
|
- `slack` - Slack SDK
|
|
45
50
|
- `all` - All integrations
|
|
46
51
|
- `dev` - Development and testing tools
|
|
47
52
|
|
|
48
|
-
### Slack
|
|
53
|
+
### Slack Workspace Automation
|
|
54
|
+
|
|
49
55
|
The `slack_setup/` submodule provides automated Slack workspace configuration:
|
|
56
|
+
|
|
50
57
|
- **Channel Creation** - Programmatic channel and permission setup
|
|
51
58
|
- **Template System** - YAML-based channel definitions
|
|
52
|
-
- **CLI Tool** - `
|
|
59
|
+
- **CLI Tool** - `slack-channel-setup` command for automation
|
|
60
|
+
- **Generic Design** - Adaptable for any Slack workspace, not NUI-specific
|
|
61
|
+
|
|
62
|
+
## Design Principles
|
|
63
|
+
|
|
64
|
+
### Keeping the Package Generic
|
|
65
|
+
|
|
66
|
+
This package is intentionally designed to avoid vendor-specific assumptions:
|
|
67
|
+
|
|
68
|
+
**✅ DO:**
|
|
69
|
+
|
|
70
|
+
- Use configurable defaults (e.g., `currency` as required parameter)
|
|
71
|
+
- Accept parameters for service-specific values (e.g., `service_name` in alerts)
|
|
72
|
+
- Provide flexible configuration via environment variables or programmatic setup
|
|
73
|
+
- Keep utility functions generic and reusable
|
|
74
|
+
|
|
75
|
+
**❌ DON'T:**
|
|
76
|
+
|
|
77
|
+
- Hardcode service names, currency codes, or business logic
|
|
78
|
+
- Add domain-specific database query methods (use generic `query()`, `execute()` methods)
|
|
79
|
+
- Create mapping dictionaries for specific organizations (emoji maps, status codes, etc.)
|
|
80
|
+
- Assume specific table schemas or column names
|
|
81
|
+
|
|
82
|
+
**Examples:**
|
|
83
|
+
|
|
84
|
+
- ❌ Hardcoded organization-specific mappings and constants
|
|
85
|
+
- ✅ Accept values as parameters or via configuration
|
|
86
|
+
- ❌ Default values that assume specific geography/currency/timezone
|
|
87
|
+
- ✅ Required parameters or configurable defaults
|
|
88
|
+
- ❌ Database methods that assume specific table schemas
|
|
89
|
+
- ✅ Generic query methods that accept SQL and parameters
|
|
90
|
+
|
|
91
|
+
### When Adding New Features
|
|
92
|
+
|
|
93
|
+
Before adding convenience methods or defaults:
|
|
94
|
+
|
|
95
|
+
1. **Ask**: "Is this specific to NUI, or useful for any Lambda project?"
|
|
96
|
+
2. **Check**: Could this be made configurable rather than hardcoded?
|
|
97
|
+
3. **Test**: Can someone use this without NUI-specific knowledge?
|
|
98
|
+
|
|
99
|
+
If a feature is NUI-specific:
|
|
100
|
+
|
|
101
|
+
- Consider if it belongs in this shared package
|
|
102
|
+
- Document it clearly as an example pattern users can adapt
|
|
103
|
+
- Provide configuration options to override defaults
|
|
53
104
|
|
|
54
105
|
## Development Commands
|
|
55
106
|
|
|
56
107
|
### Environment Setup
|
|
108
|
+
|
|
57
109
|
```bash
|
|
58
110
|
# Install package in development mode with all dependencies
|
|
59
111
|
pip install -e .[dev]
|
|
@@ -90,6 +142,7 @@ pytest tests/test_slack_client.py -v
|
|
|
90
142
|
```
|
|
91
143
|
|
|
92
144
|
### Code Quality
|
|
145
|
+
|
|
93
146
|
```bash
|
|
94
147
|
# Format code with Black (line length: 120)
|
|
95
148
|
black nui_lambda_shared_utils/ tests/
|
|
@@ -102,6 +155,12 @@ mypy nui_lambda_shared_utils/ --config-file mypy.ini
|
|
|
102
155
|
|
|
103
156
|
# Run linting (currently configured to use Black)
|
|
104
157
|
black --check nui_lambda_shared_utils/
|
|
158
|
+
|
|
159
|
+
# Lint markdown documentation
|
|
160
|
+
npx markdownlint-cli2 '**/*.md'
|
|
161
|
+
|
|
162
|
+
# Auto-fix markdown formatting issues
|
|
163
|
+
npx markdownlint-cli2 --fix '**/*.md'
|
|
105
164
|
```
|
|
106
165
|
|
|
107
166
|
### Package Building and Publishing
|
|
@@ -122,7 +181,9 @@ python -m twine upload dist/*
|
|
|
122
181
|
## Configuration Patterns
|
|
123
182
|
|
|
124
183
|
### Environment Variables
|
|
184
|
+
|
|
125
185
|
The package expects these environment variables for runtime configuration:
|
|
186
|
+
|
|
126
187
|
- `ES_HOST` - Elasticsearch endpoint
|
|
127
188
|
- `ES_CREDENTIALS_SECRET` - AWS secret name for ES credentials
|
|
128
189
|
- `DB_CREDENTIALS_SECRET` - AWS secret name for database credentials
|
|
@@ -130,7 +191,9 @@ The package expects these environment variables for runtime configuration:
|
|
|
130
191
|
- `AWS_REGION` - AWS region for services
|
|
131
192
|
|
|
132
193
|
### AWS Secrets Format
|
|
194
|
+
|
|
133
195
|
Secrets should follow standardized JSON structures:
|
|
196
|
+
|
|
134
197
|
```json
|
|
135
198
|
// Elasticsearch
|
|
136
199
|
{"host": "elastic:9200", "username": "user", "password": "pass"}
|
|
@@ -143,6 +206,7 @@ Secrets should follow standardized JSON structures:
|
|
|
143
206
|
```
|
|
144
207
|
|
|
145
208
|
### Programmatic Configuration
|
|
209
|
+
|
|
146
210
|
```python
|
|
147
211
|
import nui_lambda_shared_utils as nui
|
|
148
212
|
|
|
@@ -160,6 +224,7 @@ nui.set_config(config)
|
|
|
160
224
|
## Common Usage Patterns
|
|
161
225
|
|
|
162
226
|
For detailed usage examples and integration patterns, see:
|
|
227
|
+
|
|
163
228
|
- **[Quick Start Guide](docs/getting-started/quickstart.md)** - Common usage patterns for all components
|
|
164
229
|
- **[Slack Integration Guide](docs/guides/slack-integration.md)** - Slack messaging, blocks, threading, and file uploads
|
|
165
230
|
- **[Configuration Guide](docs/getting-started/configuration.md)** - Environment setup and AWS Secrets integration
|
|
@@ -187,43 +252,88 @@ def critical_operation():
|
|
|
187
252
|
## Testing Strategy
|
|
188
253
|
|
|
189
254
|
### Test Categories (pytest markers)
|
|
255
|
+
|
|
190
256
|
- `@pytest.mark.unit` - Fast unit tests with mocking
|
|
191
257
|
- `@pytest.mark.integration` - Tests requiring AWS services
|
|
192
258
|
- `@pytest.mark.slow` - Long-running tests
|
|
193
259
|
|
|
194
260
|
### AWS Testing
|
|
261
|
+
|
|
195
262
|
Integration tests use `moto` for AWS service mocking. Some tests require real AWS credentials for full integration testing.
|
|
196
263
|
|
|
197
264
|
### Test Structure
|
|
198
|
-
|
|
265
|
+
|
|
266
|
+
```text
|
|
199
267
|
tests/
|
|
200
268
|
├── test_<module>.py # Main module tests
|
|
201
269
|
├── conftest.py # Shared fixtures
|
|
202
270
|
└── fixtures/ # Test data files
|
|
203
271
|
```
|
|
204
272
|
|
|
273
|
+
## Contribution Guidelines
|
|
274
|
+
|
|
275
|
+
### Pull Request Checklist
|
|
276
|
+
|
|
277
|
+
Before submitting PRs, ensure:
|
|
278
|
+
|
|
279
|
+
- [ ] **No hardcoded organization-specific values** (service names, currencies, business logic)
|
|
280
|
+
- [ ] **Configuration options** provided for any defaults
|
|
281
|
+
- [ ] **Tests pass** with `pytest --cov`
|
|
282
|
+
- [ ] **Code formatted** with Black (`black nui_lambda_shared_utils/ tests/`)
|
|
283
|
+
- [ ] **Type hints** included for public APIs
|
|
284
|
+
- [ ] **Documentation updated** in docs/ for new features
|
|
285
|
+
- [ ] **Generic naming** - avoid organization-specific terminology in public APIs
|
|
286
|
+
|
|
287
|
+
### Code Review Focus Areas
|
|
288
|
+
|
|
289
|
+
Reviewers should check for:
|
|
290
|
+
|
|
291
|
+
- Generic utility patterns vs vendor-specific code
|
|
292
|
+
- Configurable defaults rather than hardcoded values
|
|
293
|
+
- Clear documentation of any platform assumptions
|
|
294
|
+
- Reusability across different AWS Lambda projects
|
|
295
|
+
|
|
205
296
|
## Package Distribution
|
|
206
297
|
|
|
207
298
|
### Version Management
|
|
299
|
+
|
|
208
300
|
Version is defined in both `setup.py` and `pyproject.toml` and should be kept in sync. The package follows semantic versioning.
|
|
209
301
|
|
|
210
302
|
### PyPI Publishing
|
|
303
|
+
|
|
211
304
|
The package is published to PyPI as `nui-lambda-shared-utils` with GitHub Actions automation for releases.
|
|
212
305
|
|
|
213
306
|
### CLI Tools
|
|
214
|
-
|
|
307
|
+
|
|
308
|
+
The package provides `slack-channel-setup` CLI tool for automating Slack workspace channel creation and configuration from YAML files. This is a generic tool useful for any team managing Slack workspaces.
|
|
309
|
+
|
|
310
|
+
**Usage:**
|
|
311
|
+
|
|
312
|
+
```bash
|
|
313
|
+
# Create channels from YAML config
|
|
314
|
+
slack-channel-setup --config channels.yaml
|
|
315
|
+
|
|
316
|
+
# Check which channels exist
|
|
317
|
+
slack-channel-setup --config channels.yaml --check-only
|
|
318
|
+
|
|
319
|
+
# Generate environment variables
|
|
320
|
+
slack-channel-setup --config channels.yaml --output channels.env --output-format env
|
|
321
|
+
```
|
|
215
322
|
|
|
216
323
|
## AWS Lambda Integration
|
|
217
324
|
|
|
218
325
|
### Bundle Size Optimization
|
|
326
|
+
|
|
219
327
|
- Use specific extras (`[slack]`, `[elasticsearch]`) rather than `[all]`
|
|
220
328
|
- Optional imports prevent failure if dependencies aren't installed
|
|
221
329
|
- Core utilities work without optional dependencies
|
|
222
330
|
|
|
223
331
|
### Lambda Layer Usage
|
|
332
|
+
|
|
224
333
|
The package is designed to work well in Lambda layers for sharing across multiple functions.
|
|
225
334
|
|
|
226
335
|
### Environment Integration
|
|
336
|
+
|
|
227
337
|
- Automatic AWS region detection
|
|
228
338
|
- Secrets Manager integration with credential caching
|
|
229
339
|
- CloudWatch metrics with proper dimensions
|
|
@@ -245,4 +355,4 @@ This project follows a clear documentation structure:
|
|
|
245
355
|
configuration examples, and integration guides that complement these development instructions.
|
|
246
356
|
|
|
247
357
|
**For new package users**: Start with [docs/getting-started/quickstart.md](docs/getting-started/quickstart.md)
|
|
248
|
-
for working code examples and common patterns.
|
|
358
|
+
for working code examples and common patterns.
|
|
@@ -14,18 +14,21 @@ We welcome contributions to the NUI Lambda Shared Utilities project! This docume
|
|
|
14
14
|
|
|
15
15
|
1. Fork the repository on GitHub
|
|
16
16
|
2. Clone your fork locally:
|
|
17
|
+
|
|
17
18
|
```bash
|
|
18
19
|
git clone https://github.com/your-username/nui-lambda-shared-utils.git
|
|
19
20
|
cd nui-lambda-shared-utils
|
|
20
21
|
```
|
|
21
22
|
|
|
22
23
|
3. Create a virtual environment:
|
|
24
|
+
|
|
23
25
|
```bash
|
|
24
26
|
python -m venv venv
|
|
25
27
|
source venv/bin/activate # On Windows: venv\Scripts\activate
|
|
26
28
|
```
|
|
27
29
|
|
|
28
30
|
4. Install development dependencies:
|
|
31
|
+
|
|
29
32
|
```bash
|
|
30
33
|
pip install -e .[dev]
|
|
31
34
|
```
|
|
@@ -74,6 +77,7 @@ make lint # If Makefile exists
|
|
|
74
77
|
### Submitting Changes
|
|
75
78
|
|
|
76
79
|
1. Create a new branch for your feature/fix:
|
|
80
|
+
|
|
77
81
|
```bash
|
|
78
82
|
git checkout -b feature/your-feature-name
|
|
79
83
|
```
|
|
@@ -85,11 +89,13 @@ make lint # If Makefile exists
|
|
|
85
89
|
- Documentation is updated
|
|
86
90
|
|
|
87
91
|
3. Commit your changes:
|
|
92
|
+
|
|
88
93
|
```bash
|
|
89
94
|
git commit -m "Add: brief description of your changes"
|
|
90
95
|
```
|
|
91
96
|
|
|
92
97
|
4. Push to your fork:
|
|
98
|
+
|
|
93
99
|
```bash
|
|
94
100
|
git push origin feature/your-feature-name
|
|
95
101
|
```
|
|
@@ -101,7 +107,6 @@ make lint # If Makefile exists
|
|
|
101
107
|
- **Title**: Use a clear, descriptive title
|
|
102
108
|
- **Description**: Explain what your changes do and why
|
|
103
109
|
- **Testing**: Include information about how you tested your changes
|
|
104
|
-
- **Breaking Changes**: Clearly mark any breaking changes
|
|
105
110
|
|
|
106
111
|
### Commit Message Format
|
|
107
112
|
|
|
@@ -115,6 +120,7 @@ Use conventional commits format:
|
|
|
115
120
|
- `chore:` for maintenance tasks
|
|
116
121
|
|
|
117
122
|
Examples:
|
|
123
|
+
|
|
118
124
|
- `feat: add retry decorator for database operations`
|
|
119
125
|
- `fix: handle missing environment variables gracefully`
|
|
120
126
|
- `docs: update configuration examples in README`
|
|
@@ -185,6 +191,7 @@ class MyUtility:
|
|
|
185
191
|
- Use `test_<functionality>_<condition>_<expected_result>` pattern
|
|
186
192
|
|
|
187
193
|
Example:
|
|
194
|
+
|
|
188
195
|
```python
|
|
189
196
|
class TestSlackClient:
|
|
190
197
|
def test_send_message_success_returns_true(self):
|
|
@@ -242,6 +249,7 @@ def example_function(param1: str, param2: Optional[int] = None) -> Dict[str, Any
|
|
|
242
249
|
### README Updates
|
|
243
250
|
|
|
244
251
|
When adding new functionality, update the README.md with:
|
|
252
|
+
|
|
245
253
|
- Usage examples
|
|
246
254
|
- Configuration options
|
|
247
255
|
- Any new dependencies
|
|
@@ -274,8 +282,9 @@ By contributing to this project, you agree that your contributions will be licen
|
|
|
274
282
|
## Questions?
|
|
275
283
|
|
|
276
284
|
If you have questions about contributing, please:
|
|
285
|
+
|
|
277
286
|
- Open an issue with the "question" label
|
|
278
287
|
- Check the existing documentation
|
|
279
288
|
- Look at similar implementations in the codebase
|
|
280
289
|
|
|
281
|
-
Thank you for contributing! 🎉
|
|
290
|
+
Thank you for contributing! 🎉
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: nui-lambda-shared-utils
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.1.1
|
|
4
4
|
Summary: Enterprise-grade utilities for AWS Lambda functions with Slack, Elasticsearch, and monitoring integrations
|
|
5
5
|
Home-page: https://github.com/nuimarkets/nui-lambda-shared-utils
|
|
6
6
|
Author: NUI Markets
|
|
@@ -38,11 +38,16 @@ Requires-Dist: pymysql>=1.0.0; extra == "database"
|
|
|
38
38
|
Requires-Dist: psycopg2-binary>=2.9.0; extra == "database"
|
|
39
39
|
Provides-Extra: slack
|
|
40
40
|
Requires-Dist: slack-sdk>=3.19.0; extra == "slack"
|
|
41
|
+
Provides-Extra: powertools
|
|
42
|
+
Requires-Dist: aws-lambda-powertools<4.0.0,>=3.6.0; extra == "powertools"
|
|
43
|
+
Requires-Dist: coloredlogs>=15.0; extra == "powertools"
|
|
41
44
|
Provides-Extra: all
|
|
42
45
|
Requires-Dist: elasticsearch<8.0.0,>=7.17.0; extra == "all"
|
|
43
46
|
Requires-Dist: pymysql>=1.0.0; extra == "all"
|
|
44
47
|
Requires-Dist: psycopg2-binary>=2.9.0; extra == "all"
|
|
45
48
|
Requires-Dist: slack-sdk>=3.19.0; extra == "all"
|
|
49
|
+
Requires-Dist: aws-lambda-powertools<4.0.0,>=3.6.0; extra == "all"
|
|
50
|
+
Requires-Dist: coloredlogs>=15.0; extra == "all"
|
|
46
51
|
Provides-Extra: dev
|
|
47
52
|
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
|
48
53
|
Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
|
|
@@ -64,10 +69,11 @@ Dynamic: requires-python
|
|
|
64
69
|
[](https://www.python.org/downloads/)
|
|
65
70
|
[](https://opensource.org/licenses/MIT)
|
|
66
71
|
|
|
67
|
-
|
|
72
|
+
Production-ready utilities for AWS Lambda functions with Slack, Elasticsearch, database, and monitoring integrations. Built and battle-tested on the NUI platform, this package provides standardized patterns for common serverless operations with sensible defaults that can be configured for any AWS environment.
|
|
68
73
|
|
|
69
74
|
## Table of Contents
|
|
70
75
|
|
|
76
|
+
- [Who This Package Is For](#who-this-package-is-for)
|
|
71
77
|
- [Key Features](#key-features)
|
|
72
78
|
- [Documentation](#documentation)
|
|
73
79
|
- [Quick Start](#quick-start)
|
|
@@ -79,8 +85,15 @@ Enterprise-grade utilities for AWS Lambda functions with Slack, Elasticsearch, a
|
|
|
79
85
|
- [Documentation & Support](#documentation--support)
|
|
80
86
|
- [License](#license)
|
|
81
87
|
|
|
88
|
+
## Who This Package Is For
|
|
89
|
+
|
|
90
|
+
**NUI Team**: Drop-in utilities with NUI platform defaults pre-configured. Handles common patterns like Slack notifications, Elasticsearch logging, database connections, and CloudWatch metrics out of the box.
|
|
91
|
+
|
|
92
|
+
**External Teams**: Solid AWS Lambda patterns for serverless operations. Default configurations reflect NUI conventions (Elasticsearch index patterns, AWS Secrets Manager naming, Slack workspace structure) but are fully overridable via environment variables or programmatic configuration. Consider this package as production-tested reference implementations that you can adapt to your infrastructure.
|
|
93
|
+
|
|
82
94
|
## Key Features
|
|
83
95
|
|
|
96
|
+
- **AWS Powertools Integration** - Standardized logging, metrics, and error handling for Lambda functions
|
|
84
97
|
- **AWS Secrets Manager Integration** - Secure credential management with caching
|
|
85
98
|
- **Slack Messaging** - Rich formatting, threading, file uploads, and channel management
|
|
86
99
|
- **Elasticsearch Operations** - Query builders, index management, and health monitoring
|
|
@@ -102,6 +115,12 @@ Enterprise-grade utilities for AWS Lambda functions with Slack, Elasticsearch, a
|
|
|
102
115
|
|
|
103
116
|
**Complete documentation**: See [docs/](docs/README.md) for all guides and references.
|
|
104
117
|
|
|
118
|
+
**Component Guides:**
|
|
119
|
+
|
|
120
|
+
- **[AWS Powertools Integration Guide](docs/guides/powertools-integration.md)** - Logging, metrics, error handling
|
|
121
|
+
- **[Slack Integration Guide](docs/guides/slack-integration.md)** - Messaging, blocks, threading, files
|
|
122
|
+
- **[Testing Guide](docs/development/testing.md)** - Test strategies and coverage
|
|
123
|
+
|
|
105
124
|
## Quick Start
|
|
106
125
|
|
|
107
126
|
### Installation
|
|
@@ -111,6 +130,7 @@ pip install nui-lambda-shared-utils
|
|
|
111
130
|
|
|
112
131
|
# With specific extras for optional dependencies
|
|
113
132
|
pip install nui-lambda-shared-utils[all] # All integrations
|
|
133
|
+
pip install nui-lambda-shared-utils[powertools] # AWS Powertools only
|
|
114
134
|
pip install nui-lambda-shared-utils[slack] # Slack only
|
|
115
135
|
pip install nui-lambda-shared-utils[elasticsearch] # Elasticsearch only
|
|
116
136
|
pip install nui-lambda-shared-utils[database] # Database only
|
|
@@ -166,6 +186,36 @@ slack_creds = get_slack_credentials() # Uses configured secret name
|
|
|
166
186
|
|
|
167
187
|
**[→ See full secrets management guide](docs/getting-started/configuration.md#aws-secrets-manager)**
|
|
168
188
|
|
|
189
|
+
### AWS Powertools Integration
|
|
190
|
+
|
|
191
|
+
```python
|
|
192
|
+
from nui_lambda_shared_utils import get_powertools_logger, powertools_handler
|
|
193
|
+
|
|
194
|
+
# Create logger with Elasticsearch-compatible formatting
|
|
195
|
+
logger = get_powertools_logger("my-service", level="INFO")
|
|
196
|
+
|
|
197
|
+
# Decorate Lambda handler with logging, metrics, and error handling
|
|
198
|
+
@powertools_handler(
|
|
199
|
+
service_name="my-service",
|
|
200
|
+
metrics_namespace="MyApp/Service",
|
|
201
|
+
slack_alert_channel="#production-alerts"
|
|
202
|
+
)
|
|
203
|
+
@logger.inject_lambda_context
|
|
204
|
+
def lambda_handler(event, context):
|
|
205
|
+
logger.info("Processing event", extra={"event_id": event.get("id")})
|
|
206
|
+
return {"statusCode": 200, "body": "Success"}
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
**Features:**
|
|
210
|
+
|
|
211
|
+
- ✅ Elasticsearch-compatible timestamps (`2025-01-18T04:39:27.788Z`)
|
|
212
|
+
- ✅ Automatic Lambda context injection (function name, request ID, cold start)
|
|
213
|
+
- ✅ CloudWatch metrics publishing
|
|
214
|
+
- ✅ Slack error alerts with graceful degradation
|
|
215
|
+
- ✅ Local development with colored logs
|
|
216
|
+
|
|
217
|
+
**[→ See comprehensive Powertools integration guide](docs/guides/powertools-integration.md)**
|
|
218
|
+
|
|
169
219
|
### Slack Integration
|
|
170
220
|
|
|
171
221
|
```python
|
|
@@ -276,11 +326,13 @@ This package requires AWS Secrets Manager for credential storage and IAM permiss
|
|
|
276
326
|
### Quick Reference
|
|
277
327
|
|
|
278
328
|
**Secrets Manager** - Store credentials as JSON:
|
|
329
|
+
|
|
279
330
|
- Elasticsearch: `{"host": "...", "username": "...", "password": "..."}`
|
|
280
331
|
- Database: `{"host": "...", "port": 3306, "username": "...", "password": "...", "database": "..."}`
|
|
281
332
|
- Slack: `{"bot_token": "xoxb-...", "webhook_url": "..."}`
|
|
282
333
|
|
|
283
334
|
**IAM Permissions** - Lambda execution role needs:
|
|
335
|
+
|
|
284
336
|
- `secretsmanager:GetSecretValue` for credential access
|
|
285
337
|
- `cloudwatch:PutMetricData` for metrics publishing
|
|
286
338
|
|
|
@@ -307,15 +359,41 @@ pytest -m integration # Integration tests (requires AWS)
|
|
|
307
359
|
|
|
308
360
|
## Contributing
|
|
309
361
|
|
|
362
|
+
We welcome contributions! This package currently supports MySQL/PostgreSQL, Elasticsearch, Slack, and core AWS services (Secrets Manager, CloudWatch). **We're open to expanding support for additional databases (MongoDB, DynamoDB, etc.) and AWS services (SQS, SNS, EventBridge, etc.).**
|
|
363
|
+
|
|
364
|
+
### How to Contribute
|
|
365
|
+
|
|
310
366
|
1. Fork the repository
|
|
311
367
|
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
|
|
312
368
|
3. Commit your changes (`git commit -m 'Add amazing feature'`)
|
|
313
369
|
4. Push to the branch (`git push origin feature/amazing-feature`)
|
|
314
370
|
5. Open a Pull Request
|
|
315
371
|
|
|
372
|
+
### Contribution Ideas
|
|
373
|
+
|
|
374
|
+
- **Database integrations**: MongoDB, DynamoDB, Redis, Cassandra
|
|
375
|
+
- **AWS services**: SQS, SNS, EventBridge, Step Functions, S3, SES
|
|
376
|
+
- **Messaging platforms**: Microsoft Teams, Discord, PagerDuty
|
|
377
|
+
- **Monitoring**: Datadog, New Relic, Prometheus exporters
|
|
378
|
+
- **Search engines**: OpenSearch, Algolia, Typesense
|
|
379
|
+
- **CLI enhancements**: Additional automation commands for common workflows
|
|
380
|
+
|
|
381
|
+
See our [development guide](docs/development/testing.md) for testing patterns and architecture guidelines.
|
|
382
|
+
|
|
383
|
+
### Built-in CLI Tools
|
|
384
|
+
|
|
385
|
+
The package includes `slack-channel-setup` - a CLI tool for automating Slack workspace channel creation from YAML configuration files. This generic tool works with any Slack workspace and can be used independently of Lambda functions.
|
|
386
|
+
|
|
387
|
+
```bash
|
|
388
|
+
# Install and use
|
|
389
|
+
pip install nui-lambda-shared-utils[slack]
|
|
390
|
+
slack-channel-setup --config channels.yaml
|
|
391
|
+
```
|
|
392
|
+
|
|
316
393
|
## Documentation & Support
|
|
317
394
|
|
|
318
395
|
### 📚 Documentation
|
|
396
|
+
|
|
319
397
|
- **[Complete Documentation](docs/README.md)** - Comprehensive guides and references
|
|
320
398
|
- **[Quick Start Guide](docs/getting-started/quickstart.md)** - Get up and running fast
|
|
321
399
|
- **[Configuration Guide](docs/getting-started/configuration.md)** - Setup and AWS integration
|
|
@@ -323,12 +401,14 @@ pytest -m integration # Integration tests (requires AWS)
|
|
|
323
401
|
- **[Testing Guide](docs/development/testing.md)** - Test strategies and coverage
|
|
324
402
|
|
|
325
403
|
### 🔗 Links
|
|
404
|
+
|
|
326
405
|
- **GitHub Repository**: https://github.com/nuimarkets/nui-lambda-shared-utils
|
|
327
406
|
- **Issue Tracker**: https://github.com/nuimarkets/nui-lambda-shared-utils/issues
|
|
328
407
|
- **PyPI Package**: https://pypi.org/project/nui-lambda-shared-utils/
|
|
329
408
|
- **Changelog**: [CHANGELOG.md](CHANGELOG.md)
|
|
330
409
|
|
|
331
410
|
### 💬 Support
|
|
411
|
+
|
|
332
412
|
- **Bug Reports**: [GitHub Issues](https://github.com/nuimarkets/nui-lambda-shared-utils/issues)
|
|
333
413
|
- **Feature Requests**: [GitHub Issues](https://github.com/nuimarkets/nui-lambda-shared-utils/issues)
|
|
334
414
|
- **Questions**: Check [docs/](docs/README.md) first, then open an issue
|
|
@@ -339,5 +419,4 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file
|
|
|
339
419
|
|
|
340
420
|
## About NUI Markets
|
|
341
421
|
|
|
342
|
-
NUI Markets is a technology company focused on building innovative trading and marketplace platforms. This package represents our commitment to open-source tooling and
|
|
343
|
-
|
|
422
|
+
NUI Markets is a technology company focused on building innovative trading and marketplace platforms. This package represents our commitment to open-source tooling and production-grade infrastructure patterns for AWS Lambda development.
|