clear-skies-aws 1.9.13__py3-none-any.whl → 1.9.15__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.9.13.dist-info → clear_skies_aws-1.9.15.dist-info}/METADATA +1 -1
- {clear_skies_aws-1.9.13.dist-info → clear_skies_aws-1.9.15.dist-info}/RECORD +8 -8
- clearskies_aws/actions/action_aws.py +20 -6
- clearskies_aws/actions/step_function.py +5 -0
- clearskies_aws/actions/step_function_test.py +30 -4
- clearskies_aws/input_outputs/lambda_invocation.py +3 -1
- {clear_skies_aws-1.9.13.dist-info → clear_skies_aws-1.9.15.dist-info}/LICENSE +0 -0
- {clear_skies_aws-1.9.13.dist-info → clear_skies_aws-1.9.15.dist-info}/WHEEL +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
clearskies_aws/__init__.py,sha256=BZKL4SIyxx4MXpyP5hmwsMo2oJatyv5c2wjJOPzKBQ4,134
|
|
2
2
|
clearskies_aws/actions/__init__.py,sha256=w_IWJg4UHV9Opv69zheH7ZHj1BnCzYLlm2JhFvHQCf8,2998
|
|
3
|
-
clearskies_aws/actions/action_aws.py,sha256=
|
|
3
|
+
clearskies_aws/actions/action_aws.py,sha256=zBXsvhBDDm2dAU4MVlub84Ld1YNZ6ey8_zf4OeTe8go,4254
|
|
4
4
|
clearskies_aws/actions/assume_role.py,sha256=tZHKMTQaImj_EAWormFZdIPkR_db7yBwOJxYaUyuGdA,4085
|
|
5
5
|
clearskies_aws/actions/assume_role_test.py,sha256=MDMGePZLVyDNTjdAlGBDJzBlfMpGIpA3Q1Ur0qEPl1w,2450
|
|
6
6
|
clearskies_aws/actions/ses.py,sha256=xJ0NEFPP-8kARPGjDv1yf_bhAiaIIM1mDzMxY22GE5E,7925
|
|
@@ -9,8 +9,8 @@ clearskies_aws/actions/sns.py,sha256=00E-eCQuq3Ygscyia928K8jX8rhDZrl5kyasM0st_uI
|
|
|
9
9
|
clearskies_aws/actions/sns_test.py,sha256=iqlaZOA-0YHPOu52-XqpCIAgAv1JZodDdlm4YYYhj8U,2306
|
|
10
10
|
clearskies_aws/actions/sqs.py,sha256=i-QyyFy-ImivXk-m-Bn9Mh5BF5qODthUyZAQVRsb8vs,3392
|
|
11
11
|
clearskies_aws/actions/sqs_test.py,sha256=aazVN-bY6E17Pu3hDwLldj6YPirbqXjM6LfYFomUVmQ,4040
|
|
12
|
-
clearskies_aws/actions/step_function.py,sha256=
|
|
13
|
-
clearskies_aws/actions/step_function_test.py,sha256=
|
|
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
14
|
clearskies_aws/backends/__init__.py,sha256=kS6pmMKZuWzBefO7qQu1fkFdcXo180t76-a-pPc1YX8,83
|
|
15
15
|
clearskies_aws/backends/dynamo_db_backend.py,sha256=Ng8IORbYVSh6Sj-mjpret3qmdSeI1U9t3GJ1uUdaGd4,29574
|
|
16
16
|
clearskies_aws/backends/dynamo_db_backend_test.py,sha256=iAT8d5lOho8Kv70up7wkLuf2VJhdR7qdJ-TxHsupjQI,13150
|
|
@@ -40,7 +40,7 @@ clearskies_aws/input_outputs/lambda_api_gateway_test.py,sha256=1I8yV-WjKUKpoMZa2
|
|
|
40
40
|
clearskies_aws/input_outputs/lambda_api_gateway_web_socket.py,sha256=kG2fys9X7TailvlOBzIMItuSI8rlvDbBD4AXtI091hM,308
|
|
41
41
|
clearskies_aws/input_outputs/lambda_elb.py,sha256=b675h0DxTGo9YscXN4mwzRGzP3hNSie4iPRKOg3kKPI,750
|
|
42
42
|
clearskies_aws/input_outputs/lambda_http_gateway.py,sha256=YQk7GlQWtQjDiKWhX5jvXc3un1eq2sm1v_jl6iseNoQ,692
|
|
43
|
-
clearskies_aws/input_outputs/lambda_invocation.py,sha256=
|
|
43
|
+
clearskies_aws/input_outputs/lambda_invocation.py,sha256=yF3rYJ-r0YYzlh--33fGE-I-pzyhQxDmDo1TUQxCu00,1122
|
|
44
44
|
clearskies_aws/input_outputs/lambda_sns.py,sha256=t1iWH1OaOm23ZSQoKgS6l53FTExFziPVju3wf86D0WY,2266
|
|
45
45
|
clearskies_aws/input_outputs/lambda_sqs_standard.py,sha256=8UlYNi3DHZB9i8OXy8LsM13OIHtbOFxVh-LvyNN0yao,2185
|
|
46
46
|
clearskies_aws/mocks/__init__.py,sha256=mn764gINN667tYoJfnsM6HjAAhCsO_kZ6E-fUwdLY50,22
|
|
@@ -61,7 +61,7 @@ clearskies_aws/secrets/parameter_store_test.py,sha256=UyqKE4AZYlldj9ww5f0fR15qsV
|
|
|
61
61
|
clearskies_aws/secrets/secrets_manager.py,sha256=jlpfAFC23EeSpm50L8B-yrXg4IROQq-M_90zzXDp_ak,3056
|
|
62
62
|
clearskies_aws/secrets/secrets_manager_test.py,sha256=mlNWtDm1wWS5C8aV0vJAzZVZB82KFR6NGRAPEkLtTyk,786
|
|
63
63
|
clearskies_aws/web_socket_connection_model.py,sha256=d_Au_Pu7YXBfc7_lbuI7zz4MZ8ZOOwGM0oooppEofcI,1776
|
|
64
|
-
clear_skies_aws-1.9.
|
|
65
|
-
clear_skies_aws-1.9.
|
|
66
|
-
clear_skies_aws-1.9.
|
|
67
|
-
clear_skies_aws-1.9.
|
|
64
|
+
clear_skies_aws-1.9.15.dist-info/LICENSE,sha256=3Ehd0g3YOpCj8sqj0Xjq5qbOtjjgk9qzhhD9YjRQgOA,1053
|
|
65
|
+
clear_skies_aws-1.9.15.dist-info/METADATA,sha256=8HgfoQ9ZjijwkHbdR8y8NEwxrVBM71eIL4OU2gi5U1k,8583
|
|
66
|
+
clear_skies_aws-1.9.15.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
|
67
|
+
clear_skies_aws-1.9.15.dist-info/RECORD,,
|
|
@@ -62,9 +62,10 @@ class ActionAws(ABC):
|
|
|
62
62
|
self._logging.exception(f"Failed to retrieve client for {self._name}")
|
|
63
63
|
raise e
|
|
64
64
|
|
|
65
|
-
def _getClient(self) -> boto3.client:
|
|
65
|
+
def _getClient(self, region=None) -> boto3.client:
|
|
66
66
|
"""Retrieve the boto3 client."""
|
|
67
|
-
|
|
67
|
+
can_cache = not region
|
|
68
|
+
if self._client and can_cache:
|
|
68
69
|
return self._client
|
|
69
70
|
|
|
70
71
|
if self.assume_role:
|
|
@@ -72,12 +73,25 @@ class ActionAws(ABC):
|
|
|
72
73
|
else:
|
|
73
74
|
boto3 = self.boto3
|
|
74
75
|
|
|
75
|
-
|
|
76
|
+
if not region:
|
|
77
|
+
region = self.default_region()
|
|
76
78
|
if region:
|
|
77
|
-
|
|
79
|
+
client = boto3.client(self._name, region_name=region)
|
|
78
80
|
else:
|
|
79
|
-
|
|
80
|
-
|
|
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
|
|
81
95
|
|
|
82
96
|
def _execute_action(self, client: boto3.client, model: Models) -> None:
|
|
83
97
|
"""Run the action."""
|
|
@@ -45,6 +45,11 @@ class StepFunction(ActionAws):
|
|
|
45
45
|
|
|
46
46
|
def _execute_action(self, client: ModuleType, model: Models) -> None:
|
|
47
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)
|
|
48
53
|
response = client.start_execution(
|
|
49
54
|
stateMachineArn=self.get_arn(model),
|
|
50
55
|
input=self.get_message_body(model),
|
|
@@ -30,7 +30,7 @@ class StepFunctionTest(unittest.TestCase):
|
|
|
30
30
|
self.boto3.client = MagicMock(return_value=self.step_function)
|
|
31
31
|
self.when = None
|
|
32
32
|
self.environment = MagicMock()
|
|
33
|
-
self.environment.get = MagicMock(return_value='us-east-
|
|
33
|
+
self.environment.get = MagicMock(return_value='us-east-2')
|
|
34
34
|
|
|
35
35
|
def always(self, model):
|
|
36
36
|
self.when = model
|
|
@@ -43,14 +43,14 @@ class StepFunctionTest(unittest.TestCase):
|
|
|
43
43
|
def test_execute(self):
|
|
44
44
|
step_function = StepFunction(self.environment, self.boto3, self.di)
|
|
45
45
|
step_function.configure(
|
|
46
|
-
arn='aws::arn
|
|
46
|
+
arn='aws::arn:us-east-2:step/asdf-er',
|
|
47
47
|
when=self.always,
|
|
48
48
|
column_to_store_execution_arn="execution_arn",
|
|
49
49
|
)
|
|
50
50
|
step_function(self.user)
|
|
51
51
|
self.step_function.start_execution.assert_has_calls([
|
|
52
52
|
call(
|
|
53
|
-
stateMachineArn='aws::arn
|
|
53
|
+
stateMachineArn='aws::arn:us-east-2:step/asdf-er',
|
|
54
54
|
input=json.dumps({
|
|
55
55
|
"id": self.user.id,
|
|
56
56
|
"email": self.user.email,
|
|
@@ -61,10 +61,36 @@ class StepFunctionTest(unittest.TestCase):
|
|
|
61
61
|
self.assertEqual(id(self.user), id(self.when))
|
|
62
62
|
self.assertEqual("aws:arn:execution", self.user.execution_arn)
|
|
63
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
|
+
|
|
64
90
|
def test_not_now(self):
|
|
65
91
|
step_function = StepFunction(self.environment, self.boto3, self.di)
|
|
66
92
|
step_function.configure(
|
|
67
|
-
arn='arn
|
|
93
|
+
arn='aws::arn:us-east-2:step-function/asdf-er',
|
|
68
94
|
when=self.never,
|
|
69
95
|
)
|
|
70
96
|
user = self.users.model({
|
|
@@ -23,7 +23,9 @@ class LambdaInvocation(LambdaAPIGateway):
|
|
|
23
23
|
def get_body(self):
|
|
24
24
|
return self._event
|
|
25
25
|
|
|
26
|
-
def json_body(self, required=True):
|
|
26
|
+
def json_body(self, required=True, allow_non_json_bodies=False):
|
|
27
|
+
# we ignore the allow_non_json_bodies flag here because with the way invoking lambdas works,
|
|
28
|
+
# the event already is an object, so it's a moot point.
|
|
27
29
|
if required and not self._event:
|
|
28
30
|
raise ClientError("Request body was not valid JSON")
|
|
29
31
|
return self._event
|
|
File without changes
|
|
File without changes
|