aws-cdk-constructs 2.26.3__tar.gz → 2.27.0__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 (47) hide show
  1. {aws_cdk_constructs-2.26.3 → aws_cdk_constructs-2.27.0}/PKG-INFO +1 -1
  2. {aws_cdk_constructs-2.26.3 → aws_cdk_constructs-2.27.0}/aws_cdk_constructs/__init__.py +2 -2
  3. aws_cdk_constructs-2.27.0/aws_cdk_constructs/api/__init__.py +1 -0
  4. {aws_cdk_constructs-2.26.3 → aws_cdk_constructs-2.27.0}/aws_cdk_constructs/api/api.py +61 -29
  5. {aws_cdk_constructs-2.26.3 → aws_cdk_constructs-2.27.0}/aws_cdk_constructs.egg-info/PKG-INFO +1 -1
  6. aws_cdk_constructs-2.26.3/aws_cdk_constructs/api/__init__.py +0 -1
  7. {aws_cdk_constructs-2.26.3 → aws_cdk_constructs-2.27.0}/LICENSE.txt +0 -0
  8. {aws_cdk_constructs-2.26.3 → aws_cdk_constructs-2.27.0}/MANIFEST.in +0 -0
  9. {aws_cdk_constructs-2.26.3 → aws_cdk_constructs-2.27.0}/README.md +0 -0
  10. {aws_cdk_constructs-2.26.3 → aws_cdk_constructs-2.27.0}/aws_cdk_constructs/bucket/__init__.py +0 -0
  11. {aws_cdk_constructs-2.26.3 → aws_cdk_constructs-2.27.0}/aws_cdk_constructs/bucket/bucket.py +0 -0
  12. {aws_cdk_constructs-2.26.3 → aws_cdk_constructs-2.27.0}/aws_cdk_constructs/database/__init__.py +0 -0
  13. {aws_cdk_constructs-2.26.3 → aws_cdk_constructs-2.27.0}/aws_cdk_constructs/database/_types/__init__.py +0 -0
  14. {aws_cdk_constructs-2.26.3 → aws_cdk_constructs-2.27.0}/aws_cdk_constructs/database/_types/document.py +0 -0
  15. {aws_cdk_constructs-2.26.3 → aws_cdk_constructs-2.27.0}/aws_cdk_constructs/database/_types/graph.py +0 -0
  16. {aws_cdk_constructs-2.26.3 → aws_cdk_constructs-2.27.0}/aws_cdk_constructs/database/_types/relational.py +0 -0
  17. {aws_cdk_constructs-2.26.3 → aws_cdk_constructs-2.27.0}/aws_cdk_constructs/database/database.py +0 -0
  18. {aws_cdk_constructs-2.26.3 → aws_cdk_constructs-2.27.0}/aws_cdk_constructs/database/types.py +0 -0
  19. {aws_cdk_constructs-2.26.3 → aws_cdk_constructs-2.27.0}/aws_cdk_constructs/ecs/__init__.py +0 -0
  20. {aws_cdk_constructs-2.26.3 → aws_cdk_constructs-2.27.0}/aws_cdk_constructs/ecs/cluster.py +0 -0
  21. {aws_cdk_constructs-2.26.3 → aws_cdk_constructs-2.27.0}/aws_cdk_constructs/ecs/fargate_validator.py +0 -0
  22. {aws_cdk_constructs-2.26.3 → aws_cdk_constructs-2.27.0}/aws_cdk_constructs/ecs/microservice.py +0 -0
  23. {aws_cdk_constructs-2.26.3 → aws_cdk_constructs-2.27.0}/aws_cdk_constructs/efs/__init__.py +0 -0
  24. {aws_cdk_constructs-2.26.3 → aws_cdk_constructs-2.27.0}/aws_cdk_constructs/efs/volume.py +0 -0
  25. {aws_cdk_constructs-2.26.3 → aws_cdk_constructs-2.27.0}/aws_cdk_constructs/load_balancer/__init__.py +0 -0
  26. {aws_cdk_constructs-2.26.3 → aws_cdk_constructs-2.27.0}/aws_cdk_constructs/load_balancer/alb.py +0 -0
  27. {aws_cdk_constructs-2.26.3 → aws_cdk_constructs-2.27.0}/aws_cdk_constructs/load_balancer/nlb.py +0 -0
  28. {aws_cdk_constructs-2.26.3 → aws_cdk_constructs-2.27.0}/aws_cdk_constructs/microservice/__init__.py +0 -0
  29. {aws_cdk_constructs-2.26.3 → aws_cdk_constructs-2.27.0}/aws_cdk_constructs/microservice/base_user_data.sh +0 -0
  30. {aws_cdk_constructs-2.26.3 → aws_cdk_constructs-2.27.0}/aws_cdk_constructs/microservice/manage_connection_to_nlb_instance_security_group_ingress/lambda_function.js +0 -0
  31. {aws_cdk_constructs-2.26.3 → aws_cdk_constructs-2.27.0}/aws_cdk_constructs/microservice/microservice.py +0 -0
  32. {aws_cdk_constructs-2.26.3 → aws_cdk_constructs-2.27.0}/aws_cdk_constructs/security_group/__init__.py +0 -0
  33. {aws_cdk_constructs-2.26.3 → aws_cdk_constructs-2.27.0}/aws_cdk_constructs/security_group/security_group.py +0 -0
  34. {aws_cdk_constructs-2.26.3 → aws_cdk_constructs-2.27.0}/aws_cdk_constructs/service_user_for_iac/__init__.py +0 -0
  35. {aws_cdk_constructs-2.26.3 → aws_cdk_constructs-2.27.0}/aws_cdk_constructs/service_user_for_iac/service_user_for_iac.py +0 -0
  36. {aws_cdk_constructs-2.26.3 → aws_cdk_constructs-2.27.0}/aws_cdk_constructs/service_user_for_static_assets/__init__.py +0 -0
  37. {aws_cdk_constructs-2.26.3 → aws_cdk_constructs-2.27.0}/aws_cdk_constructs/service_user_for_static_assets/service_user_for_static_assets.py +0 -0
  38. {aws_cdk_constructs-2.26.3 → aws_cdk_constructs-2.27.0}/aws_cdk_constructs/utils.py +0 -0
  39. {aws_cdk_constructs-2.26.3 → aws_cdk_constructs-2.27.0}/aws_cdk_constructs/windows_server/__init__.py +0 -0
  40. {aws_cdk_constructs-2.26.3 → aws_cdk_constructs-2.27.0}/aws_cdk_constructs/windows_server/user_data.ps1 +0 -0
  41. {aws_cdk_constructs-2.26.3 → aws_cdk_constructs-2.27.0}/aws_cdk_constructs/windows_server/windows_server.py +0 -0
  42. {aws_cdk_constructs-2.26.3 → aws_cdk_constructs-2.27.0}/aws_cdk_constructs.egg-info/SOURCES.txt +0 -0
  43. {aws_cdk_constructs-2.26.3 → aws_cdk_constructs-2.27.0}/aws_cdk_constructs.egg-info/dependency_links.txt +0 -0
  44. {aws_cdk_constructs-2.26.3 → aws_cdk_constructs-2.27.0}/aws_cdk_constructs.egg-info/requires.txt +0 -0
  45. {aws_cdk_constructs-2.26.3 → aws_cdk_constructs-2.27.0}/aws_cdk_constructs.egg-info/top_level.txt +0 -0
  46. {aws_cdk_constructs-2.26.3 → aws_cdk_constructs-2.27.0}/setup.cfg +0 -0
  47. {aws_cdk_constructs-2.26.3 → aws_cdk_constructs-2.27.0}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: aws_cdk_constructs
3
- Version: 2.26.3
3
+ Version: 2.27.0
4
4
  Summary: AWS CDK constructs
5
5
  Home-page: https://bitbucket.org/cioapps/aws-cdk-constructs
6
6
  Author: author
@@ -7,11 +7,11 @@ from .bucket import Bucket
7
7
  from .ecs.cluster import ECSCluster
8
8
  from .ecs.microservice import ECSMicroservice
9
9
  from .efs.volume import EFSVolume
10
- from .api import API
10
+ from .api import Api
11
11
  from .service_user_for_iac import ServiceUserForIAC
12
12
  from .service_user_for_static_assets import ServiceUserForStaticAssets
13
13
  from .load_balancer import Alb, Nlb
14
14
  from .security_group import SecurityGroup
15
15
  from .windows_server import WindowsServer
16
16
 
17
- __version__ = '2.26.3'
17
+ __version__ = '2.27.0'
@@ -0,0 +1 @@
1
+ from .api import Api
@@ -6,12 +6,46 @@ from aws_cdk_constructs.utils import (
6
6
  normalize_environment_parameter,
7
7
  get_version,
8
8
  )
9
+ from typing import Union
9
10
 
10
11
 
11
- class API(Construct):
12
+ class Api(Construct):
13
+ @property
14
+ def api(
15
+ self,
16
+ ) -> _apigateway.SpecRestApi:
17
+ """Returns the API Gateway construct
18
+
19
+ Returns:
20
+ _apigateway.SpecRestApi: API Gateway construct
21
+ """
22
+ return self._api
23
+
24
+ @property
25
+ def key(
26
+ self,
27
+ ) -> _apigateway.ApiKey:
28
+ """Returns the API Gateway key
29
+
30
+ bReturns:
31
+ _apigateway.ApiKey: API Gateway key
32
+ """
33
+ return self._key
34
+
35
+ @property
36
+ def usage_plan(
37
+ self,
38
+ ) -> _apigateway.UsagePlan:
39
+ """Returns the API Gateway usage plan associated to the key
40
+
41
+ bReturns:
42
+ _apigateway.UsagePlan: Returns the API Gateway usage plan associated to the key
43
+ """
44
+ return self._usage_plan
45
+
12
46
  """
13
47
 
14
- The FAO CDK API Construct creates an AWS API Gateway REST API, providing a Swagger JSON file.
48
+ The FAO CDK Api Construct creates an AWS Api Gateway REST Api, providing a Swagger JSON file.
15
49
 
16
50
  Every resource created by the construct will be tagged according to the FAO AWS tagging strategy described at https://aws.fao.org
17
51
 
@@ -25,7 +59,7 @@ class API(Construct):
25
59
 
26
60
  environments_parameters (dict): The dictionary containing the references to CSI AWS environments. This will simplify the environment promotions and enable a parametric development of the infrastructures.
27
61
 
28
- swagger_path (str): The path to the Swagger file (or OpenAPI compatibile) to use to auto-generate API Gateway
62
+ api_definition_path (str): The path to the OpenAI definition (or compatible) to use to auto-generate Api Gateway
29
63
 
30
64
  """
31
65
 
@@ -36,8 +70,10 @@ class API(Construct):
36
70
  app_name: str,
37
71
  environment: str,
38
72
  environments_parameters: dict,
39
- swagger_path: str = None,
40
- **kwargs
73
+ api_definition_path: str,
74
+ quota: Union[_apigateway.QuotaSettings, None] = None,
75
+ throttle: Union[_apigateway.ThrottleSettings, None] = None,
76
+ **kwargs,
41
77
  ) -> None:
42
78
  super().__init__(scope, id, **kwargs)
43
79
  environment = normalize_environment_parameter(environment)
@@ -51,32 +87,28 @@ class API(Construct):
51
87
  cdk.Tags.of(cdk.Stack.of(self)).add('fao-cdk-version', get_version())
52
88
  cdk.Tags.of(cdk.Stack.of(self)).add('fao-cdk', 'true')
53
89
 
54
- # Declare variables
55
- self.api = None
56
-
57
90
  # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Create conditions
58
- swagger_path = swagger_path.strip()
59
- swagger_was_provided = swagger_path
91
+ api_definition_path = api_definition_path.strip()
60
92
 
61
93
  environment = environment.lower()
62
94
  aws_account = environments_parameters['accounts'][environment]
63
95
 
64
- # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Conditionally create resources
65
-
66
- if swagger_was_provided:
67
- # Read the base user data from file
68
- with open(swagger_path) as swagger_content:
69
- pws_swagger = swagger_content.read()
70
- swagger_content.close()
71
-
72
- api = _apigateway.CfnRestApi(
73
- self,
74
- app_name + '-api',
75
- body=None,
76
- body_s3_location=_apigateway.CfnRestApi.S3LocationProperty(
77
- bucket=aws_account['s3_config_bucket'],
78
- key=app_name + '/' + environment + '/swagger.json',
79
- ),
80
- description=app_name + '/' + environment + ' API',
81
- name=app_name + '/' + environment,
82
- )
96
+ self._api = _apigateway.SpecRestApi(
97
+ self,
98
+ f'{id}-{environment}',
99
+ api_definition=_apigateway.ApiDefinition.from_asset(
100
+ api_definition_path
101
+ ),
102
+ )
103
+
104
+ self._usage_plan = self._api.add_usage_plan(
105
+ f'{id}-{environment}-usage-plan',
106
+ name=f'{id}-{environment}-usage-plan',
107
+ quota=quota,
108
+ throttle=throttle,
109
+ )
110
+
111
+ self._key = self._api.add_api_key(
112
+ f'{id}-{environment}-key', api_key_name=f'{id}-{environment}-key'
113
+ )
114
+ self._usage_plan.add_api_key(self._key)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: aws-cdk-constructs
3
- Version: 2.26.3
3
+ Version: 2.27.0
4
4
  Summary: AWS CDK constructs
5
5
  Home-page: https://bitbucket.org/cioapps/aws-cdk-constructs
6
6
  Author: author
@@ -1 +0,0 @@
1
- from .api import API