clear-skies-aws 1.10.1__py3-none-any.whl → 2.0.1__py3-none-any.whl

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 (73) hide show
  1. {clear_skies_aws-1.10.1.dist-info → clear_skies_aws-2.0.1.dist-info}/METADATA +36 -35
  2. clear_skies_aws-2.0.1.dist-info/RECORD +4 -0
  3. {clear_skies_aws-1.10.1.dist-info → clear_skies_aws-2.0.1.dist-info}/WHEEL +1 -1
  4. clear_skies_aws-2.0.1.dist-info/licenses/LICENSE +21 -0
  5. clear_skies_aws-1.10.1.dist-info/LICENSE +0 -7
  6. clear_skies_aws-1.10.1.dist-info/RECORD +0 -71
  7. clearskies_aws/__init__.py +0 -2
  8. clearskies_aws/actions/__init__.py +0 -108
  9. clearskies_aws/actions/action_aws.py +0 -118
  10. clearskies_aws/actions/assume_role.py +0 -102
  11. clearskies_aws/actions/assume_role_test.py +0 -72
  12. clearskies_aws/actions/ses.py +0 -194
  13. clearskies_aws/actions/ses_test.py +0 -89
  14. clearskies_aws/actions/sns.py +0 -64
  15. clearskies_aws/actions/sns_test.py +0 -77
  16. clearskies_aws/actions/sqs.py +0 -82
  17. clearskies_aws/actions/sqs_test.py +0 -127
  18. clearskies_aws/actions/step_function.py +0 -66
  19. clearskies_aws/actions/step_function_test.py +0 -103
  20. clearskies_aws/backends/__init__.py +0 -12
  21. clearskies_aws/backends/dynamo_db_backend.py +0 -614
  22. clearskies_aws/backends/dynamo_db_backend_test.py +0 -300
  23. clearskies_aws/backends/dynamo_db_condition_parser.py +0 -365
  24. clearskies_aws/backends/dynamo_db_condition_parser_test.py +0 -266
  25. clearskies_aws/backends/dynamo_db_parti_ql_backend.py +0 -1123
  26. clearskies_aws/backends/dynamo_db_parti_ql_backend_test.py +0 -544
  27. clearskies_aws/backends/sqs_backend.py +0 -80
  28. clearskies_aws/backends/sqs_backend_test.py +0 -31
  29. clearskies_aws/contexts/__init__.py +0 -10
  30. clearskies_aws/contexts/cli.py +0 -19
  31. clearskies_aws/contexts/cli_websocket_mock.py +0 -33
  32. clearskies_aws/contexts/lambda_api_gateway.py +0 -30
  33. clearskies_aws/contexts/lambda_api_gateway_web_socket.py +0 -30
  34. clearskies_aws/contexts/lambda_elb.py +0 -30
  35. clearskies_aws/contexts/lambda_http_gateway.py +0 -30
  36. clearskies_aws/contexts/lambda_invocation.py +0 -48
  37. clearskies_aws/contexts/lambda_sns.py +0 -43
  38. clearskies_aws/contexts/lambda_sqs_standard_partial_batch.py +0 -51
  39. clearskies_aws/contexts/lambda_sqs_standard_partial_batch_test.py +0 -66
  40. clearskies_aws/contexts/wsgi.py +0 -19
  41. clearskies_aws/di/__init__.py +0 -1
  42. clearskies_aws/di/standard_dependencies.py +0 -60
  43. clearskies_aws/handlers/__init__.py +0 -2
  44. clearskies_aws/handlers/secrets_manager_rotation.py +0 -174
  45. clearskies_aws/handlers/simple_body_routing.py +0 -39
  46. clearskies_aws/input_outputs/__init__.py +0 -8
  47. clearskies_aws/input_outputs/cli_websocket_mock.py +0 -12
  48. clearskies_aws/input_outputs/lambda_api_gateway.py +0 -105
  49. clearskies_aws/input_outputs/lambda_api_gateway_test.py +0 -87
  50. clearskies_aws/input_outputs/lambda_api_gateway_web_socket.py +0 -8
  51. clearskies_aws/input_outputs/lambda_elb.py +0 -21
  52. clearskies_aws/input_outputs/lambda_http_gateway.py +0 -12
  53. clearskies_aws/input_outputs/lambda_invocation.py +0 -34
  54. clearskies_aws/input_outputs/lambda_sns.py +0 -52
  55. clearskies_aws/input_outputs/lambda_sqs_standard.py +0 -54
  56. clearskies_aws/mocks/__init__.py +0 -1
  57. clearskies_aws/mocks/actions/__init__.py +0 -6
  58. clearskies_aws/mocks/actions/ses.py +0 -28
  59. clearskies_aws/mocks/actions/sns.py +0 -23
  60. clearskies_aws/mocks/actions/sqs.py +0 -23
  61. clearskies_aws/mocks/actions/step_function.py +0 -26
  62. clearskies_aws/secrets/__init__.py +0 -7
  63. clearskies_aws/secrets/additional_configs/__init__.py +0 -54
  64. clearskies_aws/secrets/additional_configs/iam_db_auth.py +0 -29
  65. clearskies_aws/secrets/additional_configs/iam_db_auth_with_ssm.py +0 -92
  66. clearskies_aws/secrets/additional_configs/mysql_connection_dynamic_producer_via_ssh_cert_bastion.py +0 -81
  67. clearskies_aws/secrets/additional_configs/mysql_connection_dynamic_producer_via_ssm_bastion.py +0 -141
  68. clearskies_aws/secrets/akeyless_with_ssm_cache.py +0 -38
  69. clearskies_aws/secrets/parameter_store.py +0 -50
  70. clearskies_aws/secrets/parameter_store_test.py +0 -18
  71. clearskies_aws/secrets/secrets_manager.py +0 -75
  72. clearskies_aws/secrets/secrets_manager_test.py +0 -18
  73. clearskies_aws/web_socket_connection_model.py +0 -43
@@ -1,46 +1,48 @@
1
- Metadata-Version: 2.3
1
+ Metadata-Version: 2.4
2
2
  Name: clear-skies-aws
3
- Version: 1.10.1
3
+ Version: 2.0.1
4
4
  Summary: clearskies bindings for working in AWS
5
- License: MIT
6
- Author: Conor Mancone
7
- Author-email: cmancone@gmail.com
8
- Requires-Python: >=3.10,<4.0
5
+ Project-URL: Repository, https://github.com/clearskies-py/clearskies-aws
6
+ Project-URL: Issues, https://github.com/clearskies-py/clearskies-aws/issues
7
+ Project-URL: Changelog, https://github.com/clearskies-py/clearskies-aws/blob/main/CHANGELOG.md
8
+ Project-URL: Documentation, https://clearskies.info/modules/clearskies-aws/
9
+ Author: tnijboer
10
+ Author-email: Conor Mancone <cmancone@gmail.com>
11
+ License-Expression: MIT
12
+ License-File: LICENSE
13
+ Classifier: Development Status :: 5 - Production/Stable
14
+ Classifier: Intended Audience :: Developers
9
15
  Classifier: License :: OSI Approved :: MIT License
10
16
  Classifier: Programming Language :: Python :: 3
11
- Classifier: Programming Language :: Python :: 3.10
12
- Classifier: Programming Language :: Python :: 3.11
13
- Classifier: Programming Language :: Python :: 3.12
14
- Classifier: Programming Language :: Python :: 3.13
17
+ Requires-Python: <4.0,>=3.11
18
+ Requires-Dist: boto3<2.0.0,>=1.26.148
19
+ Requires-Dist: clear-skies<3.0.0,>=2.0.2
20
+ Requires-Dist: types-boto3[dynamodb,sns,sqs]<2.0.0,>=1.38.13
15
21
  Provides-Extra: akeyless
22
+ Requires-Dist: akeyless-cloud-id<0.5.0,>=0.2.3; extra == 'akeyless'
23
+ Requires-Dist: akeyless<6.0.0,>=5.0.0; extra == 'akeyless'
16
24
  Provides-Extra: ses
17
- Requires-Dist: akeyless (>=4.0.0,<5.0.0) ; extra == "akeyless"
18
- Requires-Dist: akeyless-cloud-id (>=0.2.3,<0.3.0) ; extra == "akeyless"
19
- Requires-Dist: boto3 (>=1.26.148,<2.0.0)
20
- Requires-Dist: clear-skies (>=1.14.4,<2.0.0)
21
- Requires-Dist: jinja2 (>=3.1.2,<4.0.0) ; extra == "ses"
22
- Requires-Dist: types-boto3[dynamodb,sns,sqs] (>=1.38.13,<2.0.0)
23
- Project-URL: Repository, https://github.com/cmancone/clearskies-aws
25
+ Requires-Dist: jinja2<4.0.0,>=3.1.2; extra == 'ses'
24
26
  Description-Content-Type: text/markdown
25
27
 
26
28
  # clearskies-aws
27
29
 
28
30
  clearskies bindings for working in AWS, which means additional:
29
31
 
30
- - backends (DynamoDB, SQS)
31
- - Secret/environment integrations (parameter store/secret manager)
32
- - DB connectivity via IAM auth
33
- - Contexts (ALB, HTTP API Gateway, Rest API Gateway, direct Lambda invocation, lambda+SQS)
32
+ - backends (DynamoDB, SQS)
33
+ - Secret/environment integrations (parameter store/secret manager)
34
+ - DB connectivity via IAM auth
35
+ - Contexts (ALB, HTTP API Gateway, Rest API Gateway, direct Lambda invocation, lambda+SQS)
34
36
 
35
- # Installation, Documentation, and Usage
37
+ ## Installation, Documentation, and Usage
36
38
 
37
39
  To install:
38
40
 
39
- ```
41
+ ```shell
40
42
  pip3 install clear-skies-aws
41
43
  ```
42
44
 
43
- # Usage
45
+ ## Usage
44
46
 
45
47
  Anytime you use a context from `clearskies-aws`, the default dependencies are adjust to:
46
48
 
@@ -49,17 +51,17 @@ Anytime you use a context from `clearskies-aws`, the default dependencies are ad
49
51
 
50
52
  In both cases you must provide the AWS region for your resources, which you do by setting the `AWS_REGION` environment variable (either in an actual environment variable or in your `.env` file).
51
53
 
52
- ## Paramter Store
54
+ ### Parameter Store
53
55
 
54
56
  To use the SSM parameter store you just inject the `secrets` variable into your callables:
55
57
 
56
- ```
58
+ ```python
57
59
  import clearskies_aws
58
60
 
59
61
  def parameter_store_demo(secrets):
60
62
  return secrets.get('/path/to/parameter')
61
63
 
62
- execute_demo_in_elb = clearskies_aws.contexts.lambda_elb(parameter_store_demo)
64
+ execute_demo_in_elb = clearskies_aws.contexts.lambda_alb(parameter_store_demo)
63
65
 
64
66
  def lambda_handler(event, context):
65
67
  return execute_demo_in_elb(event, context)
@@ -67,14 +69,14 @@ def lambda_handler(event, context):
67
69
 
68
70
  Also, per default behavior, clearskies can fetch things from your secret manager if specified in your environment/.env file. For instance, if your database password is stored in parameter store, then you can reference it from your `.env` file with a standard cursor backend:
69
71
 
70
- ```
72
+ ```env
71
73
  db_host = "path-to-aws.rds"
72
74
  db_username = "sql_username"
73
75
  db_password = "secret://path/to/password/in/parameter/store"
74
76
  db_database = "sql_database_name"
75
77
  ```
76
78
 
77
- ## Secret Manager
79
+ ### Secret Manager
78
80
 
79
81
  If desired, you can swap out the parameter store integration for secret manager. Just remember that you can configure parameter store to fetch secrets from secret manager, so you might be best off doing that and sticking with the default parameter store integration. Still, if you want to use secret manager, you just configure it in your application or context:
80
82
 
@@ -93,7 +95,7 @@ def lambda_handler(event, context):
93
95
  return execute_demo_in_elb(event, context)
94
96
  ```
95
97
 
96
- ## Contexts
98
+ ### Contexts
97
99
 
98
100
  clearskies_aws adds the following contexts:
99
101
 
@@ -105,7 +107,7 @@ clearskies_aws adds the following contexts:
105
107
  | `clearskies_aws.contexts.lambda_inocation` | Lambdas invoked directly |
106
108
  | `clearskies_aws.contexts.lambda_sqs_standard_partial_batch` | Lambdas attached to an SQS queue |
107
109
 
108
- ### Lambdas+SQS
110
+ #### Lambdas+SQS
109
111
 
110
112
  Here's a simple example of using the Lambda+SQS context:
111
113
 
@@ -125,7 +127,7 @@ See [the AWS docs](https://docs.aws.amazon.com/lambda/latest/dg/with-sqs.html).
125
127
 
126
128
  Note that, unlike other contexts, the Lambda+SQS context really only works with a simple callable. Routing and other handlers don't make much sense here. Keep in mind that, before invoking the Lambda, AWS may batch up records together in arbitrary ways. The context will take care of this and will invoke your callable once **for each record in the AWS event** - not once for the event. `request_data` will be populated with the actual message for the event. In addition, it assumes that a JSON message was sent to the queue, so `request_data` will be an object/list/etc, rather than a string. This is intended to be used with [partial batching](https://docs.aws.amazon.com/lambda/latest/dg/with-sqs.html#services-sqs-batchfailurereporting). Therefore, if your function raises an error, the context will catch it, return a failure response for the cooresponding message, and then continue processing any other messages in the batch.
127
129
 
128
- ## SQS Backend
130
+ ### SQS Backend
129
131
 
130
132
  To use the SQS backend just declare it for your model, set the table name to return the queue url, and execute a "create" operation to send data to the queue. Note that the SQS backend is write-only: you can "create" records (resulting in a message being sent to the queue), but you can't read data back out. The way the queue system in SQS works is just too different than a standard database for that to make sense in the context of a clearskies model.
131
133
 
@@ -164,7 +166,7 @@ if __name__ == '__main__':
164
166
  cli()
165
167
  ```
166
168
 
167
- ## IAM DB Auth
169
+ ### IAM DB Auth
168
170
 
169
171
  For non-serverless RDS databases, AWS supports login via IAM. You have to provide a few additional details in your environment to make this work:
170
172
 
@@ -195,7 +197,6 @@ def lambda_handler(event, context):
195
197
 
196
198
  Of course normally you wouldn't want to interact with it directly. Adding `IAMDBAuth` to your `additional_configs` and setting up the necessary environemnt variables will be sufficient that any models that use the `cursor_backend` will connect via IAM DB Auth, rather than using hard-coded passwords.
197
199
 
198
- ## IAM DB Auth with SSM Bastion
200
+ ### IAM DB Auth with SSM Bastion
199
201
 
200
202
  Coming shortly
201
-
@@ -0,0 +1,4 @@
1
+ clear_skies_aws-2.0.1.dist-info/METADATA,sha256=RuKqjsvTbdZc56XVM2UD6IZnSySbVkWA5SaFkxpbps4,8972
2
+ clear_skies_aws-2.0.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
3
+ clear_skies_aws-2.0.1.dist-info/licenses/LICENSE,sha256=MkEX8JF8kZxdyBpTTcB0YTd-xZpWnHvbRlw-pQh8u58,1069
4
+ clear_skies_aws-2.0.1.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: poetry-core 2.1.2
2
+ Generator: hatchling 1.27.0
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025, Tom Nijboer
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -1,7 +0,0 @@
1
- Copyright 2021 Conor Mancone
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
-
5
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
-
7
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,71 +0,0 @@
1
- clearskies_aws/__init__.py,sha256=BZKL4SIyxx4MXpyP5hmwsMo2oJatyv5c2wjJOPzKBQ4,134
2
- clearskies_aws/actions/__init__.py,sha256=w_IWJg4UHV9Opv69zheH7ZHj1BnCzYLlm2JhFvHQCf8,2998
3
- clearskies_aws/actions/action_aws.py,sha256=zBXsvhBDDm2dAU4MVlub84Ld1YNZ6ey8_zf4OeTe8go,4254
4
- clearskies_aws/actions/assume_role.py,sha256=tZHKMTQaImj_EAWormFZdIPkR_db7yBwOJxYaUyuGdA,4085
5
- clearskies_aws/actions/assume_role_test.py,sha256=AoXWRtApRZz_oPDj6QhT0ERmYjKOHOXLNet-MgbbeB8,2451
6
- clearskies_aws/actions/ses.py,sha256=xJ0NEFPP-8kARPGjDv1yf_bhAiaIIM1mDzMxY22GE5E,7925
7
- clearskies_aws/actions/ses_test.py,sha256=lyNbqI46Ld_ZUKtWLgSwwfSOFksQ39H4hzPS3eTx7nk,3076
8
- clearskies_aws/actions/sns.py,sha256=00E-eCQuq3Ygscyia928K8jX8rhDZrl5kyasM0st_uI,2288
9
- clearskies_aws/actions/sns_test.py,sha256=iqlaZOA-0YHPOu52-XqpCIAgAv1JZodDdlm4YYYhj8U,2306
10
- clearskies_aws/actions/sqs.py,sha256=i-QyyFy-ImivXk-m-Bn9Mh5BF5qODthUyZAQVRsb8vs,3392
11
- clearskies_aws/actions/sqs_test.py,sha256=aazVN-bY6E17Pu3hDwLldj6YPirbqXjM6LfYFomUVmQ,4040
12
- clearskies_aws/actions/step_function.py,sha256=wiDgGdOWdY0zVoClDsX08YFZqTR0bK3ydpyj0Qa7w_s,2599
13
- clearskies_aws/actions/step_function_test.py,sha256=0gRYLDVRt2R-Cv-5Pr2ui4Gbp8rg9nPhQY4ERALg6qU,3837
14
- clearskies_aws/backends/__init__.py,sha256=t98x6QNF2bvKzVI_owS4L3eG5JNVtsLS9c2fBw8uh9s,379
15
- clearskies_aws/backends/dynamo_db_backend.py,sha256=i-Na3McQDbyCYmQewBPKgbWEd3A3pf2wfmLs6FsRJ48,29487
16
- clearskies_aws/backends/dynamo_db_backend_test.py,sha256=wtymsOEVzO9y7_Whu9cCRyioRTmSimbLmRQSt3J4cik,13106
17
- clearskies_aws/backends/dynamo_db_condition_parser.py,sha256=v-DO4ijdjiHwBsSDF3dUgqQw5twCcG-5NA1aq7kUYQ0,13239
18
- clearskies_aws/backends/dynamo_db_condition_parser_test.py,sha256=n7snumB8GxyMBVlj-HL7JrsNj-ZJ91c5gdik0UNM5Ag,12664
19
- clearskies_aws/backends/dynamo_db_parti_ql_backend.py,sha256=pVd_N7XFf9PcTAm6rhMxih_sj9Ix6RkRj3LwmFy_Mr4,48544
20
- clearskies_aws/backends/dynamo_db_parti_ql_backend_test.py,sha256=7gH-RDh7JeaiEGLXsOB512SLmOp0hjdtWQ1cMmexvDM,23649
21
- clearskies_aws/backends/sqs_backend.py,sha256=hT1JCvCMU76Q4Ir7OeX8U8eAMLIu1_tMwGgaN9rpsPk,2726
22
- clearskies_aws/backends/sqs_backend_test.py,sha256=iCuHVVqZIR_PDGUUMZIkpir8yyJy3dcPR00AWR2N25U,1138
23
- clearskies_aws/contexts/__init__.py,sha256=YjwRaSoAqC-nmo3aFB8rzyuiHSP9mi77FVM-8RF0hRE,472
24
- clearskies_aws/contexts/cli.py,sha256=11Giwl10ydackFo0clpTnHZP-HTmJnvtpbhxJf74jDA,506
25
- clearskies_aws/contexts/cli_websocket_mock.py,sha256=W5Ujp9UIz4QG2A33OTpozFLihF5SaN2uUhwf17-qj3g,1085
26
- clearskies_aws/contexts/lambda_api_gateway.py,sha256=zYO_g4K87XYlQeZLYwF7_mzYbZCUzaZYaelpfcfeuTw,1002
27
- clearskies_aws/contexts/lambda_api_gateway_web_socket.py,sha256=5vTe8uWgHzQ11aToBeRHoFymYufUsTXBLC6sE6zUt9Q,1067
28
- clearskies_aws/contexts/lambda_elb.py,sha256=R4tyuRPjuTHNgmyzDqxy-VNePsIdXRH-mUMyWEOMky4,952
29
- clearskies_aws/contexts/lambda_http_gateway.py,sha256=9gmlTTPkxrtLmOQa7uUojCk9tFGg5kJGDB7GiAXx-bQ,1009
30
- clearskies_aws/contexts/lambda_invocation.py,sha256=U_S3cuY3G1_7ktzGiFTiO2LUnqauqvEDfKKEhYdPtpg,1336
31
- clearskies_aws/contexts/lambda_sns.py,sha256=crIo3S78N8xfthZsv0l5ooNlpF21ETjoWmHe1WCGQ4w,1364
32
- clearskies_aws/contexts/lambda_sqs_standard_partial_batch.py,sha256=iypcI4BpxV4IHcKKUWDxK3HuGyaYiP5YPwpFAm4auCw,1801
33
- clearskies_aws/contexts/lambda_sqs_standard_partial_batch_test.py,sha256=SkEIV_cgxCi-1zC3WXsRNyG6bCt7LB_6CWpxvB8QPxo,1855
34
- clearskies_aws/contexts/wsgi.py,sha256=wmHnDIfcrQN0I547uE2mlHHQtOLOpLfpbKpBJkw5puY,510
35
- clearskies_aws/di/__init__.py,sha256=KLq6G-CKR-Vdk9LZe5TijW_U-McJlrp1QuIXqmyAL-A,56
36
- clearskies_aws/di/standard_dependencies.py,sha256=TRST5BxxPQpWJyvXnAwCRJWYRDXC7qM05X3ffYI7EXc,2023
37
- clearskies_aws/handlers/__init__.py,sha256=E2x04QGy5dfaDIB5Xu8IRWwgypIrgGEZibijtKWe8jM,112
38
- clearskies_aws/handlers/secrets_manager_rotation.py,sha256=KV4XWKar4gT0Xu0eM_D75ECzYkjXxjeZtkOopPRG9rc,7471
39
- clearskies_aws/handlers/simple_body_routing.py,sha256=FGdeDY8nZIGfCOn0oOHi6EOP1h4xXcBP3W9fH0NuBlc,1449
40
- clearskies_aws/input_outputs/__init__.py,sha256=Tf8kWN95nwUbvlVaboYT06ICtSuZd0MPPzwWhO5iQGs,385
41
- clearskies_aws/input_outputs/cli_websocket_mock.py,sha256=J3PDYnFxOzqYhmlxWFcobbb4McKpsGduIBq6jdSAx5Y,434
42
- clearskies_aws/input_outputs/lambda_api_gateway.py,sha256=Xi9IdT0u20IMbaIJMBtF2wmsNLCDvmEUVoYB9IRqV00,3479
43
- clearskies_aws/input_outputs/lambda_api_gateway_test.py,sha256=B4tUxTqnAEeV0D0VRMu0HyphOJKNij-LtFd2ERcnKI8,2979
44
- clearskies_aws/input_outputs/lambda_api_gateway_web_socket.py,sha256=kG2fys9X7TailvlOBzIMItuSI8rlvDbBD4AXtI091hM,308
45
- clearskies_aws/input_outputs/lambda_elb.py,sha256=b675h0DxTGo9YscXN4mwzRGzP3hNSie4iPRKOg3kKPI,750
46
- clearskies_aws/input_outputs/lambda_http_gateway.py,sha256=YQk7GlQWtQjDiKWhX5jvXc3un1eq2sm1v_jl6iseNoQ,692
47
- clearskies_aws/input_outputs/lambda_invocation.py,sha256=yF3rYJ-r0YYzlh--33fGE-I-pzyhQxDmDo1TUQxCu00,1122
48
- clearskies_aws/input_outputs/lambda_sns.py,sha256=0m1dfVCSEftcovGAEWhU9ig4txX9duLkTXbdtjIzSAw,2055
49
- clearskies_aws/input_outputs/lambda_sqs_standard.py,sha256=RjsOqzyUovTuO3Nb9CSiWnVaHHxJiPmvOmuQbmpIW38,1974
50
- clearskies_aws/mocks/__init__.py,sha256=mn764gINN667tYoJfnsM6HjAAhCsO_kZ6E-fUwdLY50,22
51
- clearskies_aws/mocks/actions/__init__.py,sha256=to1r8B365Et2PRVfUWWnJGt7Hdr8vwwQuNyZvTSTP6g,152
52
- clearskies_aws/mocks/actions/ses.py,sha256=sCCNk_WdnQbINOzg8E31xyoeoEuUQeX-RwPbJ9ueNik,937
53
- clearskies_aws/mocks/actions/sns.py,sha256=eFnLf-ZIDCL0b62uKDBbPSYXZs1Mc3kRaGv_gPt-8rA,658
54
- clearskies_aws/mocks/actions/sqs.py,sha256=7cwGX7XUhzfGzDJYso2UkUBhMaugvxEqeNKbh9hOark,662
55
- clearskies_aws/mocks/actions/step_function.py,sha256=1JbdsVwPea1wmNnTnlgeWzGaQNBAkJl-2-Y5PG3uORI,888
56
- clearskies_aws/secrets/__init__.py,sha256=MF-e-9FTfnJ64UdZAmYiOxqOl1vSxvWA-FlFFv05CKE,326
57
- clearskies_aws/secrets/additional_configs/__init__.py,sha256=ejLAqwFTP6Xc5aXJAUpBhK1xUtmLzEmexHBuOOmgNBc,1919
58
- clearskies_aws/secrets/additional_configs/iam_db_auth.py,sha256=K6eLjo_D0uSxtCfqTAqGshDi3uz_iF-T0sDSJLyoTew,1082
59
- clearskies_aws/secrets/additional_configs/iam_db_auth_with_ssm.py,sha256=hzvR_WBwSoLcMdGXwhqkvKMKmjXzhZgimPWfm2MWSZQ,3467
60
- clearskies_aws/secrets/additional_configs/mysql_connection_dynamic_producer_via_ssh_cert_bastion.py,sha256=L2-E8Tm6BDHV-yJJ_M_Lo72jNY7uBaTp8SPrRuekcUE,3776
61
- clearskies_aws/secrets/additional_configs/mysql_connection_dynamic_producer_via_ssm_bastion.py,sha256=Llvg8uQW8J-qndAlDDtg9TY_Tvu2h9tUzchxxUtaRik,6444
62
- clearskies_aws/secrets/akeyless_with_ssm_cache.py,sha256=4_ep7P2SXei3hNbLrMhUSmr14GTzK69hkzjIYYU-dA4,1443
63
- clearskies_aws/secrets/parameter_store.py,sha256=lxBlp_9d2-vVjGNfl5859XzZCcLVMMrZtlJG8lKGVPA,1810
64
- clearskies_aws/secrets/parameter_store_test.py,sha256=35fTNau4tq_D4elMwyyByIiLesnmn05QhC_X1FVQXsM,763
65
- clearskies_aws/secrets/secrets_manager.py,sha256=jlpfAFC23EeSpm50L8B-yrXg4IROQq-M_90zzXDp_ak,3056
66
- clearskies_aws/secrets/secrets_manager_test.py,sha256=__YSe-YRbbE1S1SBvZZFQd3brIX5DPX2_wE9MI_Ezx0,788
67
- clearskies_aws/web_socket_connection_model.py,sha256=d_Au_Pu7YXBfc7_lbuI7zz4MZ8ZOOwGM0oooppEofcI,1776
68
- clear_skies_aws-1.10.1.dist-info/LICENSE,sha256=3Ehd0g3YOpCj8sqj0Xjq5qbOtjjgk9qzhhD9YjRQgOA,1053
69
- clear_skies_aws-1.10.1.dist-info/METADATA,sha256=f3IkhGylUcnIZSITx8j56rD5LJWTEks69c5FTZjGqfI,8784
70
- clear_skies_aws-1.10.1.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
71
- clear_skies_aws-1.10.1.dist-info/RECORD,,
@@ -1,2 +0,0 @@
1
- from . import actions, backends, contexts, handlers, mocks, secrets
2
- from .web_socket_connection_model import WebSocketConnectionModel
@@ -1,108 +0,0 @@
1
- import clearskies
2
-
3
- from typing import Optional, Callable, Union
4
-
5
- from .assume_role import AssumeRole
6
- from .ses import SES
7
- from .sns import SNS
8
- from .sqs import SQS
9
- from .step_function import StepFunction
10
- def ses(
11
- sender,
12
- to=None,
13
- cc=None,
14
- bcc=None,
15
- subject=None,
16
- message=None,
17
- subject_template=None,
18
- message_template=None,
19
- subject_template_file=None,
20
- message_template_file=None,
21
- assume_role=None,
22
- dependencies_for_template=None,
23
- when=None,
24
- ):
25
- return clearskies.BindingConfig(
26
- SES,
27
- sender,
28
- to=to,
29
- cc=cc,
30
- bcc=bcc,
31
- subject=subject,
32
- subject_template=subject_template,
33
- subject_template_file=subject_template_file,
34
- message=message,
35
- message_template=message_template,
36
- message_template_file=message_template_file,
37
- assume_role=assume_role,
38
- dependencies_for_template=dependencies_for_template,
39
- when=when,
40
- )
41
- def sns(
42
- topic=None,
43
- topic_environment_key=None,
44
- topic_callable=None,
45
- message_callable=None,
46
- when=None,
47
- ):
48
- return clearskies.BindingConfig(
49
- SNS,
50
- topic=topic,
51
- topic_environment_key=topic_environment_key,
52
- topic_callable=topic_callable,
53
- message_callable=message_callable,
54
- when=when,
55
- )
56
- def sqs(
57
- queue_url: str = '',
58
- queue_url_environment_key: str = '',
59
- queue_url_callable: Callable = '',
60
- message_callable: Callable = None,
61
- when: Callable = None,
62
- assume_role=None,
63
- message_group_id: Optional[Union[Callable, str]]=None,
64
- ):
65
- return clearskies.BindingConfig(
66
- SQS,
67
- queue_url=queue_url,
68
- queue_url_environment_key=queue_url_environment_key,
69
- queue_url_callable=queue_url_callable,
70
- message_callable=message_callable,
71
- when=when,
72
- assume_role=assume_role,
73
- message_group_id=message_group_id,
74
- )
75
- def step_function(
76
- arn: str = "",
77
- arn_environment_key: str = "",
78
- arn_callable: Optional[Callable] = None,
79
- message_callable: Optional[Callable] = None,
80
- when: Optional[Callable] = None,
81
- assume_role: Optional[AssumeRole] = None,
82
- column_to_store_execution_arn: Optional[str] = None,
83
- ):
84
- return clearskies.BindingConfig(
85
- StepFunction,
86
- arn=arn,
87
- arn_environment_key=arn_environment_key,
88
- arn_callable=arn_callable,
89
- message_callable=message_callable,
90
- when=when,
91
- assume_role=assume_role,
92
- column_to_store_execution_arn=column_to_store_execution_arn,
93
- )
94
- def assume_role(
95
- role_arn: str,
96
- external_id: str = "",
97
- role_session_name: str = "",
98
- duration: int = 3600,
99
- source: Optional[AssumeRole] = None,
100
- ):
101
- return AssumeRole(
102
- role_arn,
103
- external_id=external_id,
104
- role_session_name=role_session_name,
105
- duration=duration,
106
- source=source,
107
- )
108
- __all__ = [assume_role, AssumeRole, ses, SES, sns, SNS, step_function, StepFunction, sqs, SQS]
@@ -1,118 +0,0 @@
1
- import boto3
2
- import json
3
- import logging
4
-
5
- from abc import ABC
6
- from boto3 import client
7
- from botocore.exceptions import ClientError
8
- from clearskies.environment import Environment
9
- from clearskies.models import Models
10
- from clearskies.functional import string
11
- from collections import OrderedDict
12
- from typing import Callable, Optional
13
-
14
- from ..di import StandardDependencies
15
- from .assume_role import AssumeRole
16
- class ActionAws(ABC):
17
-
18
- _logging = logging.getLogger(__name__)
19
- _client: Optional[boto3.client] = None
20
- _name: Optional[str] = None
21
-
22
- def __init__(self, environment: Environment, boto3: boto3, di: StandardDependencies) -> None:
23
- """Setup action."""
24
- self.environment = environment
25
- self.boto3 = boto3
26
- self.di = di
27
-
28
- def configure(
29
- self,
30
- message_callable: Optional[Callable] = None,
31
- when: Optional[Callable] = None,
32
- assume_role: Optional[AssumeRole] = None,
33
- ) -> None:
34
- """Configues the Action."""
35
- self.when = when
36
- self.message_callable = message_callable
37
- self.assume_role = assume_role
38
-
39
- if self.message_callable and not callable(self.message_callable):
40
- raise ValueError(
41
- "'message_callable' should be a callable that returns the message for the queue, but a callable was not passed."
42
- )
43
-
44
- if when and not callable(when):
45
- raise ValueError("'when' must be a callable but something else was found")
46
-
47
- if not self._name:
48
- raise ValueError(f"Name of client not set.")
49
-
50
- if not self.environment.get('AWS_REGION', True) and not self.environment.get('AWS_DEFAULT_REGION', True):
51
- raise ValueError("You must set either the AWS_REGION or AWS_DEFAULT_REGION environment variable when using AWS actions")
52
-
53
- def __call__(self, model: Models) -> None:
54
- """Send a notification as configured."""
55
- if self.when and not self.di.call_function(self.when, model=model):
56
- return
57
-
58
- try:
59
- client = self._getClient()
60
- self._execute_action(client, model)
61
- except ClientError as e:
62
- self._logging.exception(f"Failed to retrieve client for {self._name}")
63
- raise e
64
-
65
- def _getClient(self, region=None) -> boto3.client:
66
- """Retrieve the boto3 client."""
67
- can_cache = not region
68
- if self._client and can_cache:
69
- return self._client
70
-
71
- if self.assume_role:
72
- boto3 = self.assume_role(self.boto3)
73
- else:
74
- boto3 = self.boto3
75
-
76
- if not region:
77
- region = self.default_region()
78
- if region:
79
- client = boto3.client(self._name, region_name=region)
80
- else:
81
- client = boto3.client(self._name)
82
-
83
- if can_cache:
84
- self._client = client
85
- return client
86
-
87
- def default_region(self):
88
- region = self.environment.get('AWS_REGION', silent=True)
89
- if region:
90
- return region
91
- region = self.environment.get('DEFAULT_AWS_REGION', silent=True)
92
- if region:
93
- return region
94
- return None
95
-
96
- def _execute_action(self, client: boto3.client, model: Models) -> None:
97
- """Run the action."""
98
- pass
99
-
100
- def get_message_body(self, model: Models) -> str:
101
- """Retrieve the message for the action."""
102
- if self.message_callable:
103
- result = self.di.call_function(self.message_callable, model=model)
104
- if isinstance(result, dict) or isinstance(result, list):
105
- return json.dumps(result, default=string.datetime_to_iso)
106
- if not isinstance(result, str):
107
- raise TypeError(
108
- f"The return value from the message callable for the {__name__} action must be a string, dictionary, or list. I received a "
109
- + f"{type(result)} after calling '{self.message_callable.__name__}'"
110
- )
111
- return result
112
-
113
- model_data = OrderedDict()
114
- for (column_name, column) in model.columns().items():
115
- if not column.is_readable:
116
- continue
117
- model_data.update(column.to_json(model))
118
- return json.dumps(model_data, default=string.datetime_to_iso)
@@ -1,102 +0,0 @@
1
- from __future__ import annotations
2
- from types import ModuleType
3
- from typing import Optional
4
- class AssumeRole:
5
- """
6
- Used by the various actions if you need to assume a role before making an AWS call.
7
-
8
- Note that, in all cases, this class and the actions assume that you already have AWS credentials
9
- properly configured/findable by boto3 in the standard way. If you just have static IAM credentials
10
- that you are trying to use... well, you can do that with some undocumented hackery, but that's not
11
- really the goal for any of these classes.
12
-
13
- Example:
14
- Here's a basic usage example with an SQS action on a model trigger::
15
-
16
- class User(clearskies.Model):
17
- def __init__(self, memory_backend, columns):
18
- super().__init__(memory_backend, columns)
19
- def columns_configuration(self):
20
- return OrderedDict([
21
- clearskies.column_types.string(
22
- 'name',
23
- on_change=[
24
- clearskies_aws.actions.sqs(
25
- queue_url='https://queue.url.example.aws.com',
26
- assume_role=clearskies_aws.actions.assume_role(
27
- role_arn='arn:aws:iam:role/name',
28
- external_id='12345',
29
- )
30
- )
31
- ],
32
- ),
33
- ])
34
-
35
- Example:
36
- Here's a more complicated example with a double-assumme-role to show how to combine them::
37
-
38
- first_assume_role = clearskies_aws.actions.assume_role(
39
- role_arn='arn:aws:123456789012:iam:role/name',
40
- external_id='12345',
41
- )
42
- final_assume_role = clearskies_aws.actions.assume_role(
43
- role_arn='arn:aws:210987654321:iam:role/name-2',
44
- external_id='54321',
45
- source=first_assume_role,
46
- )
47
- class User(clearskies.Model):
48
- def __init__(self, memory_backend, columns):
49
- super().__init__(memory_backend, columns)
50
- def columns_configuration(self):
51
- return OrderedDict([
52
- clearskies.column_types.string(
53
- 'name',
54
- on_change=[clearskies_aws.actions.sqs(
55
- queue_url='https://queue.url.example.aws.com',
56
- assume_role=final_assume_role,
57
- )],
58
- ),
59
- ])
60
-
61
- """
62
- role_arn = ""
63
- external_id = ""
64
- role_session_name = ""
65
- duration = 3600
66
- source: Optional[AssumeRole] = None
67
-
68
- def __init__(
69
- self,
70
- role_arn: str,
71
- external_id: str = "",
72
- role_session_name: str = "",
73
- duration: int = 3600,
74
- source: Optional[AssumeRole] = None
75
- ):
76
- """Assume a role."""
77
- self.role_arn = role_arn
78
- self.external_id = external_id
79
- self.role_session_name = role_session_name
80
- self.duration = duration
81
- self.source = source
82
-
83
- def __call__(self, boto3: ModuleType) -> ModuleType:
84
- # chaining!
85
- if self.source:
86
- boto3 = self.source(boto3)
87
-
88
- calling_params = {
89
- "RoleArn": self.role_arn,
90
- "RoleSessionName": self.role_session_name if self.role_session_name else "clearkies-aws",
91
- "DurationSeconds": self.duration,
92
- }
93
- if self.external_id:
94
- calling_params['ExternalId'] = self.external_id
95
- credentials = boto3.client("sts").assume_role(**calling_params)["Credentials"]
96
-
97
- # now let's make a new session using those
98
- return boto3.Session(
99
- aws_access_key_id=credentials["AccessKeyId"],
100
- aws_secret_access_key=credentials["SecretAccessKey"],
101
- aws_session_token=credentials["SessionToken"],
102
- )