aws-cdk-constructs 2.28.0__tar.gz → 2.30.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.
- {aws_cdk_constructs-2.28.0 → aws_cdk_constructs-2.30.0}/PKG-INFO +1 -1
- {aws_cdk_constructs-2.28.0 → aws_cdk_constructs-2.30.0}/aws_cdk_constructs/__init__.py +1 -1
- {aws_cdk_constructs-2.28.0 → aws_cdk_constructs-2.30.0}/aws_cdk_constructs/api/api.py +2 -0
- aws_cdk_constructs-2.30.0/aws_cdk_constructs/bucket/auth_flow.py +137 -0
- aws_cdk_constructs-2.30.0/aws_cdk_constructs/bucket/base_edge_constructs.py +63 -0
- {aws_cdk_constructs-2.28.0 → aws_cdk_constructs-2.30.0}/aws_cdk_constructs/bucket/bucket.py +286 -115
- aws_cdk_constructs-2.30.0/aws_cdk_constructs/bucket/configuration.py +13 -0
- aws_cdk_constructs-2.30.0/aws_cdk_constructs/bucket/edge_function.py +151 -0
- aws_cdk_constructs-2.30.0/aws_cdk_constructs/bucket/edge_role.py +50 -0
- aws_cdk_constructs-2.30.0/aws_cdk_constructs/bucket/log_level.py +9 -0
- aws_cdk_constructs-2.30.0/aws_cdk_constructs/bucket/secret_generator.py +53 -0
- aws_cdk_constructs-2.30.0/aws_cdk_constructs/bucket/with_configuration.py +75 -0
- {aws_cdk_constructs-2.28.0 → aws_cdk_constructs-2.30.0}/aws_cdk_constructs/microservice/microservice.py +1 -1
- {aws_cdk_constructs-2.28.0 → aws_cdk_constructs-2.30.0}/aws_cdk_constructs/service_user_for_iac/service_user_for_iac.py +18 -1
- {aws_cdk_constructs-2.28.0 → aws_cdk_constructs-2.30.0}/aws_cdk_constructs.egg-info/PKG-INFO +1 -1
- {aws_cdk_constructs-2.28.0 → aws_cdk_constructs-2.30.0}/aws_cdk_constructs.egg-info/SOURCES.txt +8 -0
- aws_cdk_constructs-2.30.0/aws_cdk_constructs.egg-info/requires.txt +4 -0
- {aws_cdk_constructs-2.28.0 → aws_cdk_constructs-2.30.0}/setup.py +4 -9
- aws_cdk_constructs-2.28.0/aws_cdk_constructs.egg-info/requires.txt +0 -7
- {aws_cdk_constructs-2.28.0 → aws_cdk_constructs-2.30.0}/LICENSE.txt +0 -0
- {aws_cdk_constructs-2.28.0 → aws_cdk_constructs-2.30.0}/MANIFEST.in +0 -0
- {aws_cdk_constructs-2.28.0 → aws_cdk_constructs-2.30.0}/README.md +0 -0
- {aws_cdk_constructs-2.28.0 → aws_cdk_constructs-2.30.0}/aws_cdk_constructs/api/__init__.py +0 -0
- {aws_cdk_constructs-2.28.0 → aws_cdk_constructs-2.30.0}/aws_cdk_constructs/bucket/__init__.py +0 -0
- {aws_cdk_constructs-2.28.0 → aws_cdk_constructs-2.30.0}/aws_cdk_constructs/database/__init__.py +0 -0
- {aws_cdk_constructs-2.28.0 → aws_cdk_constructs-2.30.0}/aws_cdk_constructs/database/_types/__init__.py +0 -0
- {aws_cdk_constructs-2.28.0 → aws_cdk_constructs-2.30.0}/aws_cdk_constructs/database/_types/document.py +0 -0
- {aws_cdk_constructs-2.28.0 → aws_cdk_constructs-2.30.0}/aws_cdk_constructs/database/_types/graph.py +0 -0
- {aws_cdk_constructs-2.28.0 → aws_cdk_constructs-2.30.0}/aws_cdk_constructs/database/_types/relational.py +0 -0
- {aws_cdk_constructs-2.28.0 → aws_cdk_constructs-2.30.0}/aws_cdk_constructs/database/database.py +0 -0
- {aws_cdk_constructs-2.28.0 → aws_cdk_constructs-2.30.0}/aws_cdk_constructs/database/types.py +0 -0
- {aws_cdk_constructs-2.28.0 → aws_cdk_constructs-2.30.0}/aws_cdk_constructs/ecs/__init__.py +0 -0
- {aws_cdk_constructs-2.28.0 → aws_cdk_constructs-2.30.0}/aws_cdk_constructs/ecs/cluster.py +0 -0
- {aws_cdk_constructs-2.28.0 → aws_cdk_constructs-2.30.0}/aws_cdk_constructs/ecs/fargate_validator.py +0 -0
- {aws_cdk_constructs-2.28.0 → aws_cdk_constructs-2.30.0}/aws_cdk_constructs/ecs/microservice.py +0 -0
- {aws_cdk_constructs-2.28.0 → aws_cdk_constructs-2.30.0}/aws_cdk_constructs/efs/__init__.py +0 -0
- {aws_cdk_constructs-2.28.0 → aws_cdk_constructs-2.30.0}/aws_cdk_constructs/efs/volume.py +0 -0
- {aws_cdk_constructs-2.28.0 → aws_cdk_constructs-2.30.0}/aws_cdk_constructs/load_balancer/__init__.py +0 -0
- {aws_cdk_constructs-2.28.0 → aws_cdk_constructs-2.30.0}/aws_cdk_constructs/load_balancer/alb.py +0 -0
- {aws_cdk_constructs-2.28.0 → aws_cdk_constructs-2.30.0}/aws_cdk_constructs/load_balancer/nlb.py +0 -0
- {aws_cdk_constructs-2.28.0 → aws_cdk_constructs-2.30.0}/aws_cdk_constructs/microservice/__init__.py +0 -0
- {aws_cdk_constructs-2.28.0 → aws_cdk_constructs-2.30.0}/aws_cdk_constructs/microservice/base_user_data.sh +0 -0
- {aws_cdk_constructs-2.28.0 → aws_cdk_constructs-2.30.0}/aws_cdk_constructs/microservice/manage_connection_to_nlb_instance_security_group_ingress/lambda_function.js +0 -0
- {aws_cdk_constructs-2.28.0 → aws_cdk_constructs-2.30.0}/aws_cdk_constructs/security_group/__init__.py +0 -0
- {aws_cdk_constructs-2.28.0 → aws_cdk_constructs-2.30.0}/aws_cdk_constructs/security_group/security_group.py +0 -0
- {aws_cdk_constructs-2.28.0 → aws_cdk_constructs-2.30.0}/aws_cdk_constructs/service_user_for_iac/__init__.py +0 -0
- {aws_cdk_constructs-2.28.0 → aws_cdk_constructs-2.30.0}/aws_cdk_constructs/service_user_for_static_assets/__init__.py +0 -0
- {aws_cdk_constructs-2.28.0 → aws_cdk_constructs-2.30.0}/aws_cdk_constructs/service_user_for_static_assets/service_user_for_static_assets.py +0 -0
- {aws_cdk_constructs-2.28.0 → aws_cdk_constructs-2.30.0}/aws_cdk_constructs/utils.py +0 -0
- {aws_cdk_constructs-2.28.0 → aws_cdk_constructs-2.30.0}/aws_cdk_constructs/windows_server/__init__.py +0 -0
- {aws_cdk_constructs-2.28.0 → aws_cdk_constructs-2.30.0}/aws_cdk_constructs/windows_server/user_data.ps1 +0 -0
- {aws_cdk_constructs-2.28.0 → aws_cdk_constructs-2.30.0}/aws_cdk_constructs/windows_server/windows_server.py +0 -0
- {aws_cdk_constructs-2.28.0 → aws_cdk_constructs-2.30.0}/aws_cdk_constructs.egg-info/dependency_links.txt +0 -0
- {aws_cdk_constructs-2.28.0 → aws_cdk_constructs-2.30.0}/aws_cdk_constructs.egg-info/top_level.txt +0 -0
- {aws_cdk_constructs-2.28.0 → aws_cdk_constructs-2.30.0}/setup.cfg +0 -0
|
@@ -74,6 +74,7 @@ class Api(Construct):
|
|
|
74
74
|
quota: Union[_apigateway.QuotaSettings, None] = None,
|
|
75
75
|
throttle: Union[_apigateway.ThrottleSettings, None] = None,
|
|
76
76
|
stage_options: Union[_apigateway.StageOptions, None] = None,
|
|
77
|
+
domain_name_options: Union[_apigateway.DomainNameOptions, None] = None,
|
|
77
78
|
**kwargs,
|
|
78
79
|
) -> None:
|
|
79
80
|
super().__init__(scope, id, **kwargs)
|
|
@@ -100,6 +101,7 @@ class Api(Construct):
|
|
|
100
101
|
api_definition=_apigateway.ApiDefinition.from_asset(
|
|
101
102
|
api_definition_path
|
|
102
103
|
),
|
|
104
|
+
domain_name=domain_name_options if domain_name_options else None,
|
|
103
105
|
deploy_options=(
|
|
104
106
|
stage_options
|
|
105
107
|
if stage_options
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import builtins
|
|
2
|
+
from os import path
|
|
3
|
+
import os
|
|
4
|
+
import typing
|
|
5
|
+
import aws_cdk
|
|
6
|
+
import constructs
|
|
7
|
+
from aws_cdk_constructs.bucket.edge_role import EdgeRole
|
|
8
|
+
from aws_cdk_constructs.bucket.edge_function import EdgeFunction
|
|
9
|
+
from aws_cdk_constructs.bucket.configuration import EdgeLambdaConfiguration
|
|
10
|
+
|
|
11
|
+
from aws_cdk_constructs.bucket.log_level import LogLevel
|
|
12
|
+
|
|
13
|
+
from aws_cdk import aws_lambda, aws_cloudfront
|
|
14
|
+
|
|
15
|
+
dirname = os.path.dirname(__file__)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class RedirectPaths(typing.TypedDict):
|
|
19
|
+
sign_in: str
|
|
20
|
+
auth_refresh: str
|
|
21
|
+
sign_out: str
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class AuthFlow(constructs.Construct):
|
|
25
|
+
def __init__(
|
|
26
|
+
self,
|
|
27
|
+
scope: constructs.Construct,
|
|
28
|
+
id: builtins.str,
|
|
29
|
+
*,
|
|
30
|
+
app_name: str,
|
|
31
|
+
cognito_auth_domain: builtins.str,
|
|
32
|
+
cookie_settings: typing.Mapping[builtins.str, builtins.str],
|
|
33
|
+
log_level: LogLevel,
|
|
34
|
+
nonce_signing_secret: builtins.str,
|
|
35
|
+
oauth_scopes: typing.Sequence[aws_cdk.aws_cognito.OAuthScope],
|
|
36
|
+
redirect_paths: RedirectPaths,
|
|
37
|
+
user_pool: aws_cdk.aws_cognito.IUserPool,
|
|
38
|
+
user_pool_client: aws_cdk.aws_cognito.IUserPoolClient,
|
|
39
|
+
client_secret: typing.Optional[builtins.str] = None,
|
|
40
|
+
) -> None:
|
|
41
|
+
"""
|
|
42
|
+
:param scope: -
|
|
43
|
+
:param id: -
|
|
44
|
+
:param cognito_auth_domain: -
|
|
45
|
+
:param cookie_settings: -
|
|
46
|
+
:param log_level: -
|
|
47
|
+
:param nonce_signing_secret: -
|
|
48
|
+
:param oauth_scopes: -
|
|
49
|
+
:param redirect_paths: -
|
|
50
|
+
:param user_pool: -
|
|
51
|
+
:param user_pool_client: -
|
|
52
|
+
:param client_secret: -
|
|
53
|
+
"""
|
|
54
|
+
super().__init__(scope, id)
|
|
55
|
+
|
|
56
|
+
self.edge_role = EdgeRole(self, 'EdgeRole', app_name=app_name)
|
|
57
|
+
|
|
58
|
+
self.configuration = EdgeLambdaConfiguration(
|
|
59
|
+
**{
|
|
60
|
+
'logLevel': log_level.value,
|
|
61
|
+
'redirectPathSignIn': redirect_paths.get('sign_in'),
|
|
62
|
+
'redirectPathAuthRefresh': redirect_paths.get('auth_refresh'),
|
|
63
|
+
'redirectPathSignOut': redirect_paths.get('sign_out'),
|
|
64
|
+
'userPoolId': user_pool.user_pool_id,
|
|
65
|
+
'clientId': user_pool_client.user_pool_client_id,
|
|
66
|
+
'oauthScopes': list(
|
|
67
|
+
map(lambda scope: scope.scope_name, oauth_scopes)
|
|
68
|
+
),
|
|
69
|
+
'cognitoAuthDomain': cognito_auth_domain,
|
|
70
|
+
'cookieSettings': cookie_settings,
|
|
71
|
+
'nonceSigningSecret': nonce_signing_secret,
|
|
72
|
+
'clientSecret': client_secret,
|
|
73
|
+
}
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
self.check_auth = EdgeFunction(
|
|
77
|
+
self,
|
|
78
|
+
'CheckAuth',
|
|
79
|
+
name='check-auth',
|
|
80
|
+
code=aws_lambda.Code.from_asset(
|
|
81
|
+
path=os.path.join(dirname, '../../lambda/check-auth/')
|
|
82
|
+
),
|
|
83
|
+
edge_role=self.edge_role,
|
|
84
|
+
configuration=self.configuration,
|
|
85
|
+
event_type=aws_cloudfront.LambdaEdgeEventType.VIEWER_REQUEST,
|
|
86
|
+
)
|
|
87
|
+
|
|
88
|
+
self.parse_auth = EdgeFunction(
|
|
89
|
+
self,
|
|
90
|
+
'ParseAuth',
|
|
91
|
+
name='parse-auth',
|
|
92
|
+
code=aws_lambda.Code.from_asset(
|
|
93
|
+
path=os.path.join(dirname, '../../lambda/parse-auth/')
|
|
94
|
+
),
|
|
95
|
+
edge_role=self.edge_role,
|
|
96
|
+
configuration=self.configuration,
|
|
97
|
+
event_type=aws_cloudfront.LambdaEdgeEventType.VIEWER_REQUEST,
|
|
98
|
+
)
|
|
99
|
+
|
|
100
|
+
self.refresh_auth = EdgeFunction(
|
|
101
|
+
self,
|
|
102
|
+
'RefreshAuth',
|
|
103
|
+
name='refresh-auth',
|
|
104
|
+
code=aws_lambda.Code.from_asset(
|
|
105
|
+
path=os.path.join(dirname, '../../lambda/refresh-auth/')
|
|
106
|
+
),
|
|
107
|
+
edge_role=self.edge_role,
|
|
108
|
+
configuration=self.configuration,
|
|
109
|
+
event_type=aws_cloudfront.LambdaEdgeEventType.VIEWER_REQUEST,
|
|
110
|
+
)
|
|
111
|
+
|
|
112
|
+
self.sign_out = EdgeFunction(
|
|
113
|
+
self,
|
|
114
|
+
'SignOut',
|
|
115
|
+
name='sign-out',
|
|
116
|
+
code=aws_lambda.Code.from_asset(
|
|
117
|
+
path=os.path.join(dirname, '../../lambda/sign-out/')
|
|
118
|
+
),
|
|
119
|
+
edge_role=self.edge_role,
|
|
120
|
+
configuration=self.configuration,
|
|
121
|
+
event_type=aws_cloudfront.LambdaEdgeEventType.VIEWER_REQUEST,
|
|
122
|
+
)
|
|
123
|
+
|
|
124
|
+
def add_edge_function(
|
|
125
|
+
self, name, path, event_type: aws_cloudfront.LambdaEdgeEventType
|
|
126
|
+
):
|
|
127
|
+
return EdgeFunction(
|
|
128
|
+
self,
|
|
129
|
+
name,
|
|
130
|
+
name=name,
|
|
131
|
+
code=aws_lambda.Code.from_asset(
|
|
132
|
+
path=os.path.join(dirname, f'../../lambda/{path}')
|
|
133
|
+
),
|
|
134
|
+
edge_role=self.edge_role,
|
|
135
|
+
configuration=self.configuration,
|
|
136
|
+
event_type=event_type,
|
|
137
|
+
)
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import builtins
|
|
2
|
+
import aws_cdk
|
|
3
|
+
import constructs
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class BaseEdgeConstruct(constructs.Construct):
|
|
7
|
+
def __init__(self, scope: constructs.Construct, id: builtins.str) -> None:
|
|
8
|
+
"""
|
|
9
|
+
:param scope: -
|
|
10
|
+
:param id: -
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
super().__init__(scope, id)
|
|
14
|
+
|
|
15
|
+
self._stack = aws_cdk.Stack.of(self)
|
|
16
|
+
|
|
17
|
+
self._edge_stack = (
|
|
18
|
+
self.get_or_create_cross_region_support_stack()
|
|
19
|
+
if self.stack.region != 'us-east-1'
|
|
20
|
+
else self.stack
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
@property
|
|
24
|
+
def stack(self):
|
|
25
|
+
return self._stack
|
|
26
|
+
|
|
27
|
+
@property
|
|
28
|
+
def edge_stack(self):
|
|
29
|
+
return self._edge_stack
|
|
30
|
+
|
|
31
|
+
def get_or_create_cross_region_support_stack(self) -> aws_cdk.Stack:
|
|
32
|
+
|
|
33
|
+
stack = self.stack.nested_stack_parent or self.stack
|
|
34
|
+
account = stack.account
|
|
35
|
+
stack_name = stack.stack_name
|
|
36
|
+
stack_id = 'lambda-cloudfront-support-stack'
|
|
37
|
+
app = self.require_app()
|
|
38
|
+
|
|
39
|
+
support_stack: aws_cdk.Stack = app.node.try_find_child(stack_id)
|
|
40
|
+
|
|
41
|
+
if support_stack is None:
|
|
42
|
+
support_stack = aws_cdk.Stack(
|
|
43
|
+
app,
|
|
44
|
+
stack_id,
|
|
45
|
+
stack_name=f'{stack_name}-support-lambda-cloudfront',
|
|
46
|
+
env={'account': account, 'region': 'us-east-1'},
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
# the stack containing the edge lambdas must be deployed before
|
|
50
|
+
self.stack.add_dependency(support_stack)
|
|
51
|
+
|
|
52
|
+
return support_stack
|
|
53
|
+
|
|
54
|
+
def require_app(self) -> aws_cdk.App:
|
|
55
|
+
|
|
56
|
+
app = self.node.root
|
|
57
|
+
|
|
58
|
+
if app is None or aws_cdk.App.is_app(app) is False:
|
|
59
|
+
raise Exception(
|
|
60
|
+
'Stacks which uses edge constructs must be part of a CDK app'
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
return app
|