clear-skies-aws 1.9.14__tar.gz → 1.9.15__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 (74) hide show
  1. {clear_skies_aws-1.9.14 → clear_skies_aws-1.9.15}/PKG-INFO +1 -1
  2. {clear_skies_aws-1.9.14 → clear_skies_aws-1.9.15}/pyproject.toml +1 -1
  3. {clear_skies_aws-1.9.14 → clear_skies_aws-1.9.15}/src/clearskies_aws/actions/action_aws.py +20 -6
  4. {clear_skies_aws-1.9.14 → clear_skies_aws-1.9.15}/src/clearskies_aws/actions/step_function.py +5 -0
  5. {clear_skies_aws-1.9.14 → clear_skies_aws-1.9.15}/src/clearskies_aws/actions/step_function_test.py +30 -4
  6. {clear_skies_aws-1.9.14 → clear_skies_aws-1.9.15}/LICENSE +0 -0
  7. {clear_skies_aws-1.9.14 → clear_skies_aws-1.9.15}/README.md +0 -0
  8. {clear_skies_aws-1.9.14 → clear_skies_aws-1.9.15}/src/clearskies_aws/__init__.py +0 -0
  9. {clear_skies_aws-1.9.14 → clear_skies_aws-1.9.15}/src/clearskies_aws/actions/__init__.py +0 -0
  10. {clear_skies_aws-1.9.14 → clear_skies_aws-1.9.15}/src/clearskies_aws/actions/assume_role.py +0 -0
  11. {clear_skies_aws-1.9.14 → clear_skies_aws-1.9.15}/src/clearskies_aws/actions/assume_role_test.py +0 -0
  12. {clear_skies_aws-1.9.14 → clear_skies_aws-1.9.15}/src/clearskies_aws/actions/ses.py +0 -0
  13. {clear_skies_aws-1.9.14 → clear_skies_aws-1.9.15}/src/clearskies_aws/actions/ses_test.py +0 -0
  14. {clear_skies_aws-1.9.14 → clear_skies_aws-1.9.15}/src/clearskies_aws/actions/sns.py +0 -0
  15. {clear_skies_aws-1.9.14 → clear_skies_aws-1.9.15}/src/clearskies_aws/actions/sns_test.py +0 -0
  16. {clear_skies_aws-1.9.14 → clear_skies_aws-1.9.15}/src/clearskies_aws/actions/sqs.py +0 -0
  17. {clear_skies_aws-1.9.14 → clear_skies_aws-1.9.15}/src/clearskies_aws/actions/sqs_test.py +0 -0
  18. {clear_skies_aws-1.9.14 → clear_skies_aws-1.9.15}/src/clearskies_aws/backends/__init__.py +0 -0
  19. {clear_skies_aws-1.9.14 → clear_skies_aws-1.9.15}/src/clearskies_aws/backends/dynamo_db_backend.py +0 -0
  20. {clear_skies_aws-1.9.14 → clear_skies_aws-1.9.15}/src/clearskies_aws/backends/dynamo_db_backend_test.py +0 -0
  21. {clear_skies_aws-1.9.14 → clear_skies_aws-1.9.15}/src/clearskies_aws/backends/sqs_backend.py +0 -0
  22. {clear_skies_aws-1.9.14 → clear_skies_aws-1.9.15}/src/clearskies_aws/backends/sqs_backend_test.py +0 -0
  23. {clear_skies_aws-1.9.14 → clear_skies_aws-1.9.15}/src/clearskies_aws/contexts/__init__.py +0 -0
  24. {clear_skies_aws-1.9.14 → clear_skies_aws-1.9.15}/src/clearskies_aws/contexts/__pycache__/aws_http_api_gateway.cpython-38.pyc +0 -0
  25. {clear_skies_aws-1.9.14 → clear_skies_aws-1.9.15}/src/clearskies_aws/contexts/__pycache__/aws_lambda_api_gateway.cpython-38.pyc +0 -0
  26. {clear_skies_aws-1.9.14 → clear_skies_aws-1.9.15}/src/clearskies_aws/contexts/__pycache__/aws_lambda_elb.cpython-38.pyc +0 -0
  27. {clear_skies_aws-1.9.14 → clear_skies_aws-1.9.15}/src/clearskies_aws/contexts/cli.py +0 -0
  28. {clear_skies_aws-1.9.14 → clear_skies_aws-1.9.15}/src/clearskies_aws/contexts/cli_websocket_mock.py +0 -0
  29. {clear_skies_aws-1.9.14 → clear_skies_aws-1.9.15}/src/clearskies_aws/contexts/lambda_api_gateway.py +0 -0
  30. {clear_skies_aws-1.9.14 → clear_skies_aws-1.9.15}/src/clearskies_aws/contexts/lambda_api_gateway_web_socket.py +0 -0
  31. {clear_skies_aws-1.9.14 → clear_skies_aws-1.9.15}/src/clearskies_aws/contexts/lambda_elb.py +0 -0
  32. {clear_skies_aws-1.9.14 → clear_skies_aws-1.9.15}/src/clearskies_aws/contexts/lambda_http_gateway.py +0 -0
  33. {clear_skies_aws-1.9.14 → clear_skies_aws-1.9.15}/src/clearskies_aws/contexts/lambda_invocation.py +0 -0
  34. {clear_skies_aws-1.9.14 → clear_skies_aws-1.9.15}/src/clearskies_aws/contexts/lambda_sns.py +0 -0
  35. {clear_skies_aws-1.9.14 → clear_skies_aws-1.9.15}/src/clearskies_aws/contexts/lambda_sqs_standard_partial_batch.py +0 -0
  36. {clear_skies_aws-1.9.14 → clear_skies_aws-1.9.15}/src/clearskies_aws/contexts/lambda_sqs_standard_partial_batch_test.py +0 -0
  37. {clear_skies_aws-1.9.14 → clear_skies_aws-1.9.15}/src/clearskies_aws/contexts/wsgi.py +0 -0
  38. {clear_skies_aws-1.9.14 → clear_skies_aws-1.9.15}/src/clearskies_aws/di/__init__.py +0 -0
  39. {clear_skies_aws-1.9.14 → clear_skies_aws-1.9.15}/src/clearskies_aws/di/standard_dependencies.py +0 -0
  40. {clear_skies_aws-1.9.14 → clear_skies_aws-1.9.15}/src/clearskies_aws/handlers/__init__.py +0 -0
  41. {clear_skies_aws-1.9.14 → clear_skies_aws-1.9.15}/src/clearskies_aws/handlers/secrets_manager_rotation.py +0 -0
  42. {clear_skies_aws-1.9.14 → clear_skies_aws-1.9.15}/src/clearskies_aws/handlers/simple_body_routing.py +0 -0
  43. {clear_skies_aws-1.9.14 → clear_skies_aws-1.9.15}/src/clearskies_aws/input_outputs/__init__.py +0 -0
  44. {clear_skies_aws-1.9.14 → clear_skies_aws-1.9.15}/src/clearskies_aws/input_outputs/__pycache__/aws_http_api_gateway.cpython-38.pyc +0 -0
  45. {clear_skies_aws-1.9.14 → clear_skies_aws-1.9.15}/src/clearskies_aws/input_outputs/__pycache__/aws_lambda_api_gateway.cpython-38.pyc +0 -0
  46. {clear_skies_aws-1.9.14 → clear_skies_aws-1.9.15}/src/clearskies_aws/input_outputs/__pycache__/aws_lambda_api_gateway_test.cpython-38.pyc +0 -0
  47. {clear_skies_aws-1.9.14 → clear_skies_aws-1.9.15}/src/clearskies_aws/input_outputs/__pycache__/aws_lambda_elb.cpython-38.pyc +0 -0
  48. {clear_skies_aws-1.9.14 → clear_skies_aws-1.9.15}/src/clearskies_aws/input_outputs/cli_websocket_mock.py +0 -0
  49. {clear_skies_aws-1.9.14 → clear_skies_aws-1.9.15}/src/clearskies_aws/input_outputs/lambda_api_gateway.py +0 -0
  50. {clear_skies_aws-1.9.14 → clear_skies_aws-1.9.15}/src/clearskies_aws/input_outputs/lambda_api_gateway_test.py +0 -0
  51. {clear_skies_aws-1.9.14 → clear_skies_aws-1.9.15}/src/clearskies_aws/input_outputs/lambda_api_gateway_web_socket.py +0 -0
  52. {clear_skies_aws-1.9.14 → clear_skies_aws-1.9.15}/src/clearskies_aws/input_outputs/lambda_elb.py +0 -0
  53. {clear_skies_aws-1.9.14 → clear_skies_aws-1.9.15}/src/clearskies_aws/input_outputs/lambda_http_gateway.py +0 -0
  54. {clear_skies_aws-1.9.14 → clear_skies_aws-1.9.15}/src/clearskies_aws/input_outputs/lambda_invocation.py +0 -0
  55. {clear_skies_aws-1.9.14 → clear_skies_aws-1.9.15}/src/clearskies_aws/input_outputs/lambda_sns.py +0 -0
  56. {clear_skies_aws-1.9.14 → clear_skies_aws-1.9.15}/src/clearskies_aws/input_outputs/lambda_sqs_standard.py +0 -0
  57. {clear_skies_aws-1.9.14 → clear_skies_aws-1.9.15}/src/clearskies_aws/mocks/__init__.py +0 -0
  58. {clear_skies_aws-1.9.14 → clear_skies_aws-1.9.15}/src/clearskies_aws/mocks/actions/__init__.py +0 -0
  59. {clear_skies_aws-1.9.14 → clear_skies_aws-1.9.15}/src/clearskies_aws/mocks/actions/ses.py +0 -0
  60. {clear_skies_aws-1.9.14 → clear_skies_aws-1.9.15}/src/clearskies_aws/mocks/actions/sns.py +0 -0
  61. {clear_skies_aws-1.9.14 → clear_skies_aws-1.9.15}/src/clearskies_aws/mocks/actions/sqs.py +0 -0
  62. {clear_skies_aws-1.9.14 → clear_skies_aws-1.9.15}/src/clearskies_aws/mocks/actions/step_function.py +0 -0
  63. {clear_skies_aws-1.9.14 → clear_skies_aws-1.9.15}/src/clearskies_aws/secrets/__init__.py +0 -0
  64. {clear_skies_aws-1.9.14 → clear_skies_aws-1.9.15}/src/clearskies_aws/secrets/additional_configs/__init__.py +0 -0
  65. {clear_skies_aws-1.9.14 → clear_skies_aws-1.9.15}/src/clearskies_aws/secrets/additional_configs/iam_db_auth.py +0 -0
  66. {clear_skies_aws-1.9.14 → clear_skies_aws-1.9.15}/src/clearskies_aws/secrets/additional_configs/iam_db_auth_with_ssm.py +0 -0
  67. {clear_skies_aws-1.9.14 → clear_skies_aws-1.9.15}/src/clearskies_aws/secrets/additional_configs/mysql_connection_dynamic_producer_via_ssh_cert_bastion.py +0 -0
  68. {clear_skies_aws-1.9.14 → clear_skies_aws-1.9.15}/src/clearskies_aws/secrets/additional_configs/mysql_connection_dynamic_producer_via_ssm_bastion.py +0 -0
  69. {clear_skies_aws-1.9.14 → clear_skies_aws-1.9.15}/src/clearskies_aws/secrets/akeyless_with_ssm_cache.py +0 -0
  70. {clear_skies_aws-1.9.14 → clear_skies_aws-1.9.15}/src/clearskies_aws/secrets/parameter_store.py +0 -0
  71. {clear_skies_aws-1.9.14 → clear_skies_aws-1.9.15}/src/clearskies_aws/secrets/parameter_store_test.py +0 -0
  72. {clear_skies_aws-1.9.14 → clear_skies_aws-1.9.15}/src/clearskies_aws/secrets/secrets_manager.py +0 -0
  73. {clear_skies_aws-1.9.14 → clear_skies_aws-1.9.15}/src/clearskies_aws/secrets/secrets_manager_test.py +0 -0
  74. {clear_skies_aws-1.9.14 → clear_skies_aws-1.9.15}/src/clearskies_aws/web_socket_connection_model.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: clear-skies-aws
3
- Version: 1.9.14
3
+ Version: 1.9.15
4
4
  Summary: clearskies bindings for working in AWS
5
5
  Home-page: https://github.com/cmancone/clearskies-aws
6
6
  License: MIT
@@ -2,7 +2,7 @@
2
2
 
3
3
  [tool.poetry]
4
4
  name = "clear-skies-aws"
5
- version = "1.9.14"
5
+ version = "1.9.15"
6
6
  description = "clearskies bindings for working in AWS"
7
7
  authors = [
8
8
  "Conor Mancone <cmancone@gmail.com>",
@@ -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
- if self._client:
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
- region = self.environment.get('AWS_REGION', silent=True)
76
+ if not region:
77
+ region = self.default_region()
76
78
  if region:
77
- self._client = boto3.client(self._name, region_name=region)
79
+ client = boto3.client(self._name, region_name=region)
78
80
  else:
79
- self._client = boto3.client(self._name)
80
- return self._client
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-1')
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::step/asdf-er',
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::step/asdf-er',
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::aws:step-function/asdf-er',
93
+ arn='aws::arn:us-east-2:step-function/asdf-er',
68
94
  when=self.never,
69
95
  )
70
96
  user = self.users.model({