clear-skies-aws 1.10.2__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.
- {clear_skies_aws-1.10.2.dist-info → clear_skies_aws-2.0.1.dist-info}/METADATA +36 -35
- clear_skies_aws-2.0.1.dist-info/RECORD +4 -0
- {clear_skies_aws-1.10.2.dist-info → clear_skies_aws-2.0.1.dist-info}/WHEEL +1 -1
- clear_skies_aws-2.0.1.dist-info/licenses/LICENSE +21 -0
- clear_skies_aws-1.10.2.dist-info/LICENSE +0 -7
- clear_skies_aws-1.10.2.dist-info/RECORD +0 -71
- clearskies_aws/__init__.py +0 -2
- clearskies_aws/actions/__init__.py +0 -108
- clearskies_aws/actions/action_aws.py +0 -118
- clearskies_aws/actions/assume_role.py +0 -102
- clearskies_aws/actions/assume_role_test.py +0 -72
- clearskies_aws/actions/ses.py +0 -194
- clearskies_aws/actions/ses_test.py +0 -89
- clearskies_aws/actions/sns.py +0 -64
- clearskies_aws/actions/sns_test.py +0 -77
- clearskies_aws/actions/sqs.py +0 -82
- clearskies_aws/actions/sqs_test.py +0 -127
- clearskies_aws/actions/step_function.py +0 -66
- clearskies_aws/actions/step_function_test.py +0 -103
- clearskies_aws/backends/__init__.py +0 -12
- clearskies_aws/backends/dynamo_db_backend.py +0 -614
- clearskies_aws/backends/dynamo_db_backend_test.py +0 -300
- clearskies_aws/backends/dynamo_db_condition_parser.py +0 -365
- clearskies_aws/backends/dynamo_db_condition_parser_test.py +0 -266
- clearskies_aws/backends/dynamo_db_parti_ql_backend.py +0 -1123
- clearskies_aws/backends/dynamo_db_parti_ql_backend_test.py +0 -544
- clearskies_aws/backends/sqs_backend.py +0 -80
- clearskies_aws/backends/sqs_backend_test.py +0 -31
- clearskies_aws/contexts/__init__.py +0 -10
- clearskies_aws/contexts/cli.py +0 -19
- clearskies_aws/contexts/cli_websocket_mock.py +0 -33
- clearskies_aws/contexts/lambda_api_gateway.py +0 -30
- clearskies_aws/contexts/lambda_api_gateway_web_socket.py +0 -30
- clearskies_aws/contexts/lambda_elb.py +0 -30
- clearskies_aws/contexts/lambda_http_gateway.py +0 -30
- clearskies_aws/contexts/lambda_invocation.py +0 -48
- clearskies_aws/contexts/lambda_sns.py +0 -43
- clearskies_aws/contexts/lambda_sqs_standard_partial_batch.py +0 -51
- clearskies_aws/contexts/lambda_sqs_standard_partial_batch_test.py +0 -66
- clearskies_aws/contexts/wsgi.py +0 -19
- clearskies_aws/di/__init__.py +0 -1
- clearskies_aws/di/standard_dependencies.py +0 -60
- clearskies_aws/handlers/__init__.py +0 -2
- clearskies_aws/handlers/secrets_manager_rotation.py +0 -174
- clearskies_aws/handlers/simple_body_routing.py +0 -39
- clearskies_aws/input_outputs/__init__.py +0 -8
- clearskies_aws/input_outputs/cli_websocket_mock.py +0 -12
- clearskies_aws/input_outputs/lambda_api_gateway.py +0 -105
- clearskies_aws/input_outputs/lambda_api_gateway_test.py +0 -87
- clearskies_aws/input_outputs/lambda_api_gateway_web_socket.py +0 -8
- clearskies_aws/input_outputs/lambda_elb.py +0 -21
- clearskies_aws/input_outputs/lambda_http_gateway.py +0 -12
- clearskies_aws/input_outputs/lambda_invocation.py +0 -34
- clearskies_aws/input_outputs/lambda_sns.py +0 -52
- clearskies_aws/input_outputs/lambda_sqs_standard.py +0 -54
- clearskies_aws/mocks/__init__.py +0 -1
- clearskies_aws/mocks/actions/__init__.py +0 -6
- clearskies_aws/mocks/actions/ses.py +0 -28
- clearskies_aws/mocks/actions/sns.py +0 -23
- clearskies_aws/mocks/actions/sqs.py +0 -23
- clearskies_aws/mocks/actions/step_function.py +0 -26
- clearskies_aws/secrets/__init__.py +0 -7
- clearskies_aws/secrets/additional_configs/__init__.py +0 -54
- clearskies_aws/secrets/additional_configs/iam_db_auth.py +0 -29
- clearskies_aws/secrets/additional_configs/iam_db_auth_with_ssm.py +0 -92
- clearskies_aws/secrets/additional_configs/mysql_connection_dynamic_producer_via_ssh_cert_bastion.py +0 -81
- clearskies_aws/secrets/additional_configs/mysql_connection_dynamic_producer_via_ssm_bastion.py +0 -141
- clearskies_aws/secrets/akeyless_with_ssm_cache.py +0 -46
- clearskies_aws/secrets/parameter_store.py +0 -50
- clearskies_aws/secrets/parameter_store_test.py +0 -18
- clearskies_aws/secrets/secrets_manager.py +0 -75
- clearskies_aws/secrets/secrets_manager_test.py +0 -18
- clearskies_aws/web_socket_connection_model.py +0 -43
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
import unittest
|
|
2
|
-
from unittest.mock import MagicMock, call
|
|
3
|
-
from .sqs import SQS
|
|
4
|
-
import clearskies
|
|
5
|
-
from ..di import StandardDependencies
|
|
6
|
-
import json
|
|
7
|
-
from collections import OrderedDict
|
|
8
|
-
class User(clearskies.Model):
|
|
9
|
-
def __init__(self, memory_backend, columns):
|
|
10
|
-
super().__init__(memory_backend, columns)
|
|
11
|
-
|
|
12
|
-
def columns_configuration(self):
|
|
13
|
-
return OrderedDict([
|
|
14
|
-
clearskies.column_types.string('name'),
|
|
15
|
-
clearskies.column_types.email('email'),
|
|
16
|
-
])
|
|
17
|
-
class SQSTest(unittest.TestCase):
|
|
18
|
-
def setUp(self):
|
|
19
|
-
self.di = StandardDependencies()
|
|
20
|
-
self.di.bind('environment', {'AWS_REGION': 'us-east-2'})
|
|
21
|
-
self.users = self.di.build(User)
|
|
22
|
-
self.sqs = MagicMock()
|
|
23
|
-
self.sqs.send_message = MagicMock()
|
|
24
|
-
self.boto3 = MagicMock()
|
|
25
|
-
self.boto3.client = MagicMock(return_value=self.sqs)
|
|
26
|
-
self.when = None
|
|
27
|
-
self.environment = MagicMock()
|
|
28
|
-
self.environment.get = MagicMock(return_value='us-east-1')
|
|
29
|
-
|
|
30
|
-
def always(self, model):
|
|
31
|
-
self.when = model
|
|
32
|
-
return True
|
|
33
|
-
|
|
34
|
-
def never(self, model):
|
|
35
|
-
self.when = model
|
|
36
|
-
return False
|
|
37
|
-
|
|
38
|
-
def test_send(self):
|
|
39
|
-
sqs = SQS(self.environment, self.boto3, self.di)
|
|
40
|
-
sqs.configure(
|
|
41
|
-
queue_url='https://queue.example.com',
|
|
42
|
-
when=self.always,
|
|
43
|
-
)
|
|
44
|
-
user = self.users.model({
|
|
45
|
-
"id": "1-2-3-4",
|
|
46
|
-
"name": "Jane",
|
|
47
|
-
"email": "jane@example.com",
|
|
48
|
-
})
|
|
49
|
-
sqs(user)
|
|
50
|
-
self.sqs.send_message.assert_has_calls([
|
|
51
|
-
call(
|
|
52
|
-
QueueUrl='https://queue.example.com',
|
|
53
|
-
MessageBody=json.dumps({
|
|
54
|
-
"id": "1-2-3-4",
|
|
55
|
-
"name": "Jane",
|
|
56
|
-
"email": "jane@example.com",
|
|
57
|
-
}),
|
|
58
|
-
),
|
|
59
|
-
])
|
|
60
|
-
self.assertEqual(id(user), id(self.when))
|
|
61
|
-
|
|
62
|
-
def test_send_message_group_id(self):
|
|
63
|
-
sqs = SQS(self.environment, self.boto3, self.di)
|
|
64
|
-
sqs.configure(
|
|
65
|
-
queue_url='https://queue.example.com',
|
|
66
|
-
when=self.always,
|
|
67
|
-
message_group_id='heysup',
|
|
68
|
-
)
|
|
69
|
-
user = self.users.model({
|
|
70
|
-
"id": "1-2-3-4",
|
|
71
|
-
"name": "Jane",
|
|
72
|
-
"email": "jane@example.com",
|
|
73
|
-
})
|
|
74
|
-
sqs(user)
|
|
75
|
-
self.sqs.send_message.assert_has_calls([
|
|
76
|
-
call(
|
|
77
|
-
QueueUrl='https://queue.example.com',
|
|
78
|
-
MessageGroupId='heysup',
|
|
79
|
-
MessageBody=json.dumps({
|
|
80
|
-
"id": "1-2-3-4",
|
|
81
|
-
"name": "Jane",
|
|
82
|
-
"email": "jane@example.com",
|
|
83
|
-
}),
|
|
84
|
-
),
|
|
85
|
-
])
|
|
86
|
-
self.assertEqual(id(user), id(self.when))
|
|
87
|
-
|
|
88
|
-
def test_send_message_group_id_callable(self):
|
|
89
|
-
sqs = SQS(self.environment, self.boto3, self.di)
|
|
90
|
-
sqs.configure(
|
|
91
|
-
queue_url='https://queue.example.com',
|
|
92
|
-
when=self.always,
|
|
93
|
-
message_group_id=lambda model: model.id,
|
|
94
|
-
)
|
|
95
|
-
user = self.users.model({
|
|
96
|
-
"id": "1-2-3-4",
|
|
97
|
-
"name": "Jane",
|
|
98
|
-
"email": "jane@example.com",
|
|
99
|
-
})
|
|
100
|
-
sqs(user)
|
|
101
|
-
self.sqs.send_message.assert_has_calls([
|
|
102
|
-
call(
|
|
103
|
-
QueueUrl='https://queue.example.com',
|
|
104
|
-
MessageGroupId='1-2-3-4',
|
|
105
|
-
MessageBody=json.dumps({
|
|
106
|
-
"id": "1-2-3-4",
|
|
107
|
-
"name": "Jane",
|
|
108
|
-
"email": "jane@example.com",
|
|
109
|
-
}),
|
|
110
|
-
),
|
|
111
|
-
])
|
|
112
|
-
self.assertEqual(id(user), id(self.when))
|
|
113
|
-
|
|
114
|
-
def test_not_now(self):
|
|
115
|
-
sqs = SQS(self.environment, self.boto3, self.di)
|
|
116
|
-
sqs.configure(
|
|
117
|
-
queue_url='https://queue.example.com',
|
|
118
|
-
when=self.never,
|
|
119
|
-
)
|
|
120
|
-
user = self.users.model({
|
|
121
|
-
"id": "1-2-3-4",
|
|
122
|
-
"name": "Jane",
|
|
123
|
-
"email": "jane@example.com",
|
|
124
|
-
})
|
|
125
|
-
sqs(user)
|
|
126
|
-
self.sqs.send_message.assert_not_called()
|
|
127
|
-
self.assertEqual(id(user), id(self.when))
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import boto3
|
|
2
|
-
|
|
3
|
-
from clearskies.environment import Environment
|
|
4
|
-
from clearskies.models import Models
|
|
5
|
-
from types import ModuleType
|
|
6
|
-
from typing import List, Optional, Callable, cast
|
|
7
|
-
|
|
8
|
-
from ..di import StandardDependencies
|
|
9
|
-
from .assume_role import AssumeRole
|
|
10
|
-
from .action_aws import ActionAws
|
|
11
|
-
class StepFunction(ActionAws):
|
|
12
|
-
_name = "stepfunctions"
|
|
13
|
-
|
|
14
|
-
def __init__(self, environment: Environment, boto3: boto3, di: StandardDependencies) -> None:
|
|
15
|
-
super().__init__(environment, boto3, di)
|
|
16
|
-
|
|
17
|
-
def configure(
|
|
18
|
-
self,
|
|
19
|
-
arn: Optional[str]=None,
|
|
20
|
-
arn_environment_key: Optional[str] = None,
|
|
21
|
-
arn_callable: Optional[Callable] = None,
|
|
22
|
-
column_to_store_execution_arn: Optional[str] = None,
|
|
23
|
-
message_callable: Optional[Callable] = None,
|
|
24
|
-
when: Optional[Callable] = None,
|
|
25
|
-
assume_role: Optional[AssumeRole] = None,
|
|
26
|
-
) -> None:
|
|
27
|
-
"""Configures the action for the step function."""
|
|
28
|
-
super().configure(message_callable=message_callable, when=when, assume_role=assume_role)
|
|
29
|
-
|
|
30
|
-
self.arn = arn
|
|
31
|
-
self.arn_environment_key = arn_environment_key
|
|
32
|
-
self.arn_callable = arn_callable
|
|
33
|
-
self.column_to_store_execution_arn = column_to_store_execution_arn
|
|
34
|
-
|
|
35
|
-
arns = 0
|
|
36
|
-
for value in [arn, arn_environment_key, arn_callable]:
|
|
37
|
-
if value:
|
|
38
|
-
arns += 1
|
|
39
|
-
if arns > 1:
|
|
40
|
-
raise ValueError(
|
|
41
|
-
"You can only provide one of 'arn', 'arn_environment_key', or 'arn_callable', but more than one was provided."
|
|
42
|
-
)
|
|
43
|
-
if not arns:
|
|
44
|
-
raise ValueError("You must provide at least one of 'arn', 'arn_environment_key', or 'arn_callable'.")
|
|
45
|
-
|
|
46
|
-
def _execute_action(self, client: ModuleType, model: Models) -> None:
|
|
47
|
-
"""Send a notification as configured."""
|
|
48
|
-
arn = self.get_arn(model)
|
|
49
|
-
default_region = self.default_region()
|
|
50
|
-
arn_region = arn.split(':')[3]
|
|
51
|
-
if default_region and default_region != arn_region:
|
|
52
|
-
client = self._getClient(region=arn_region)
|
|
53
|
-
response = client.start_execution(
|
|
54
|
-
stateMachineArn=self.get_arn(model),
|
|
55
|
-
input=self.get_message_body(model),
|
|
56
|
-
)
|
|
57
|
-
|
|
58
|
-
if self.column_to_store_execution_arn:
|
|
59
|
-
model.save({self.column_to_store_execution_arn: response['executionArn']})
|
|
60
|
-
|
|
61
|
-
def get_arn(self, model: Models) -> str:
|
|
62
|
-
if self.arn:
|
|
63
|
-
return self.arn
|
|
64
|
-
if self.arn_environment_key:
|
|
65
|
-
return self.environment.get(self.arn_environment_key)
|
|
66
|
-
return self.di.call_function(self.arn_callable, model=model)
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import unittest
|
|
2
|
-
from unittest.mock import MagicMock, call
|
|
3
|
-
from .step_function import StepFunction
|
|
4
|
-
import clearskies
|
|
5
|
-
from ..di import StandardDependencies
|
|
6
|
-
import json
|
|
7
|
-
from collections import OrderedDict
|
|
8
|
-
class User(clearskies.Model):
|
|
9
|
-
def __init__(self, memory_backend, columns):
|
|
10
|
-
super().__init__(memory_backend, columns)
|
|
11
|
-
|
|
12
|
-
def columns_configuration(self):
|
|
13
|
-
return OrderedDict([
|
|
14
|
-
clearskies.column_types.email('email'),
|
|
15
|
-
clearskies.column_types.string('execution_arn'),
|
|
16
|
-
])
|
|
17
|
-
class StepFunctionTest(unittest.TestCase):
|
|
18
|
-
def setUp(self):
|
|
19
|
-
self.di = StandardDependencies()
|
|
20
|
-
self.di.bind('environment', {'AWS_REGION': 'us-east-2'})
|
|
21
|
-
memory_backend = self.di.build("memory_backend")
|
|
22
|
-
self.users = self.di.build(User)
|
|
23
|
-
self.user = self.users.create({
|
|
24
|
-
"id": "1-2-3-4",
|
|
25
|
-
"email": "blah@example.com",
|
|
26
|
-
})
|
|
27
|
-
self.step_function = MagicMock()
|
|
28
|
-
self.step_function.start_execution = MagicMock(return_value={"executionArn":"aws:arn:execution"})
|
|
29
|
-
self.boto3 = MagicMock()
|
|
30
|
-
self.boto3.client = MagicMock(return_value=self.step_function)
|
|
31
|
-
self.when = None
|
|
32
|
-
self.environment = MagicMock()
|
|
33
|
-
self.environment.get = MagicMock(return_value='us-east-2')
|
|
34
|
-
|
|
35
|
-
def always(self, model):
|
|
36
|
-
self.when = model
|
|
37
|
-
return True
|
|
38
|
-
|
|
39
|
-
def never(self, model):
|
|
40
|
-
self.when = model
|
|
41
|
-
return False
|
|
42
|
-
|
|
43
|
-
def test_execute(self):
|
|
44
|
-
step_function = StepFunction(self.environment, self.boto3, self.di)
|
|
45
|
-
step_function.configure(
|
|
46
|
-
arn='aws::arn:us-east-2:step/asdf-er',
|
|
47
|
-
when=self.always,
|
|
48
|
-
column_to_store_execution_arn="execution_arn",
|
|
49
|
-
)
|
|
50
|
-
step_function(self.user)
|
|
51
|
-
self.step_function.start_execution.assert_has_calls([
|
|
52
|
-
call(
|
|
53
|
-
stateMachineArn='aws::arn:us-east-2:step/asdf-er',
|
|
54
|
-
input=json.dumps({
|
|
55
|
-
"id": self.user.id,
|
|
56
|
-
"email": self.user.email,
|
|
57
|
-
"execution_arn": None,
|
|
58
|
-
}),
|
|
59
|
-
),
|
|
60
|
-
])
|
|
61
|
-
self.assertEqual(id(self.user), id(self.when))
|
|
62
|
-
self.assertEqual("aws:arn:execution", self.user.execution_arn)
|
|
63
|
-
|
|
64
|
-
def test_region_switch(self):
|
|
65
|
-
self.boto3.client.side_effect = [self.step_function, self.step_function]
|
|
66
|
-
step_function = StepFunction(self.environment, self.boto3, self.di)
|
|
67
|
-
step_function.configure(
|
|
68
|
-
arn='aws::arn:eu-west-1:step/asdf-er',
|
|
69
|
-
when=self.always,
|
|
70
|
-
column_to_store_execution_arn="execution_arn",
|
|
71
|
-
)
|
|
72
|
-
step_function(self.user)
|
|
73
|
-
self.step_function.start_execution.assert_has_calls([
|
|
74
|
-
call(
|
|
75
|
-
stateMachineArn='aws::arn:eu-west-1:step/asdf-er',
|
|
76
|
-
input=json.dumps({
|
|
77
|
-
"id": self.user.id,
|
|
78
|
-
"email": self.user.email,
|
|
79
|
-
"execution_arn": None,
|
|
80
|
-
}),
|
|
81
|
-
),
|
|
82
|
-
])
|
|
83
|
-
self.assertEqual(id(self.user), id(self.when))
|
|
84
|
-
self.assertEqual("aws:arn:execution", self.user.execution_arn)
|
|
85
|
-
self.boto3.client.assert_has_calls([
|
|
86
|
-
call("stepfunctions", region_name="us-east-2"),
|
|
87
|
-
call("stepfunctions", region_name="eu-west-1"),
|
|
88
|
-
])
|
|
89
|
-
|
|
90
|
-
def test_not_now(self):
|
|
91
|
-
step_function = StepFunction(self.environment, self.boto3, self.di)
|
|
92
|
-
step_function.configure(
|
|
93
|
-
arn='aws::arn:us-east-2:step-function/asdf-er',
|
|
94
|
-
when=self.never,
|
|
95
|
-
)
|
|
96
|
-
user = self.users.model({
|
|
97
|
-
"id": "1-2-3-4",
|
|
98
|
-
"name": "Jane",
|
|
99
|
-
"email": "jane@example.com",
|
|
100
|
-
})
|
|
101
|
-
step_function(user)
|
|
102
|
-
self.step_function.start_execution.assert_not_called()
|
|
103
|
-
self.assertEqual(id(user), id(self.when))
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
from .dynamo_db_backend import DynamoDBBackend
|
|
2
|
-
from .dynamo_db_parti_ql_backend import DynamoDBPartiQLBackend, DynamoDBPartiQLCursor
|
|
3
|
-
from .dynamo_db_condition_parser import DynamoDBConditionParser
|
|
4
|
-
from .sqs_backend import SqsBackend
|
|
5
|
-
|
|
6
|
-
__all__ = [
|
|
7
|
-
"DynamoDBBackend",
|
|
8
|
-
"SqsBackend",
|
|
9
|
-
"DynamoDBPartiQLBackend",
|
|
10
|
-
"DynamoDBPartiQLCursor",
|
|
11
|
-
"DynamoDBConditionParser",
|
|
12
|
-
]
|