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.
Files changed (83) hide show
  1. {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/.pre-commit-config.yaml +1 -4
  2. {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/CHANGELOG.md +13 -0
  3. clear_skies_aws-2.0.4/LATEST_CHANGELOG.md +11 -0
  4. {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/PKG-INFO +4 -2
  5. {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/pyproject.toml +6 -4
  6. {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/__init__.py +2 -0
  7. {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/backends/__init__.py +3 -3
  8. {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/backends/dynamo_db_backend.py +1 -0
  9. {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/backends/dynamo_db_condition_parser.py +1 -0
  10. {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/backends/dynamo_db_parti_ql_backend.py +2 -0
  11. {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/contexts/lambda_api_gateway_web_socket.py +2 -2
  12. {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/contexts/lambda_invoke.py +2 -2
  13. {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/contexts/lambda_sqs_standard.py +2 -2
  14. clear_skies_aws-2.0.4/src/clearskies_aws/cursors/__init__.py +3 -0
  15. clear_skies_aws-2.0.4/src/clearskies_aws/cursors/iam/__init__.py +7 -0
  16. clear_skies_aws-2.0.4/src/clearskies_aws/cursors/iam/rds_mysql.py +125 -0
  17. clear_skies_aws-2.0.4/src/clearskies_aws/cursors/port_forwarding/__init__.py +3 -0
  18. {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/di/aws_additional_config_auto_import.py +1 -1
  19. {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/di/inject/boto3.py +1 -1
  20. {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/endpoints/secrets_manager_rotation.py +1 -1
  21. {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/uv.lock +354 -335
  22. clear_skies_aws-2.0.3/LATEST_CHANGELOG.md +0 -34
  23. {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/.copier-answers.yml +0 -0
  24. {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/.editorconfig +0 -0
  25. {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/.github/workflows/create-version.yaml +0 -0
  26. {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/.github/workflows/docs.yaml +0 -0
  27. {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/.github/workflows/run-tests.yml +0 -0
  28. {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/.github/workflows/tests-matrix.yaml +0 -0
  29. {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/.github/workflows/tests.yaml +0 -0
  30. {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/.gitignore +0 -0
  31. {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/.python-version +0 -0
  32. {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/LICENSE +0 -0
  33. {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/README.md +0 -0
  34. {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/cliff.toml +0 -0
  35. {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/ruff.toml +0 -0
  36. {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/actions/__init__.py +0 -0
  37. {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/actions/action_aws.py +0 -0
  38. {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/actions/assume_role.py +0 -0
  39. {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/actions/ses.py +0 -0
  40. {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/actions/sns.py +0 -0
  41. {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/actions/sqs.py +0 -0
  42. {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/actions/step_function.py +0 -0
  43. {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/backends/backend.py +0 -0
  44. {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/backends/sqs_backend.py +0 -0
  45. {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/configs/__init__.py +0 -0
  46. {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/contexts/__init__.py +0 -0
  47. {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/contexts/cli_web_socket_mock.py +0 -0
  48. {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/contexts/lambda_alb.py +0 -0
  49. {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/contexts/lambda_api_gateway.py +0 -0
  50. {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/contexts/lambda_sns.py +0 -0
  51. {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/di/__init__.py +0 -0
  52. {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/di/inject/__init__.py +0 -0
  53. {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/di/inject/boto3_session.py +0 -0
  54. {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/di/inject/parameter_store.py +0 -0
  55. {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/endpoints/__init__.py +0 -0
  56. {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/endpoints/simple_body_routing.py +0 -0
  57. {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/input_outputs/__init__.py +0 -0
  58. {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/input_outputs/cli_web_socket_mock.py +0 -0
  59. {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/input_outputs/lambda_alb.py +0 -0
  60. {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/input_outputs/lambda_api_gateway.py +0 -0
  61. {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
  62. {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/input_outputs/lambda_input_output.py +0 -0
  63. {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/input_outputs/lambda_invoke.py +0 -0
  64. {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/input_outputs/lambda_sns.py +0 -0
  65. {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/input_outputs/lambda_sqs_standard.py +0 -0
  66. {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/mocks/__init__.py +0 -0
  67. {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/mocks/actions/__init__.py +0 -0
  68. {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/mocks/actions/ses.py +0 -0
  69. {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/mocks/actions/sns.py +0 -0
  70. {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/mocks/actions/sqs.py +0 -0
  71. {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/mocks/actions/step_function.py +0 -0
  72. {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/models/__init__.py +0 -0
  73. {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/models/web_socket_connection_model.py +0 -0
  74. {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/secrets/__init__.py +0 -0
  75. {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/secrets/additional_configs/__init__.py +0 -0
  76. {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/secrets/additional_configs/iam_db_auth.py +0 -0
  77. {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
  78. {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
  79. {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
  80. {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/secrets/akeyless_with_ssm_cache.py +0 -0
  81. {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/secrets/parameter_store.py +0 -0
  82. {clear_skies_aws-2.0.3 → clear_skies_aws-2.0.4}/src/clearskies_aws/secrets/secrets.py +0 -0
  83. {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
 
@@ -0,0 +1,11 @@
1
+ ## [2.0.4] - 2026-01-09
2
+
3
+ ### Added
4
+ - Add rds mysql cursor
5
+
6
+ ### Changed
7
+ - Use the port forwarder class in [#8](https://github.com/clearskies-py/aws/pull/8)
8
+
9
+ ### Fixed
10
+ - Make age dynamic instead of fixed
11
+
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: clear-skies-aws
3
- Version: 2.0.3
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.3"
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
- 'clear-skies (>=2.0.20,<3.0.0)',
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]
@@ -4,6 +4,7 @@ from clearskies_aws import (
4
4
  actions,
5
5
  backends,
6
6
  contexts,
7
+ cursors,
7
8
  di,
8
9
  endpoints,
9
10
  handlers,
@@ -17,6 +18,7 @@ __all__ = [
17
18
  "actions",
18
19
  "backends",
19
20
  "contexts",
21
+ "cursors",
20
22
  "di",
21
23
  "endpoints",
22
24
  "handlers",
@@ -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
  )
@@ -1,3 +1,4 @@
1
+ # type: ignore
1
2
  from __future__ import annotations
2
3
 
3
4
  import base64
@@ -1,3 +1,4 @@
1
+ # type: ignore
1
2
  from __future__ import annotations
2
3
 
3
4
  import base64
@@ -1,3 +1,5 @@
1
+ # type: ignore
2
+
1
3
  from __future__ import annotations
2
4
 
3
5
  import base64
@@ -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]: # type: ignore[override]
78
+ ) -> dict[str, Any]:
79
79
  return self.execute_application(LambdaApiGatewayWebSocketInputOutput(event, context, url))
@@ -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]: # type: ignore[override]
130
+ ) -> dict[str, Any]:
131
131
  return self.execute_application(
132
132
  LambdaInvokeInputOutput(
133
133
  event,
@@ -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]: # type: ignore[override]
125
+ ) -> dict[str, Any]:
126
126
  item_failures = []
127
127
  for record in event["Records"]:
128
128
  try:
@@ -0,0 +1,3 @@
1
+ from clearskies_aws.cursors import iam, port_forwarding
2
+
3
+ __all__ = ["iam", "port_forwarding"]
@@ -0,0 +1,7 @@
1
+ import logging
2
+
3
+ from clearskies_aws.cursors.iam.rds_mysql import RdsMySql
4
+
5
+ logging.getLogger(__name__)
6
+
7
+ __all__ = ["RdsMySql", "MysqlWithSSM"]
@@ -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}
@@ -0,0 +1,3 @@
1
+ from clearskies_aws.cursors.port_forwarding.ssm import Ssm
2
+
3
+ __all__ = ["Ssm"]
@@ -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 provide_boto3(self) -> ModuleType:
20
+ def provide_boto3_sdk(self) -> ModuleType:
21
21
  import boto3
22
22
 
23
23
  return boto3
@@ -12,4 +12,4 @@ class Boto3(Injectable):
12
12
  def __get__(self, instance, parent) -> ModuleType:
13
13
  if instance is None:
14
14
  return self # type: ignore
15
- return self._di.build_from_name("boto3", cache=self.cache)
15
+ return self._di.build_from_name("boto3_sdk", cache=self.cache)
@@ -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 = None
94
+ pending_secret_data = {}
95
95
  else:
96
96
  raise error
97
97