boto3-assist 0.1.2__tar.gz → 0.1.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 (75) hide show
  1. {boto3_assist-0.1.2 → boto3_assist-0.1.4}/PKG-INFO +1 -1
  2. boto3_assist-0.1.4/aws_regions_with_status.csv +31 -0
  3. boto3_assist-0.1.4/aws_regions_with_status.json +122 -0
  4. boto3_assist-0.1.4/examples/ec2/regions_report.py +80 -0
  5. {boto3_assist-0.1.2 → boto3_assist-0.1.4}/pyproject.toml +1 -1
  6. {boto3_assist-0.1.2 → boto3_assist-0.1.4}/requirements-dev.txt +1 -0
  7. boto3_assist-0.1.4/src/boto3_assist/connection_tracker.py +47 -0
  8. {boto3_assist-0.1.2 → boto3_assist-0.1.4}/src/boto3_assist/dynamodb/dynamodb.py +2 -0
  9. {boto3_assist-0.1.2 → boto3_assist-0.1.4}/src/boto3_assist/dynamodb/dynamodb_model_base.py +8 -0
  10. boto3_assist-0.1.4/src/boto3_assist/ec2/ec2_connection.py +103 -0
  11. {boto3_assist-0.1.2 → boto3_assist-0.1.4}/src/boto3_assist/environment_services/environment_variables.py +16 -0
  12. boto3_assist-0.1.4/src/boto3_assist/version.py +1 -0
  13. boto3_assist-0.1.2/src/boto3_assist/version.py +0 -1
  14. {boto3_assist-0.1.2 → boto3_assist-0.1.4}/.env.development +0 -0
  15. {boto3_assist-0.1.2 → boto3_assist-0.1.4}/.env.docker +0 -0
  16. {boto3_assist-0.1.2 → boto3_assist-0.1.4}/.env.docker.001 +0 -0
  17. {boto3_assist-0.1.2 → boto3_assist-0.1.4}/.env.docker.nosql.workbench +0 -0
  18. {boto3_assist-0.1.2 → boto3_assist-0.1.4}/.gitignore +0 -0
  19. {boto3_assist-0.1.2 → boto3_assist-0.1.4}/.vscode/launch.json +0 -0
  20. {boto3_assist-0.1.2 → boto3_assist-0.1.4}/.vscode/settings.json +0 -0
  21. {boto3_assist-0.1.2 → boto3_assist-0.1.4}/.vscode/tasks.json +0 -0
  22. {boto3_assist-0.1.2 → boto3_assist-0.1.4}/LICENSE-EXPLAINED.txt +0 -0
  23. {boto3_assist-0.1.2 → boto3_assist-0.1.4}/LICENSE.txt +0 -0
  24. {boto3_assist-0.1.2 → boto3_assist-0.1.4}/README.md +0 -0
  25. {boto3_assist-0.1.2 → boto3_assist-0.1.4}/devops/build.py +0 -0
  26. {boto3_assist-0.1.2 → boto3_assist-0.1.4}/devops/readme.md +0 -0
  27. {boto3_assist-0.1.2 → boto3_assist-0.1.4}/examples/__init__.py +0 -0
  28. {boto3_assist-0.1.2 → boto3_assist-0.1.4}/examples/dynamodb/models/order_item_model.py +0 -0
  29. {boto3_assist-0.1.2 → boto3_assist-0.1.4}/examples/dynamodb/models/order_model.py +0 -0
  30. {boto3_assist-0.1.2 → boto3_assist-0.1.4}/examples/dynamodb/models/product_model.py +0 -0
  31. {boto3_assist-0.1.2 → boto3_assist-0.1.4}/examples/dynamodb/models/user_model.py +0 -0
  32. {boto3_assist-0.1.2 → boto3_assist-0.1.4}/examples/dynamodb/models/user_post_model.py +0 -0
  33. {boto3_assist-0.1.2 → boto3_assist-0.1.4}/examples/dynamodb/order_example/main.py +0 -0
  34. {boto3_assist-0.1.2 → boto3_assist-0.1.4}/examples/dynamodb/order_example/products.json +0 -0
  35. {boto3_assist-0.1.2 → boto3_assist-0.1.4}/examples/dynamodb/services/order_item_service.py +0 -0
  36. {boto3_assist-0.1.2 → boto3_assist-0.1.4}/examples/dynamodb/services/order_service.py +0 -0
  37. {boto3_assist-0.1.2 → boto3_assist-0.1.4}/examples/dynamodb/services/product_service.py +0 -0
  38. {boto3_assist-0.1.2 → boto3_assist-0.1.4}/examples/dynamodb/services/table_service.py +0 -0
  39. {boto3_assist-0.1.2 → boto3_assist-0.1.4}/examples/dynamodb/services/user_post_service.py +0 -0
  40. {boto3_assist-0.1.2 → boto3_assist-0.1.4}/examples/dynamodb/services/user_service.py +0 -0
  41. {boto3_assist-0.1.2 → boto3_assist-0.1.4}/examples/dynamodb/services/user_service_client_example.py +0 -0
  42. {boto3_assist-0.1.2 → boto3_assist-0.1.4}/examples/dynamodb/services/user_service_resource_example.py +0 -0
  43. {boto3_assist-0.1.2 → boto3_assist-0.1.4}/examples/dynamodb/user_post_example/main.py +0 -0
  44. {boto3_assist-0.1.2 → boto3_assist-0.1.4}/module-headers.txt +0 -0
  45. {boto3_assist-0.1.2 → boto3_assist-0.1.4}/mypy.ini +0 -0
  46. {boto3_assist-0.1.2 → boto3_assist-0.1.4}/requirements.txt +0 -0
  47. {boto3_assist-0.1.2 → boto3_assist-0.1.4}/run-checks.sh +0 -0
  48. {boto3_assist-0.1.2 → boto3_assist-0.1.4}/src/boto3_assist/__init__.py +0 -0
  49. {boto3_assist-0.1.2 → boto3_assist-0.1.4}/src/boto3_assist/boto3session.py +0 -0
  50. {boto3_assist-0.1.2 → boto3_assist-0.1.4}/src/boto3_assist/dynamodb/dynamodb_connection.py +0 -0
  51. {boto3_assist-0.1.2 → boto3_assist-0.1.4}/src/boto3_assist/dynamodb/dynamodb_connection_tracker.py +0 -0
  52. {boto3_assist-0.1.2 → boto3_assist-0.1.4}/src/boto3_assist/dynamodb/dynamodb_helpers.py +0 -0
  53. {boto3_assist-0.1.2 → boto3_assist-0.1.4}/src/boto3_assist/dynamodb/dynamodb_importer.py +0 -0
  54. {boto3_assist-0.1.2 → boto3_assist-0.1.4}/src/boto3_assist/dynamodb/dynamodb_index.py +0 -0
  55. {boto3_assist-0.1.2 → boto3_assist-0.1.4}/src/boto3_assist/dynamodb/dynamodb_iservice.py +0 -0
  56. {boto3_assist-0.1.2 → boto3_assist-0.1.4}/src/boto3_assist/dynamodb/dynamodb_key.py +0 -0
  57. {boto3_assist-0.1.2 → boto3_assist-0.1.4}/src/boto3_assist/dynamodb/dynamodb_model_base_interfaces.py +0 -0
  58. {boto3_assist-0.1.2 → boto3_assist-0.1.4}/src/boto3_assist/dynamodb/dynamodb_reindexer.py +0 -0
  59. {boto3_assist-0.1.2 → boto3_assist-0.1.4}/src/boto3_assist/dynamodb/readme.md +0 -0
  60. {boto3_assist-0.1.2 → boto3_assist-0.1.4}/src/boto3_assist/dynamodb/troubleshooting.md +0 -0
  61. {boto3_assist-0.1.2 → boto3_assist-0.1.4}/src/boto3_assist/environment_services/__init__.py +0 -0
  62. {boto3_assist-0.1.2 → boto3_assist-0.1.4}/src/boto3_assist/environment_services/environment_loader.py +0 -0
  63. {boto3_assist-0.1.2 → boto3_assist-0.1.4}/src/boto3_assist/utilities/datetime_utility.py +0 -0
  64. {boto3_assist-0.1.2 → boto3_assist-0.1.4}/src/boto3_assist/utilities/logging_utility.py +0 -0
  65. {boto3_assist-0.1.2 → boto3_assist-0.1.4}/src/boto3_assist/utilities/serialization_utility.py +0 -0
  66. {boto3_assist-0.1.2 → boto3_assist-0.1.4}/src/boto3_assist/utilities/string_utility.py +0 -0
  67. {boto3_assist-0.1.2 → boto3_assist-0.1.4}/tests/__init__.py +0 -0
  68. {boto3_assist-0.1.2 → boto3_assist-0.1.4}/tests/__top/__init__.py +0 -0
  69. {boto3_assist-0.1.2 → boto3_assist-0.1.4}/tests/dynamodb/__init__.py +0 -0
  70. {boto3_assist-0.1.2 → boto3_assist-0.1.4}/tests/dynamodb/dynamodb_model_base_test.py +0 -0
  71. {boto3_assist-0.1.2 → boto3_assist-0.1.4}/tests/dynamodb/dynamodb_reindex_test.py +0 -0
  72. {boto3_assist-0.1.2 → boto3_assist-0.1.4}/tests/examples_test/__init__.py +0 -0
  73. {boto3_assist-0.1.2 → boto3_assist-0.1.4}/tests/examples_test/user_service_test.py +0 -0
  74. {boto3_assist-0.1.2 → boto3_assist-0.1.4}/tests/utilities/__init__.py +0 -0
  75. {boto3_assist-0.1.2 → boto3_assist-0.1.4}/tests/utilities/serialization_utility_test.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: boto3_assist
3
- Version: 0.1.2
3
+ Version: 0.1.4
4
4
  Summary: Additional boto3 wrappers to make your life a little easier
5
5
  Author-email: Eric Wilson <boto3-assist@geekcafe.com>
6
6
  License-File: LICENSE-EXPLAINED.txt
@@ -0,0 +1,31 @@
1
+ RegionName,OptInStatus
2
+ af-south-1,not-opted-in
3
+ ap-east-1,not-opted-in
4
+ ap-northeast-1,opt-in-not-required
5
+ ap-northeast-2,opt-in-not-required
6
+ ap-northeast-3,opt-in-not-required
7
+ ap-south-1,opt-in-not-required
8
+ ap-south-2,not-opted-in
9
+ ap-southeast-1,opt-in-not-required
10
+ ap-southeast-2,opt-in-not-required
11
+ ap-southeast-3,not-opted-in
12
+ ap-southeast-4,not-opted-in
13
+ ap-southeast-5,not-opted-in
14
+ ca-central-1,opt-in-not-required
15
+ ca-west-1,not-opted-in
16
+ eu-central-1,opt-in-not-required
17
+ eu-central-2,not-opted-in
18
+ eu-north-1,opt-in-not-required
19
+ eu-south-1,not-opted-in
20
+ eu-south-2,not-opted-in
21
+ eu-west-1,opt-in-not-required
22
+ eu-west-2,opt-in-not-required
23
+ eu-west-3,opt-in-not-required
24
+ il-central-1,not-opted-in
25
+ me-central-1,not-opted-in
26
+ me-south-1,not-opted-in
27
+ sa-east-1,opt-in-not-required
28
+ us-east-1,opt-in-not-required
29
+ us-east-2,opt-in-not-required
30
+ us-west-1,opt-in-not-required
31
+ us-west-2,opt-in-not-required
@@ -0,0 +1,122 @@
1
+ [
2
+ {
3
+ "RegionName": "af-south-1",
4
+ "OptInStatus": "not-opted-in"
5
+ },
6
+ {
7
+ "RegionName": "ap-east-1",
8
+ "OptInStatus": "not-opted-in"
9
+ },
10
+ {
11
+ "RegionName": "ap-northeast-1",
12
+ "OptInStatus": "opt-in-not-required"
13
+ },
14
+ {
15
+ "RegionName": "ap-northeast-2",
16
+ "OptInStatus": "opt-in-not-required"
17
+ },
18
+ {
19
+ "RegionName": "ap-northeast-3",
20
+ "OptInStatus": "opt-in-not-required"
21
+ },
22
+ {
23
+ "RegionName": "ap-south-1",
24
+ "OptInStatus": "opt-in-not-required"
25
+ },
26
+ {
27
+ "RegionName": "ap-south-2",
28
+ "OptInStatus": "not-opted-in"
29
+ },
30
+ {
31
+ "RegionName": "ap-southeast-1",
32
+ "OptInStatus": "opt-in-not-required"
33
+ },
34
+ {
35
+ "RegionName": "ap-southeast-2",
36
+ "OptInStatus": "opt-in-not-required"
37
+ },
38
+ {
39
+ "RegionName": "ap-southeast-3",
40
+ "OptInStatus": "not-opted-in"
41
+ },
42
+ {
43
+ "RegionName": "ap-southeast-4",
44
+ "OptInStatus": "not-opted-in"
45
+ },
46
+ {
47
+ "RegionName": "ap-southeast-5",
48
+ "OptInStatus": "not-opted-in"
49
+ },
50
+ {
51
+ "RegionName": "ca-central-1",
52
+ "OptInStatus": "opt-in-not-required"
53
+ },
54
+ {
55
+ "RegionName": "ca-west-1",
56
+ "OptInStatus": "not-opted-in"
57
+ },
58
+ {
59
+ "RegionName": "eu-central-1",
60
+ "OptInStatus": "opt-in-not-required"
61
+ },
62
+ {
63
+ "RegionName": "eu-central-2",
64
+ "OptInStatus": "not-opted-in"
65
+ },
66
+ {
67
+ "RegionName": "eu-north-1",
68
+ "OptInStatus": "opt-in-not-required"
69
+ },
70
+ {
71
+ "RegionName": "eu-south-1",
72
+ "OptInStatus": "not-opted-in"
73
+ },
74
+ {
75
+ "RegionName": "eu-south-2",
76
+ "OptInStatus": "not-opted-in"
77
+ },
78
+ {
79
+ "RegionName": "eu-west-1",
80
+ "OptInStatus": "opt-in-not-required"
81
+ },
82
+ {
83
+ "RegionName": "eu-west-2",
84
+ "OptInStatus": "opt-in-not-required"
85
+ },
86
+ {
87
+ "RegionName": "eu-west-3",
88
+ "OptInStatus": "opt-in-not-required"
89
+ },
90
+ {
91
+ "RegionName": "il-central-1",
92
+ "OptInStatus": "not-opted-in"
93
+ },
94
+ {
95
+ "RegionName": "me-central-1",
96
+ "OptInStatus": "not-opted-in"
97
+ },
98
+ {
99
+ "RegionName": "me-south-1",
100
+ "OptInStatus": "not-opted-in"
101
+ },
102
+ {
103
+ "RegionName": "sa-east-1",
104
+ "OptInStatus": "opt-in-not-required"
105
+ },
106
+ {
107
+ "RegionName": "us-east-1",
108
+ "OptInStatus": "opt-in-not-required"
109
+ },
110
+ {
111
+ "RegionName": "us-east-2",
112
+ "OptInStatus": "opt-in-not-required"
113
+ },
114
+ {
115
+ "RegionName": "us-west-1",
116
+ "OptInStatus": "opt-in-not-required"
117
+ },
118
+ {
119
+ "RegionName": "us-west-2",
120
+ "OptInStatus": "opt-in-not-required"
121
+ }
122
+ ]
@@ -0,0 +1,80 @@
1
+ import os
2
+ import json
3
+ import csv
4
+ from typing import List, Dict, Any
5
+ from pathlib import Path
6
+ from boto3_assist.environment_services.environment_loader import EnvironmentLoader
7
+ from boto3_assist.ec2.ec2_connection import EC2Connection
8
+
9
+
10
+ class RegionsReport(EC2Connection):
11
+ def __init__(self) -> None:
12
+ super().__init__()
13
+
14
+ def get_aws_regions_with_status(self) -> List[Dict[str, Any]]:
15
+ """_summary_
16
+
17
+ Returns:
18
+ _type_: _description_
19
+ """
20
+ ec2 = self.client
21
+ regions = ec2.describe_regions(AllRegions=True)
22
+ # order by region name
23
+ regions["Regions"].sort(key=lambda x: x["RegionName"])
24
+ return [
25
+ {"RegionName": region["RegionName"], "OptInStatus": region["OptInStatus"]}
26
+ for region in regions["Regions"]
27
+ ]
28
+
29
+ def export(self, regions: List[Dict[str, Any]], file_format: str = "csv"):
30
+ """
31
+ Export the regions to a file
32
+ Args:
33
+ regions (List[Dict[str, Any]]): _description_
34
+ file_format (str, optional): _description_. Defaults to "csv".
35
+ """
36
+ if file_format == "csv":
37
+ self.__export_regions_to_csv(regions)
38
+ elif file_format == "json":
39
+ self.__export_regions_to_json(regions)
40
+
41
+ def __export_regions_to_csv(self, regions, filename="aws_regions_with_status.csv"):
42
+ with open(filename, "w", newline="", encoding="utf-8") as csvfile:
43
+ writer = csv.writer(csvfile)
44
+ writer.writerow(["RegionName", "OptInStatus"])
45
+ for region in regions:
46
+ writer.writerow([region["RegionName"], region["OptInStatus"]])
47
+
48
+ def __export_regions_to_json(
49
+ self, regions, filename="aws_regions_with_status.json"
50
+ ):
51
+ with open(filename, "w", encoding="utf-8") as jsonfile:
52
+ json.dump(regions, jsonfile, indent=4)
53
+
54
+
55
+ def main():
56
+ """Main"""
57
+
58
+ env_file_name: str = os.getenv("ENVRIONMENT_FILE", ".env")
59
+ path = os.path.join(str(Path(__file__).parents[2].absolute()), env_file_name)
60
+ el: EnvironmentLoader = EnvironmentLoader()
61
+ if not os.path.exists(path=path):
62
+ raise FileNotFoundError("Failed to find the environmetn file")
63
+ loaded: bool = el.load_environment_file(path)
64
+ if not loaded:
65
+ raise RuntimeError("Failed to load my local environment")
66
+
67
+ report: RegionsReport = RegionsReport()
68
+
69
+ # Retrieve AWS regions with their status
70
+ regions_with_status = report.get_aws_regions_with_status()
71
+
72
+ # Export to CSV
73
+ report.export(regions_with_status)
74
+
75
+ # Export to JSON
76
+ report.export(regions_with_status, file_format="json")
77
+
78
+
79
+ if __name__ == "__main__":
80
+ main()
@@ -7,7 +7,7 @@ packages = ["src/boto3_assist"]
7
7
 
8
8
  [project]
9
9
  name = "boto3_assist"
10
- version = "0.1.2"
10
+ version = "0.1.4"
11
11
  authors = [
12
12
  { name="Eric Wilson", email="boto3-assist@geekcafe.com" }
13
13
  ]
@@ -2,6 +2,7 @@ boto3-stubs[dynamodb]
2
2
  build
3
3
  mypy
4
4
  mypy_boto3_dynamodb
5
+ mypy_boto3_ec2
5
6
  moto [dynamodb2] # mocks for unit tests
6
7
  # setuptools
7
8
  types-python-dateutil
@@ -0,0 +1,47 @@
1
+ """
2
+ Geek Cafe, LLC
3
+ Maintainers: Eric Wilson
4
+ MIT License. See Project Root for the license information.
5
+ """
6
+
7
+
8
+ class ConnectionTracker:
9
+ """
10
+ Tracks Connection Requests.
11
+ Useful in for performance tuning and debugging.
12
+ """
13
+
14
+ def __init__(self, service_name: str) -> None:
15
+ self.__connection_couter: int = 0
16
+ self.__service_name: str = service_name
17
+
18
+ def increment_connection(self) -> None:
19
+ """Increments the connection counter"""
20
+ self.__connection_couter += 1
21
+
22
+ if self.connection_count > 1:
23
+ self.__log_warning(
24
+ f"Your dynamodb connection count is {self.connection_count}. "
25
+ "Under most circumstances you should be able to use the same connection "
26
+ "vs. creating a new one. Connections are expensive in terms of time / latency. "
27
+ "If you are seeing perforance issues, check how and where you are creating your "
28
+ "connections. You should be able to pass the .db connection to your other objects "
29
+ "and reuse your dynamodb boto connections."
30
+ )
31
+
32
+ def decrement_connection(self) -> None:
33
+ """Decrements the connection counter"""
34
+ self.__connection_couter -= 1
35
+
36
+ @property
37
+ def connection_count(self) -> int:
38
+ """Returns the current connection count"""
39
+ return self.__connection_couter
40
+
41
+ def reset(self) -> None:
42
+ """Resets the connection counter"""
43
+ self.__connection_couter = 0
44
+
45
+ def __log_warning(self, message: str) -> None:
46
+ """Logs a warning message"""
47
+ print(f"Warning: {message}")
@@ -372,6 +372,7 @@ class DynamoDB(DynamoDBConnection):
372
372
  do_projections: bool = False,
373
373
  ascending: bool = False,
374
374
  strongly_consistent: bool = False,
375
+ limit: Optional[int] = None,
375
376
  ) -> dict:
376
377
  """Helper function to list by criteria"""
377
378
 
@@ -391,6 +392,7 @@ class DynamoDB(DynamoDBConnection):
391
392
  expression_attribute_names=expression_attribute_names,
392
393
  ascending=ascending,
393
394
  strongly_consistent=strongly_consistent,
395
+ limit=limit,
394
396
  )
395
397
 
396
398
  return response
@@ -130,6 +130,14 @@ class DynamoDBModelBase:
130
130
  self, include_indexes=include_indexes
131
131
  )
132
132
 
133
+ def to_dictionary(self):
134
+ """
135
+ Convert the instance to a dictionary without an indexes/keys.
136
+ Usefull for turning an object into a dictionary for serialization.
137
+ This is the same as to_resource_dictionary(include_indexes=False)
138
+ """
139
+ return DynamoDBSerializer.to_resource_dictionary(self, include_indexes=False)
140
+
133
141
  def get_key(self, index_name: str) -> DynamoDBIndex:
134
142
  """Get the index name and key"""
135
143
 
@@ -0,0 +1,103 @@
1
+ """
2
+ Geek Cafe, LLC
3
+ Maintainers: Eric Wilson
4
+ MIT License. See Project Root for the license information.
5
+ """
6
+
7
+ from typing import Optional
8
+ from typing import TYPE_CHECKING
9
+
10
+ from aws_lambda_powertools import Logger
11
+ from boto3_assist.boto3session import Boto3SessionManager
12
+ from boto3_assist.environment_services.environment_variables import (
13
+ EnvironmentVariables,
14
+ )
15
+ from boto3_assist.connection_tracker import ConnectionTracker
16
+
17
+ if TYPE_CHECKING:
18
+ from mypy_boto3_ec2 import Client
19
+ else:
20
+ Client = object
21
+
22
+ SERVICE_NAME = "ec2"
23
+ logger = Logger()
24
+ tracker: ConnectionTracker = ConnectionTracker(service_name=SERVICE_NAME)
25
+
26
+
27
+ class EC2Connection:
28
+ """DB Environment"""
29
+
30
+ def __init__(
31
+ self,
32
+ *,
33
+ aws_profile: Optional[str] = None,
34
+ aws_region: Optional[str] = None,
35
+ aws_access_key_id: Optional[str] = None,
36
+ aws_secret_access_key: Optional[str] = None,
37
+ ) -> None:
38
+ self.aws_profile = aws_profile
39
+ self.aws_region = aws_region
40
+
41
+ self.aws_access_key_id = aws_access_key_id
42
+ self.aws_secret_access_key = aws_secret_access_key
43
+ self.__session: Boto3SessionManager | None = None
44
+ self.__client: Client | None = None
45
+
46
+ self.raise_on_error: bool = True
47
+
48
+ def setup(self, setup_source: Optional[str] = None) -> None:
49
+ """
50
+ Setup the environment. Automatically called via init.
51
+ You can run setup at anytime with new parameters.
52
+ Args: setup_source: Optional[str] = None
53
+ Defines the source of the setup. Useful for logging.
54
+ Returns: None
55
+ """
56
+
57
+ logger.info(
58
+ {
59
+ "metric_filter": "connection_setup",
60
+ "source": "setup",
61
+ "aws_profile": self.aws_profile,
62
+ "aws_region": self.aws_region,
63
+ "setup_source": setup_source,
64
+ }
65
+ )
66
+
67
+ # lazy load the session
68
+ self.__session = Boto3SessionManager(
69
+ service_name=SERVICE_NAME,
70
+ aws_profile=self.aws_profile,
71
+ aws_region=self.aws_region or EnvironmentVariables.AWS.region(),
72
+ aws_access_key_id=self.aws_access_key_id
73
+ or EnvironmentVariables.AWS.aws_access_key_id(),
74
+ aws_secret_access_key=self.aws_secret_access_key
75
+ or EnvironmentVariables.AWS.aws_secret_access_key(),
76
+ )
77
+
78
+ tracker.increment_connection()
79
+
80
+ self.raise_on_error = EnvironmentVariables.AWS.DynamoDB.raise_on_error_setting()
81
+
82
+ @property
83
+ def session(self) -> Boto3SessionManager:
84
+ """Session"""
85
+ if self.__session is None:
86
+ self.setup(setup_source="session init")
87
+ return self.__session
88
+
89
+ @property
90
+ def client(self) -> Client:
91
+ """Client Connection"""
92
+ if self.__client is None:
93
+ logger.info("Creating Client")
94
+ self.__client = self.session.client
95
+
96
+ if self.raise_on_error and self.__client is None:
97
+ raise RuntimeError("Client is not available")
98
+ return self.__client
99
+
100
+ @client.setter
101
+ def client(self, value: Client):
102
+ logger.info("Setting Client")
103
+ self.__client = value
@@ -83,6 +83,22 @@ class EnvironmentVariables:
83
83
  )
84
84
  return value
85
85
 
86
+ @staticmethod
87
+ def aws_access_key_id() -> str | None:
88
+ """
89
+ The aws_access_key_id. Often used for local development.
90
+ """
91
+ value = os.getenv("ACCESS_KEY_ID")
92
+ return value
93
+
94
+ @staticmethod
95
+ def aws_secret_access_key() -> str | None:
96
+ """
97
+ The aws_secret_access_key. Often used for local development.
98
+ """
99
+ value = os.getenv("SECRET_ACCESS_KEY")
100
+ return value
101
+
86
102
  class SES:
87
103
  """SES Settings"""
88
104
 
@@ -0,0 +1 @@
1
+ __version__ = '0.1.4'
@@ -1 +0,0 @@
1
- __version__ = '0.1.2'
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes