clear-skies-aws 2.0.3__tar.gz → 2.0.4__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.
- {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/.pre-commit-config.yaml +1 -4
- {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/CHANGELOG.md +13 -0
- clear_skies_aws-2.0.4/LATEST_CHANGELOG.md +11 -0
- {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/PKG-INFO +4 -2
- {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/pyproject.toml +6 -4
- {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/__init__.py +2 -0
- {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/backends/__init__.py +3 -3
- {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/backends/dynamo_db_backend.py +1 -0
- {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/backends/dynamo_db_condition_parser.py +1 -0
- {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/backends/dynamo_db_parti_ql_backend.py +2 -0
- {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/contexts/lambda_api_gateway_web_socket.py +2 -2
- {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/contexts/lambda_invoke.py +2 -2
- {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/contexts/lambda_sqs_standard.py +2 -2
- clear_skies_aws-2.0.4/src/clearskies_aws/cursors/__init__.py +3 -0
- clear_skies_aws-2.0.4/src/clearskies_aws/cursors/iam/__init__.py +7 -0
- clear_skies_aws-2.0.4/src/clearskies_aws/cursors/iam/rds_mysql.py +125 -0
- clear_skies_aws-2.0.4/src/clearskies_aws/cursors/port_forwarding/__init__.py +3 -0
- {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/di/aws_additional_config_auto_import.py +1 -1
- {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/di/inject/boto3.py +1 -1
- {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/endpoints/secrets_manager_rotation.py +1 -1
- {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/uv.lock +354 -335
- clear_skies_aws-2.0.3/LATEST_CHANGELOG.md +0 -34
- {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/.copier-answers.yml +0 -0
- {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/.editorconfig +0 -0
- {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/.github/workflows/create-version.yaml +0 -0
- {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/.github/workflows/docs.yaml +0 -0
- {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/.github/workflows/run-tests.yml +0 -0
- {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/.github/workflows/tests-matrix.yaml +0 -0
- {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/.github/workflows/tests.yaml +0 -0
- {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/.gitignore +0 -0
- {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/.python-version +0 -0
- {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/LICENSE +0 -0
- {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/README.md +0 -0
- {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/cliff.toml +0 -0
- {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/ruff.toml +0 -0
- {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/actions/__init__.py +0 -0
- {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/actions/action_aws.py +0 -0
- {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/actions/assume_role.py +0 -0
- {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/actions/ses.py +0 -0
- {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/actions/sns.py +0 -0
- {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/actions/sqs.py +0 -0
- {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/actions/step_function.py +0 -0
- {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/backends/backend.py +0 -0
- {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/backends/sqs_backend.py +0 -0
- {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/configs/__init__.py +0 -0
- {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/contexts/__init__.py +0 -0
- {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/contexts/cli_web_socket_mock.py +0 -0
- {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/contexts/lambda_alb.py +0 -0
- {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/contexts/lambda_api_gateway.py +0 -0
- {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/contexts/lambda_sns.py +0 -0
- {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/di/__init__.py +0 -0
- {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/di/inject/__init__.py +0 -0
- {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/di/inject/boto3_session.py +0 -0
- {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/di/inject/parameter_store.py +0 -0
- {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/endpoints/__init__.py +0 -0
- {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/endpoints/simple_body_routing.py +0 -0
- {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/input_outputs/__init__.py +0 -0
- {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/input_outputs/cli_web_socket_mock.py +0 -0
- {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/input_outputs/lambda_alb.py +0 -0
- {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/input_outputs/lambda_api_gateway.py +0 -0
- {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/input_outputs/lambda_api_gateway_web_socket.py +0 -0
- {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/input_outputs/lambda_input_output.py +0 -0
- {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/input_outputs/lambda_invoke.py +0 -0
- {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/input_outputs/lambda_sns.py +0 -0
- {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/input_outputs/lambda_sqs_standard.py +0 -0
- {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/mocks/__init__.py +0 -0
- {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/mocks/actions/__init__.py +0 -0
- {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/mocks/actions/ses.py +0 -0
- {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/mocks/actions/sns.py +0 -0
- {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/mocks/actions/sqs.py +0 -0
- {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/mocks/actions/step_function.py +0 -0
- {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/models/__init__.py +0 -0
- {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/models/web_socket_connection_model.py +0 -0
- {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/secrets/__init__.py +0 -0
- {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/secrets/additional_configs/__init__.py +0 -0
- {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/secrets/additional_configs/iam_db_auth.py +0 -0
- {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/secrets/additional_configs/iam_db_auth_with_ssm.py +0 -0
- {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/secrets/additional_configs/mysql_connection_dynamic_producer_via_ssh_cert_bastion.py +0 -0
- {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/secrets/additional_configs/mysql_connection_dynamic_producer_via_ssm_bastion.py +0 -0
- {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/secrets/akeyless_with_ssm_cache.py +0 -0
- {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/secrets/parameter_store.py +0 -0
- {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/secrets/secrets.py +0 -0
- {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/secrets/secrets_manager.py +0 -0
|
@@ -8,9 +8,6 @@ ci:
|
|
|
8
8
|
default_install_hook_types:
|
|
9
9
|
- pre-commit
|
|
10
10
|
- commit-msg
|
|
11
|
-
- post-checkout
|
|
12
|
-
- post-merge
|
|
13
|
-
- post-rewrite
|
|
14
11
|
|
|
15
12
|
default_stages: ["pre-commit"]
|
|
16
13
|
|
|
@@ -69,7 +66,7 @@ repos:
|
|
|
69
66
|
hooks:
|
|
70
67
|
- id: pytest
|
|
71
68
|
name: pytest
|
|
72
|
-
entry: uv run pytest .
|
|
69
|
+
entry: uv run pytest . -m "not broken"
|
|
73
70
|
language: system
|
|
74
71
|
types: [python]
|
|
75
72
|
pass_filenames: false
|
|
@@ -5,9 +5,21 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [2.0.4] - 2026-01-09
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- Add rds mysql cursor
|
|
12
|
+
|
|
13
|
+
### Changed
|
|
14
|
+
- Use the port forwarder class in [#8](https://github.com/clearskies-py/aws/pull/8)
|
|
15
|
+
|
|
16
|
+
### Fixed
|
|
17
|
+
- Make age dynamic instead of fixed
|
|
18
|
+
|
|
8
19
|
## [2.0.3] - 2026-01-05
|
|
9
20
|
|
|
10
21
|
### Changed
|
|
22
|
+
- Bump version to v2.0.3 by @github-actions[bot]
|
|
11
23
|
- Merge pull request #7 from clearskies-py/contexts by @cmancone in [#7](https://github.com/clearskies-py/aws/pull/7)
|
|
12
24
|
- Require latest clearskies version per added feature by @cmancone
|
|
13
25
|
- Bring up-to-date by @cmancone
|
|
@@ -77,6 +89,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
77
89
|
* @cmancone made their first contribution
|
|
78
90
|
* @ made their first contribution
|
|
79
91
|
* @github-actions[bot] made their first contribution
|
|
92
|
+
[2.0.4]: https://github.com/clearskies-py/aws/compare/v2.0.3..v2.0.4
|
|
80
93
|
[2.0.3]: https://github.com/clearskies-py/aws/compare/v2.0.2..v2.0.3
|
|
81
94
|
[2.0.2]: https://github.com/clearskies-py/aws/compare/v2.0.1..v2.0.2
|
|
82
95
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: clear-skies-aws
|
|
3
|
-
Version: 2.0.
|
|
3
|
+
Version: 2.0.4
|
|
4
4
|
Summary: clearskies bindings for working in AWS
|
|
5
5
|
Project-URL: Repository, https://github.com/clearskies-py/clearskies-aws
|
|
6
6
|
Project-URL: Issues, https://github.com/clearskies-py/clearskies-aws/issues
|
|
@@ -17,10 +17,12 @@ Classifier: Programming Language :: Python :: 3
|
|
|
17
17
|
Requires-Python: <4.0,>=3.11
|
|
18
18
|
Requires-Dist: boto3<2.0.0,>=1.26.148
|
|
19
19
|
Requires-Dist: clear-skies<3.0.0,>=2.0.20
|
|
20
|
-
Requires-Dist: types-boto3[dynamodb,sns,sqs]<2.0.0,>=1.38.13
|
|
20
|
+
Requires-Dist: types-boto3[dynamodb,secretsmanager,ses,sns,sqs,ssm,stepfunctions]<2.0.0,>=1.38.13
|
|
21
21
|
Provides-Extra: akeyless
|
|
22
22
|
Requires-Dist: akeyless-cloud-id<0.5.0,>=0.2.3; extra == 'akeyless'
|
|
23
23
|
Requires-Dist: akeyless<6.0.0,>=5.0.0; extra == 'akeyless'
|
|
24
|
+
Provides-Extra: mysql
|
|
25
|
+
Requires-Dist: pymysql<2.0.0,>=1.1.0; extra == 'mysql'
|
|
24
26
|
Provides-Extra: ses
|
|
25
27
|
Requires-Dist: jinja2<4.0.0,>=3.1.2; extra == 'ses'
|
|
26
28
|
Description-Content-Type: text/markdown
|
|
@@ -3,14 +3,14 @@
|
|
|
3
3
|
name = "clear-skies-aws"
|
|
4
4
|
description = "clearskies bindings for working in AWS"
|
|
5
5
|
license = "MIT"
|
|
6
|
-
version = "2.0.
|
|
6
|
+
version = "2.0.4"
|
|
7
7
|
readme = "./README.md"
|
|
8
8
|
authors = [{name = "tnijboer"}, {name = "Conor Mancone", email = "cmancone@gmail.com"}]
|
|
9
9
|
requires-python = '>=3.11,<4.0'
|
|
10
10
|
dependencies = [
|
|
11
11
|
'boto3 (>=1.26.148,<2.0.0)',
|
|
12
|
-
|
|
13
|
-
'types-boto3[dynamodb,sns,sqs] (>=1.38.13,<2.0.0)',
|
|
12
|
+
"clear-skies>=2.0.20,<3.0.0",
|
|
13
|
+
'types-boto3[dynamodb,sns,sqs,ses,ssm,secretsmanager,stepfunctions] (>=1.38.13,<2.0.0)',
|
|
14
14
|
]
|
|
15
15
|
classifiers = [
|
|
16
16
|
"Development Status :: 5 - Production/Stable",
|
|
@@ -28,6 +28,7 @@ Documentation = "https://clearskies.info/modules/clearskies-aws/"
|
|
|
28
28
|
[project.optional-dependencies]
|
|
29
29
|
akeyless = ['akeyless-cloud-id (>=0.2.3,<0.5.0)', 'akeyless (>=5.0.0,<6.0.0)']
|
|
30
30
|
ses = ['jinja2 (>=3.1.2,<4.0.0)']
|
|
31
|
+
mysql = ['pymysql (>=1.1.0,<2.0.0)']
|
|
31
32
|
|
|
32
33
|
[build-system]
|
|
33
34
|
requires = ["hatchling"]
|
|
@@ -55,7 +56,8 @@ python_version = "3.11"
|
|
|
55
56
|
|
|
56
57
|
exclude = [
|
|
57
58
|
".*_test\\.py$",
|
|
58
|
-
"docs/.*"
|
|
59
|
+
"docs/.*",
|
|
60
|
+
"tests/.*"
|
|
59
61
|
]
|
|
60
62
|
|
|
61
63
|
[tool.pytest.ini_options]
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
3
|
from clearskies_aws.backends.backend import Backend
|
|
4
|
-
from clearskies_aws.backends.dynamo_db_backend import DynamoDBBackend
|
|
5
|
-
from clearskies_aws.backends.dynamo_db_condition_parser import DynamoDBConditionParser
|
|
6
|
-
from clearskies_aws.backends.dynamo_db_parti_ql_backend import (
|
|
4
|
+
from clearskies_aws.backends.dynamo_db_backend import DynamoDBBackend # type: ignore
|
|
5
|
+
from clearskies_aws.backends.dynamo_db_condition_parser import DynamoDBConditionParser # type: ignore
|
|
6
|
+
from clearskies_aws.backends.dynamo_db_parti_ql_backend import ( # type: ignore
|
|
7
7
|
DynamoDBPartiQLBackend,
|
|
8
8
|
DynamoDBPartiQLCursor,
|
|
9
9
|
)
|
|
@@ -73,7 +73,7 @@ class LambdaApiGatewayWebSocket(Context):
|
|
|
73
73
|
|
|
74
74
|
"""
|
|
75
75
|
|
|
76
|
-
def __call__(
|
|
76
|
+
def __call__( # type: ignore[override]
|
|
77
77
|
self, event: dict[str, Any], context: dict[str, Any], url: str = "", request_method: str = ""
|
|
78
|
-
) -> dict[str, Any]:
|
|
78
|
+
) -> dict[str, Any]:
|
|
79
79
|
return self.execute_application(LambdaApiGatewayWebSocketInputOutput(event, context, url))
|
{clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/contexts/lambda_invoke.py
RENAMED
|
@@ -125,9 +125,9 @@ class LambdaInvoke(Context):
|
|
|
125
125
|
|
|
126
126
|
"""
|
|
127
127
|
|
|
128
|
-
def __call__(
|
|
128
|
+
def __call__( # type: ignore[override]
|
|
129
129
|
self, event: dict[str, Any], context: dict[str, Any], request_method: str = "", url: str = ""
|
|
130
|
-
) -> dict[str, Any]:
|
|
130
|
+
) -> dict[str, Any]:
|
|
131
131
|
return self.execute_application(
|
|
132
132
|
LambdaInvokeInputOutput(
|
|
133
133
|
event,
|
{clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/contexts/lambda_sqs_standard.py
RENAMED
|
@@ -120,9 +120,9 @@ class LambdaSqsStandard(Context):
|
|
|
120
120
|
|
|
121
121
|
"""
|
|
122
122
|
|
|
123
|
-
def __call__(
|
|
123
|
+
def __call__( # type: ignore[override]
|
|
124
124
|
self, event: dict[str, Any], context: dict[str, Any], url: str = "", request_method: str = ""
|
|
125
|
-
) -> dict[str, Any]:
|
|
125
|
+
) -> dict[str, Any]:
|
|
126
126
|
item_failures = []
|
|
127
127
|
for record in event["Records"]:
|
|
128
128
|
try:
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
"""
|
|
2
|
+
RdsMySql: MySQL cursor with AWS RDS IAM authentication.
|
|
3
|
+
|
|
4
|
+
This class provides a MySQL cursor that uses AWS RDS IAM DB authentication.
|
|
5
|
+
It loads connection parameters from environment variables and generates a temporary
|
|
6
|
+
IAM authentication token for secure database access.
|
|
7
|
+
|
|
8
|
+
Configuration fields:
|
|
9
|
+
- boto3: Injected boto3 provider for AWS API access.
|
|
10
|
+
- environment: Injected environment variable provider.
|
|
11
|
+
- hostname_environment_key: Environment variable for DB host (default: "DATABASE_HOST").
|
|
12
|
+
- username_environment_key: Environment variable for DB user (default: "DATABASE_USERNAME").
|
|
13
|
+
- database_environment_key: Environment variable for DB name (default: "DATABASE_NAME").
|
|
14
|
+
- port_environment_key: Environment variable for DB port (default: "DATABASE_PORT").
|
|
15
|
+
- cert_path_environment_key: Environment variable for SSL CA cert (default: "DATABASE_CERT_PATH").
|
|
16
|
+
- autocommit_environment_key: Environment variable for autocommit (default: "DATABASE_AUTOCOMMIT").
|
|
17
|
+
- connect_timeout_environment_key: Environment variable for connect timeout (default: "DATABASE_CONNECT_TIMEOUT").
|
|
18
|
+
- database_region_key: Environment variable for AWS region (default: "DATABASE_REGION").
|
|
19
|
+
|
|
20
|
+
Example:
|
|
21
|
+
import clearskies_aws.cursors.iam.rds_mysql
|
|
22
|
+
|
|
23
|
+
cursor = clearskies_aws.cursors.iam.rds_mysql.RdsMySql()
|
|
24
|
+
cursor.execute("SELECT 1")
|
|
25
|
+
"""
|
|
26
|
+
|
|
27
|
+
import os
|
|
28
|
+
from typing import Any
|
|
29
|
+
|
|
30
|
+
import clearskies
|
|
31
|
+
from clearskies import decorators
|
|
32
|
+
from clearskies.cursors import Mysql as MysqlBase
|
|
33
|
+
|
|
34
|
+
from clearskies_aws.di import inject
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
class RdsMySql(MysqlBase):
|
|
38
|
+
"""MySQL cursor with AWS RDS IAM DB authentication."""
|
|
39
|
+
|
|
40
|
+
"""Injected boto3 provider for AWS API access."""
|
|
41
|
+
boto3 = inject.Boto3()
|
|
42
|
+
|
|
43
|
+
"""Injected environment variable provider."""
|
|
44
|
+
environment = clearskies.di.inject.Environment()
|
|
45
|
+
|
|
46
|
+
"""Environment variable for DB host (default: "DATABASE_HOST")."""
|
|
47
|
+
hostname_environment_key = clearskies.configs.String(default="DATABASE_HOST")
|
|
48
|
+
|
|
49
|
+
"""Environment variable for DB user (default: "DATABASE_USERNAME")."""
|
|
50
|
+
username_environment_key = clearskies.configs.String(default="DATABASE_USERNAME")
|
|
51
|
+
|
|
52
|
+
"""Environment variable for DB name (default: "DATABASE_NAME")."""
|
|
53
|
+
database_environment_key = clearskies.configs.String(default="DATABASE_NAME")
|
|
54
|
+
|
|
55
|
+
"""Environment variable for DB port (default: "DATABASE_PORT")."""
|
|
56
|
+
port_environment_key = clearskies.configs.String(default="DATABASE_PORT")
|
|
57
|
+
|
|
58
|
+
"""Environment variable for SSL CA cert (default: "DATABASE_CERT_PATH")."""
|
|
59
|
+
cert_path_environment_key = clearskies.configs.String(default="DATABASE_CERT_PATH")
|
|
60
|
+
|
|
61
|
+
"""Environment variable for autocommit (default: "DATABASE_AUTOCOMMIT")."""
|
|
62
|
+
autocommit_environment_key = clearskies.configs.String(default="DATABASE_AUTOCOMMIT")
|
|
63
|
+
|
|
64
|
+
"""Environment variable for connect timeout (default: "DATABASE_CONNECT_TIMEOUT")."""
|
|
65
|
+
connect_timeout_environment_key = clearskies.configs.String(default="DATABASE_CONNECT_TIMEOUT")
|
|
66
|
+
|
|
67
|
+
"""Environment variable for AWS region (default: "DATABASE_REGION")."""
|
|
68
|
+
database_region_key = clearskies.configs.String(default="DATABASE_REGION")
|
|
69
|
+
|
|
70
|
+
@decorators.parameters_to_properties
|
|
71
|
+
def __init__(
|
|
72
|
+
self,
|
|
73
|
+
hostname_environment_key: str | None = None,
|
|
74
|
+
username_environment_key: str | None = None,
|
|
75
|
+
database_environment_key: str | None = None,
|
|
76
|
+
port_environment_key: str | None = None,
|
|
77
|
+
cert_path_environment_key: str | None = None,
|
|
78
|
+
autocommit_environment_key: str | None = None,
|
|
79
|
+
database_region_key: str | None = None,
|
|
80
|
+
connect_timeout_environment_key: str | None = None,
|
|
81
|
+
port_forwarding: Any | None = None,
|
|
82
|
+
):
|
|
83
|
+
self.finalize_and_validate_configuration()
|
|
84
|
+
|
|
85
|
+
def build_connection_kwargs(self) -> dict:
|
|
86
|
+
"""
|
|
87
|
+
Build the connection kwargs for the MySQL client, using IAM DB authentication.
|
|
88
|
+
|
|
89
|
+
Returns
|
|
90
|
+
-------
|
|
91
|
+
dict
|
|
92
|
+
Connection parameters for the MySQL client.
|
|
93
|
+
"""
|
|
94
|
+
connection_kwargs = {
|
|
95
|
+
"user": self.environment.get(self.username_environment_key),
|
|
96
|
+
"host": self.environment.get(self.hostname_environment_key),
|
|
97
|
+
"database": self.environment.get(self.database_environment_key),
|
|
98
|
+
"port": int(self.environment.get(self.port_environment_key, silent=True) or self.port),
|
|
99
|
+
"ssl_ca": self.environment.get(self.cert_path_environment_key, silent=True),
|
|
100
|
+
"autocommit": self.environment.get(self.autocommit_environment_key, silent=True),
|
|
101
|
+
"connect_timeout": int(
|
|
102
|
+
self.environment.get(self.connect_timeout_environment_key, silent=True) or self.connect_timeout
|
|
103
|
+
),
|
|
104
|
+
}
|
|
105
|
+
region: str = self.environment.get(self.database_region_key, True) or self.environment.get("AWS_REGION", True)
|
|
106
|
+
if not region:
|
|
107
|
+
raise ValueError(
|
|
108
|
+
"To use RDS IAM DB auth you must set DATABASE_REGION or AWS_REGION in the .env file or an environment variable"
|
|
109
|
+
)
|
|
110
|
+
os.environ["LIBMYSQL_ENABLE_CLEARTEXT_PLUGIN"] = "1"
|
|
111
|
+
|
|
112
|
+
rds_api = self.boto3.Session().client("rds")
|
|
113
|
+
rds_token = rds_api.generate_db_auth_token(
|
|
114
|
+
DBHostname=connection_kwargs.get("host"),
|
|
115
|
+
Port=connection_kwargs.get("port", 3306),
|
|
116
|
+
DBUsername=connection_kwargs.get("user"),
|
|
117
|
+
Region=region,
|
|
118
|
+
)
|
|
119
|
+
connection_kwargs["password"] = rds_token
|
|
120
|
+
|
|
121
|
+
for kwarg in ["autocommit", "connect_timeout", "port", "ssl_ca"]:
|
|
122
|
+
if not connection_kwargs[kwarg]:
|
|
123
|
+
del connection_kwargs[kwarg]
|
|
124
|
+
|
|
125
|
+
return {**super().build_connection_kwargs(), **connection_kwargs}
|
|
@@ -17,7 +17,7 @@ class AwsAdditionalConfigAutoImport(AdditionalConfigAutoImport):
|
|
|
17
17
|
This DI auto injects boto3, boto3 Session and the parameter store.
|
|
18
18
|
"""
|
|
19
19
|
|
|
20
|
-
def
|
|
20
|
+
def provide_boto3_sdk(self) -> ModuleType:
|
|
21
21
|
import boto3
|
|
22
22
|
|
|
23
23
|
return boto3
|
|
@@ -91,7 +91,7 @@ class SecretsManagerRotation(Endpoint):
|
|
|
91
91
|
pending_secret_data = json.loads(pending_secret["SecretString"])
|
|
92
92
|
except botocore.exceptions.ClientError as error:
|
|
93
93
|
if error.response["Error"]["Code"] == "ResourceNotFoundException":
|
|
94
|
-
pending_secret_data =
|
|
94
|
+
pending_secret_data = {}
|
|
95
95
|
else:
|
|
96
96
|
raise error
|
|
97
97
|
|