cdk-factory 0.19.10__py3-none-any.whl → 0.19.19__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.
- cdk_factory/configurations/resources/lambda_edge.py +17 -3
- cdk_factory/stack_library/lambda_edge/EDGE_LOG_RETENTION_TODO.md +226 -0
- cdk_factory/stack_library/lambda_edge/lambda_edge_stack.py +118 -50
- cdk_factory/version.py +1 -1
- {cdk_factory-0.19.10.dist-info → cdk_factory-0.19.19.dist-info}/METADATA +1 -1
- {cdk_factory-0.19.10.dist-info → cdk_factory-0.19.19.dist-info}/RECORD +9 -8
- {cdk_factory-0.19.10.dist-info → cdk_factory-0.19.19.dist-info}/WHEEL +0 -0
- {cdk_factory-0.19.10.dist-info → cdk_factory-0.19.19.dist-info}/entry_points.txt +0 -0
- {cdk_factory-0.19.10.dist-info → cdk_factory-0.19.19.dist-info}/licenses/LICENSE +0 -0
|
@@ -49,10 +49,24 @@ class LambdaEdgeConfig(EnhancedBaseConfig):
|
|
|
49
49
|
|
|
50
50
|
@property
|
|
51
51
|
def timeout(self) -> int:
|
|
52
|
-
"""Timeout in seconds
|
|
52
|
+
"""Timeout in seconds
|
|
53
|
+
viewer-request: 5s
|
|
54
|
+
viewer-response: 5s
|
|
55
|
+
---
|
|
56
|
+
origin-request: 30s
|
|
57
|
+
origin-response: 30s
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
"""
|
|
53
61
|
timeout = int(self._config.get("timeout", 5))
|
|
54
|
-
|
|
55
|
-
|
|
62
|
+
|
|
63
|
+
event_type = self.event_type
|
|
64
|
+
if event_type == "viewer-request" or event_type == "viewer-response":
|
|
65
|
+
if timeout > 5:
|
|
66
|
+
raise ValueError("Lambda@Edge viewer timeout cannot exceed 5 seconds. Value was set to {}".format(timeout))
|
|
67
|
+
else:
|
|
68
|
+
if timeout > 30:
|
|
69
|
+
raise ValueError("Lambda@Edge origin timeout cannot exceed 30 seconds. Value was set to {}".format(timeout))
|
|
56
70
|
return timeout
|
|
57
71
|
|
|
58
72
|
@property
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
# Lambda@Edge Log Retention - Implementation Plan
|
|
2
|
+
|
|
3
|
+
## 🚨 Current Status: DISABLED
|
|
4
|
+
|
|
5
|
+
Lambda@Edge log retention configuration has been **disabled** because edge log groups are created on-demand when the function is invoked at edge locations, not during CloudFormation deployment.
|
|
6
|
+
|
|
7
|
+
## 🔍 Problem Analysis
|
|
8
|
+
|
|
9
|
+
### Why Deployment-Time Configuration Fails
|
|
10
|
+
1. **On-Demand Creation**: Lambda@Edge log groups are created only when the function is actually invoked at edge locations
|
|
11
|
+
2. **Timing Issue**: CloudFormation deployment happens before any edge invocations occur
|
|
12
|
+
3. **Error**: `The specified log group does not exist` when trying to set retention policies
|
|
13
|
+
|
|
14
|
+
### Log Group Naming Pattern
|
|
15
|
+
```
|
|
16
|
+
Pattern: /aws/lambda/{edge-region}.{function-name}
|
|
17
|
+
Example: /aws/lambda/eu-central-1.trav-talks-blue-green-edge-function
|
|
18
|
+
Location: All edge log groups are created in us-east-1
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## 💡 Proposed Solutions
|
|
22
|
+
|
|
23
|
+
### Solution 1: EventBridge + Lambda (Recommended)
|
|
24
|
+
```yaml
|
|
25
|
+
# EventBridge rule to detect log group creation
|
|
26
|
+
EventPattern:
|
|
27
|
+
source: ["aws.logs"]
|
|
28
|
+
detail-type: ["AWS API Call via CloudTrail"]
|
|
29
|
+
detail:
|
|
30
|
+
eventSource: ["logs.amazonaws.com"]
|
|
31
|
+
eventName: ["CreateLogGroup"]
|
|
32
|
+
requestParameters:
|
|
33
|
+
logGroupName: ["/aws/lambda/*.edge-function"]
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
**Implementation:**
|
|
37
|
+
1. Create EventBridge rule that triggers on log group creation
|
|
38
|
+
2. Lambda function receives event and sets retention policy
|
|
39
|
+
3. Automatic handling of new edge log groups
|
|
40
|
+
|
|
41
|
+
**Pros:**
|
|
42
|
+
- Automatic and real-time
|
|
43
|
+
- No manual intervention required
|
|
44
|
+
- Handles all edge regions
|
|
45
|
+
|
|
46
|
+
**Cons:**
|
|
47
|
+
- Additional Lambda function to maintain
|
|
48
|
+
- Requires CloudTrail enabled for CloudWatch Logs
|
|
49
|
+
|
|
50
|
+
### Solution 2: Periodic Lambda Function
|
|
51
|
+
```python
|
|
52
|
+
def lambda_handler(event, context):
|
|
53
|
+
# Scan for edge log groups
|
|
54
|
+
log_groups = logs.describe_log_groups(
|
|
55
|
+
logGroupNamePrefix='/aws/lambda/eu-central-1.trav-talks-blue-green-edge-function'
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
# Apply retention policy
|
|
59
|
+
for log_group in log_groups['logGroups']:
|
|
60
|
+
logs.put_retention_policy(
|
|
61
|
+
logGroupName=log_group['logGroupName'],
|
|
62
|
+
retentionInDays=7
|
|
63
|
+
)
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
**Implementation:**
|
|
67
|
+
1. Create Lambda function on schedule (e.g., every hour)
|
|
68
|
+
2. Scan for edge log groups with function name pattern
|
|
69
|
+
3. Apply retention policy if not already set
|
|
70
|
+
|
|
71
|
+
**Pros:**
|
|
72
|
+
- Simple to implement
|
|
73
|
+
- No CloudTrail dependency
|
|
74
|
+
- Can handle existing log groups
|
|
75
|
+
|
|
76
|
+
**Cons:**
|
|
77
|
+
- Not real-time (delayed retention)
|
|
78
|
+
- Runs periodically even when not needed
|
|
79
|
+
|
|
80
|
+
### Solution 3: Post-Deployment Script
|
|
81
|
+
```bash
|
|
82
|
+
#!/bin/bash
|
|
83
|
+
# Wait for edge log groups to appear
|
|
84
|
+
function_name="trav-talks-blue-green-edge-function"
|
|
85
|
+
edge_regions=("eu-central-1" "eu-west-1" "ap-southeast-1")
|
|
86
|
+
|
|
87
|
+
for region in "${edge_regions[@]}"; do
|
|
88
|
+
log_group="/aws/lambda/${region}.${function_name}"
|
|
89
|
+
|
|
90
|
+
# Wait for log group to exist
|
|
91
|
+
until aws logs describe-log-groups --log-group-name-prefix "$log_group" --region us-east-1; do
|
|
92
|
+
echo "Waiting for log group: $log_group"
|
|
93
|
+
sleep 30
|
|
94
|
+
done
|
|
95
|
+
|
|
96
|
+
# Set retention policy
|
|
97
|
+
aws logs put-retention-policy --log-group-name "$log_group" --retention-in-days 7 --region us-east-1
|
|
98
|
+
done
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
**Implementation:**
|
|
102
|
+
1. Script runs after Lambda@Edge deployment
|
|
103
|
+
2. Waits for edge log groups to be created
|
|
104
|
+
3. Sets retention policies when they appear
|
|
105
|
+
|
|
106
|
+
**Pros:**
|
|
107
|
+
- Direct control over timing
|
|
108
|
+
- No additional AWS resources needed
|
|
109
|
+
|
|
110
|
+
**Cons:**
|
|
111
|
+
- Manual process
|
|
112
|
+
- Hard to determine when log groups will appear
|
|
113
|
+
- Not automated
|
|
114
|
+
|
|
115
|
+
### Solution 4: CloudWatch Logs Subscription
|
|
116
|
+
```python
|
|
117
|
+
# Lambda triggered by log group creation via subscription filter
|
|
118
|
+
def lambda_handler(event, context):
|
|
119
|
+
for record in event['Records']:
|
|
120
|
+
log_group = record['logGroup']
|
|
121
|
+
if 'edge-function' in log_group:
|
|
122
|
+
# Set retention policy
|
|
123
|
+
logs.put_retention_policy(
|
|
124
|
+
logGroupName=log_group,
|
|
125
|
+
retentionInDays=7
|
|
126
|
+
)
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
**Implementation:**
|
|
130
|
+
1. Create subscription filter on log group pattern
|
|
131
|
+
2. Lambda function triggered by log events
|
|
132
|
+
3. Set retention policy on first log event
|
|
133
|
+
|
|
134
|
+
**Pros:**
|
|
135
|
+
- Event-driven
|
|
136
|
+
- No CloudTrail needed
|
|
137
|
+
|
|
138
|
+
**Cons:**
|
|
139
|
+
- Requires log group to exist first
|
|
140
|
+
- Complex subscription filter setup
|
|
141
|
+
|
|
142
|
+
## 🎯 Recommended Implementation
|
|
143
|
+
|
|
144
|
+
### Phase 1: Quick Win (Solution 2)
|
|
145
|
+
Implement periodic Lambda function as temporary solution:
|
|
146
|
+
- Easy to implement quickly
|
|
147
|
+
- Solves immediate problem
|
|
148
|
+
- Can be replaced later with better solution
|
|
149
|
+
|
|
150
|
+
### Phase 2: Production Solution (Solution 1)
|
|
151
|
+
Implement EventBridge + Lambda for production:
|
|
152
|
+
- Real-time response
|
|
153
|
+
- Automatic handling
|
|
154
|
+
- Best long-term solution
|
|
155
|
+
|
|
156
|
+
## 📋 Implementation Steps for Solution 1
|
|
157
|
+
|
|
158
|
+
### 1. Create EventBridge Rule
|
|
159
|
+
```python
|
|
160
|
+
event_rule = events.Rule(
|
|
161
|
+
self, "EdgeLogGroupRule",
|
|
162
|
+
event_pattern=events.EventPattern(
|
|
163
|
+
source=["aws.logs"],
|
|
164
|
+
detail_type=["AWS API Call via CloudTrail"],
|
|
165
|
+
detail={
|
|
166
|
+
"eventSource": ["logs.amazonaws.com"],
|
|
167
|
+
"eventName": ["CreateLogGroup"],
|
|
168
|
+
"requestParameters": {
|
|
169
|
+
"logGroupName": [{"prefix": "/aws/lambda/"}]
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
)
|
|
173
|
+
)
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### 2. Create Lambda Function
|
|
177
|
+
```python
|
|
178
|
+
retention_handler = _lambda.Function(
|
|
179
|
+
self, "EdgeLogRetentionHandler",
|
|
180
|
+
runtime=_lambda.Runtime.PYTHON_3_9,
|
|
181
|
+
handler="handler.lambda_handler",
|
|
182
|
+
code=_lambda.Code.from_asset("lambda/edge_log_retention"),
|
|
183
|
+
environment={
|
|
184
|
+
"RETENTION_DAYS": "7",
|
|
185
|
+
"FUNCTION_NAME_PATTERN": "*edge-function"
|
|
186
|
+
}
|
|
187
|
+
)
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
### 3. Add Permissions
|
|
191
|
+
```python
|
|
192
|
+
retention_handler.add_to_role_policy(
|
|
193
|
+
iam.PolicyStatement(
|
|
194
|
+
actions=["logs:PutRetentionPolicy", "logs:DescribeLogGroups"],
|
|
195
|
+
resources=["*"]
|
|
196
|
+
)
|
|
197
|
+
)
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
### 4. Connect EventBridge to Lambda
|
|
201
|
+
```python
|
|
202
|
+
event_rule.add_target(targets.LambdaFunction(retention_handler))
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
## 🔧 Current Configuration
|
|
206
|
+
|
|
207
|
+
The edge log retention configuration is currently **disabled** in the Lambda Edge stack:
|
|
208
|
+
|
|
209
|
+
```python
|
|
210
|
+
def _configure_edge_log_retention(self, function_name: str) -> None:
|
|
211
|
+
# DISABLED: See implementation plan above
|
|
212
|
+
logger.warning("Edge log retention disabled - see TODO for implementation")
|
|
213
|
+
return
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
## 📊 Configuration Impact
|
|
217
|
+
|
|
218
|
+
| Setting | Current Behavior | Target Behavior |
|
|
219
|
+
|---------|------------------|-----------------|
|
|
220
|
+
| `edge_log_retention_days` | Warning logged, no action applied | Retention policy set on all edge log groups |
|
|
221
|
+
| Edge log groups | Created with default retention (never expire) | Created with specified retention (e.g., 7 days) |
|
|
222
|
+
| Cost impact | Potential high log storage costs | Controlled log storage costs |
|
|
223
|
+
|
|
224
|
+
---
|
|
225
|
+
|
|
226
|
+
**Status**: Ready for implementation when edge log retention is required.
|
|
@@ -100,6 +100,9 @@ class LambdaEdgeStack(IStack, StandardizedSsmMixin):
|
|
|
100
100
|
# Create version (required for Lambda@Edge)
|
|
101
101
|
self._create_function_version(function_name)
|
|
102
102
|
|
|
103
|
+
# Configure edge log retention for regional logs
|
|
104
|
+
self._configure_edge_log_retention(function_name)
|
|
105
|
+
|
|
103
106
|
# Add outputs
|
|
104
107
|
self._add_outputs(function_name)
|
|
105
108
|
|
|
@@ -245,19 +248,12 @@ class LambdaEdgeStack(IStack, StandardizedSsmMixin):
|
|
|
245
248
|
self.edge_config.runtime,
|
|
246
249
|
_lambda.Runtime.PYTHON_3_11
|
|
247
250
|
)
|
|
248
|
-
|
|
249
|
-
# Lambda@Edge does NOT support environment variables
|
|
250
|
-
# Configuration must be handled via:
|
|
251
|
-
# 1. Hardcoded in the function code
|
|
252
|
-
# 2. Fetched from SSM Parameter Store at runtime
|
|
253
|
-
# 3. Other configuration mechanisms
|
|
254
|
-
|
|
251
|
+
|
|
255
252
|
# Log warning if environment variables are configured
|
|
256
253
|
if self.edge_config.environment:
|
|
257
254
|
logger.warning(
|
|
258
255
|
f"Lambda@Edge function '{function_name}' has environment variables configured, "
|
|
259
|
-
"but Lambda@Edge does not support environment variables. "
|
|
260
|
-
"The function must fetch these values from SSM Parameter Store at runtime."
|
|
256
|
+
"but Lambda@Edge does not support environment variables. The function must fetch these values from SSM Parameter Store at runtime."
|
|
261
257
|
)
|
|
262
258
|
for key, value in self.edge_config.environment.items():
|
|
263
259
|
logger.warning(f" - {key}: {value}")
|
|
@@ -268,7 +264,8 @@ class LambdaEdgeStack(IStack, StandardizedSsmMixin):
|
|
|
268
264
|
f"{function_name}-Role",
|
|
269
265
|
assumed_by=iam.CompositePrincipal(
|
|
270
266
|
iam.ServicePrincipal("lambda.amazonaws.com"),
|
|
271
|
-
iam.ServicePrincipal("edgelambda.amazonaws.com")
|
|
267
|
+
iam.ServicePrincipal("edgelambda.amazonaws.com"),
|
|
268
|
+
iam.ServicePrincipal("cloudfront.amazonaws.com") # Add CloudFront service principal
|
|
272
269
|
),
|
|
273
270
|
description=f"Execution role for Lambda@Edge function {function_name}",
|
|
274
271
|
managed_policies=[
|
|
@@ -294,7 +291,20 @@ class LambdaEdgeStack(IStack, StandardizedSsmMixin):
|
|
|
294
291
|
)
|
|
295
292
|
)
|
|
296
293
|
|
|
297
|
-
#
|
|
294
|
+
# Add Secrets Manager permissions for origin secret access
|
|
295
|
+
execution_role.add_to_policy(
|
|
296
|
+
iam.PolicyStatement(
|
|
297
|
+
effect=iam.Effect.ALLOW,
|
|
298
|
+
actions=[
|
|
299
|
+
"secretsmanager:GetSecretValue",
|
|
300
|
+
"secretsmanager:DescribeSecret"
|
|
301
|
+
],
|
|
302
|
+
resources=[
|
|
303
|
+
f"arn:aws:secretsmanager:*:{cdk.Aws.ACCOUNT_ID}:secret:{self.deployment.environment}/{self.workload.name}/origin-secret*"
|
|
304
|
+
]
|
|
305
|
+
)
|
|
306
|
+
)
|
|
307
|
+
|
|
298
308
|
self.function = _lambda.Function(
|
|
299
309
|
self,
|
|
300
310
|
function_name,
|
|
@@ -307,6 +317,7 @@ class LambdaEdgeStack(IStack, StandardizedSsmMixin):
|
|
|
307
317
|
description=self.edge_config.description,
|
|
308
318
|
role=execution_role,
|
|
309
319
|
# Lambda@Edge does NOT support environment variables
|
|
320
|
+
# Configuration must be fetched from SSM at runtime
|
|
310
321
|
log_retention=logs.RetentionDays.ONE_WEEK,
|
|
311
322
|
)
|
|
312
323
|
|
|
@@ -314,6 +325,36 @@ class LambdaEdgeStack(IStack, StandardizedSsmMixin):
|
|
|
314
325
|
for key, value in self.edge_config.tags.items():
|
|
315
326
|
cdk.Tags.of(self.function).add(key, value)
|
|
316
327
|
|
|
328
|
+
# Add resource-based policy allowing CloudFront to invoke the Lambda function
|
|
329
|
+
# This is REQUIRED for Lambda@Edge to work properly
|
|
330
|
+
permission_kwargs = {
|
|
331
|
+
"principal": iam.ServicePrincipal("cloudfront.amazonaws.com"),
|
|
332
|
+
"action": "lambda:InvokeFunction",
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
# Optional: Add source ARN restriction if CloudFront distribution ARN is available
|
|
336
|
+
# This provides more secure permission scoping
|
|
337
|
+
distribution_arn_path = f"/{self.deployment.environment}/{self.workload.name}/cloudfront/arn"
|
|
338
|
+
try:
|
|
339
|
+
distribution_arn = ssm.StringParameter.from_string_parameter_name(
|
|
340
|
+
self,
|
|
341
|
+
"cloudfront-distribution-arn",
|
|
342
|
+
distribution_arn_path
|
|
343
|
+
).string_value
|
|
344
|
+
|
|
345
|
+
# Add source ARN condition for more secure permission scoping
|
|
346
|
+
permission_kwargs["source_arn"] = distribution_arn
|
|
347
|
+
logger.info(f"Adding CloudFront permission with source ARN restriction: {distribution_arn}")
|
|
348
|
+
except Exception:
|
|
349
|
+
# Distribution ARN not available (common during initial deployment)
|
|
350
|
+
# CloudFront will scope the permission appropriately when it associates the Lambda
|
|
351
|
+
logger.warning(f"CloudFront distribution ARN not found at {distribution_arn_path}, using open permission")
|
|
352
|
+
|
|
353
|
+
self.function.add_permission(
|
|
354
|
+
"CloudFrontInvokePermission",
|
|
355
|
+
**permission_kwargs
|
|
356
|
+
)
|
|
357
|
+
|
|
317
358
|
def _create_function_version(self, function_name: str) -> None:
|
|
318
359
|
"""
|
|
319
360
|
Create a version of the Lambda function.
|
|
@@ -329,10 +370,46 @@ class LambdaEdgeStack(IStack, StandardizedSsmMixin):
|
|
|
329
370
|
f"Version for Lambda@Edge deployment - {self.edge_config.description}"
|
|
330
371
|
)
|
|
331
372
|
|
|
332
|
-
def
|
|
333
|
-
"""
|
|
373
|
+
def _configure_edge_log_retention(self, function_name: str) -> None:
|
|
374
|
+
"""
|
|
375
|
+
Configure log retention for Lambda@Edge log groups in all edge regions
|
|
376
|
+
|
|
377
|
+
TODO: IMPLEMENT POST-DEPLOYMENT SOLUTION
|
|
378
|
+
--------------------------------------
|
|
379
|
+
Lambda@Edge log groups are created on-demand when the function is invoked
|
|
380
|
+
at edge locations, not during deployment. This means we cannot set retention
|
|
381
|
+
policies during CloudFormation deployment.
|
|
382
|
+
|
|
383
|
+
Possible solutions to implement:
|
|
384
|
+
1. EventBridge rule that triggers on log group creation
|
|
385
|
+
2. Custom Lambda function that runs periodically to set retention
|
|
386
|
+
3. Post-deployment script that waits for log groups to appear
|
|
387
|
+
4. CloudWatch Logs subscription filter that handles new log groups
|
|
388
|
+
|
|
389
|
+
Current behavior: DISABLED to prevent deployment failures
|
|
390
|
+
"""
|
|
391
|
+
|
|
392
|
+
# DISABLED: Edge log groups don't exist during deployment
|
|
393
|
+
# Lambda@Edge creates log groups on-demand at edge locations
|
|
394
|
+
# Setting retention policies during deployment fails with "log group does not exist"
|
|
334
395
|
|
|
396
|
+
edge_retention_days = self.edge_config.dictionary.get("edge_log_retention_days", 7)
|
|
397
|
+
logger.warning(
|
|
398
|
+
f"Edge log retention configuration disabled - log groups are created on-demand. "
|
|
399
|
+
f"Desired retention: {edge_retention_days} days. "
|
|
400
|
+
f"See TODO in _configure_edge_log_retention() for implementation approach."
|
|
401
|
+
)
|
|
402
|
+
|
|
403
|
+
# TODO: Implement one of these solutions:
|
|
404
|
+
# 1. EventBridge + Lambda: Trigger on log group creation and set retention
|
|
405
|
+
# 2. Periodic Lambda: Scan for edge log groups and apply retention policies
|
|
406
|
+
# 3. Post-deployment script: Wait for log groups to appear after edge replication
|
|
407
|
+
# 4. CloudWatch Logs subscription: Process new log group events
|
|
335
408
|
|
|
409
|
+
return
|
|
410
|
+
|
|
411
|
+
def _add_outputs(self, function_name: str) -> None:
|
|
412
|
+
"""Add CloudFormation outputs and SSM exports"""
|
|
336
413
|
|
|
337
414
|
# SSM Parameter Store exports (if configured)
|
|
338
415
|
ssm_exports = self.edge_config.dictionary.get("ssm", {}).get("exports", {})
|
|
@@ -355,40 +432,31 @@ class LambdaEdgeStack(IStack, StandardizedSsmMixin):
|
|
|
355
432
|
description=f"{key} for Lambda@Edge function {function_name}"
|
|
356
433
|
)
|
|
357
434
|
|
|
358
|
-
# Export
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
)
|
|
387
|
-
|
|
388
|
-
self.export_ssm_parameter(
|
|
389
|
-
self,
|
|
390
|
-
f"env-{env_key}-param",
|
|
391
|
-
env_value,
|
|
392
|
-
ssm_path,
|
|
393
|
-
description=f"Configuration for Lambda@Edge: {env_key}"
|
|
394
|
-
)
|
|
435
|
+
# Export the complete configuration as a single SSM parameter
|
|
436
|
+
config_ssm_path = f"/{self.deployment.environment}/{self.workload.name}/lambda-edge/config"
|
|
437
|
+
configuration = self.edge_config.dictionary.get("configuration", {})
|
|
438
|
+
environment_variables = configuration.get("environment_variables", {})
|
|
439
|
+
|
|
440
|
+
full_config = {
|
|
441
|
+
"environment_variables": environment_variables
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
self.export_ssm_parameter(
|
|
445
|
+
self,
|
|
446
|
+
"full-config-param",
|
|
447
|
+
json.dumps(full_config),
|
|
448
|
+
config_ssm_path,
|
|
449
|
+
description=f"Complete Lambda@Edge configuration for {function_name} - update this for dynamic changes"
|
|
450
|
+
)
|
|
451
|
+
|
|
452
|
+
# Export cache TTL parameter for dynamic cache control
|
|
453
|
+
cache_ttl_ssm_path = f"/{self.deployment.environment}/{self.workload.name}/lambda-edge/cache-ttl"
|
|
454
|
+
default_cache_ttl = self.edge_config.dictionary.get("cache_ttl_seconds", 300) # Default 5 minutes
|
|
455
|
+
|
|
456
|
+
self.export_ssm_parameter(
|
|
457
|
+
self,
|
|
458
|
+
"cache-ttl-param",
|
|
459
|
+
str(default_cache_ttl),
|
|
460
|
+
cache_ttl_ssm_path,
|
|
461
|
+
description=f"Lambda@Edge configuration cache TTL in seconds for {function_name} - adjust for maintenance windows (30-3600)"
|
|
462
|
+
)
|
cdk_factory/version.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = "0.19.
|
|
1
|
+
__version__ = "0.19.19"
|
|
@@ -2,7 +2,7 @@ cdk_factory/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
|
2
2
|
cdk_factory/app.py,sha256=RnX0-pwdTAPAdKJK_j13Zl8anf9zYKBwboR0KA8K8xM,10346
|
|
3
3
|
cdk_factory/cdk.json,sha256=SKZKhJ2PBpFH78j-F8S3VDYW-lf76--Q2I3ON-ZIQfw,3106
|
|
4
4
|
cdk_factory/cli.py,sha256=FGbCTS5dYCNsfp-etshzvFlGDCjC28r6rtzYbe7KoHI,6407
|
|
5
|
-
cdk_factory/version.py,sha256=
|
|
5
|
+
cdk_factory/version.py,sha256=7SkXrcCPPywUj5iTSUoEUN_6FonxdNwtTRVl_D3253s,24
|
|
6
6
|
cdk_factory/builds/README.md,sha256=9BBWd7bXpyKdMU_g2UljhQwrC9i5O_Tvkb6oPvndoZk,90
|
|
7
7
|
cdk_factory/commands/command_loader.py,sha256=QbLquuP_AdxtlxlDy-2IWCQ6D-7qa58aphnDPtp_uTs,3744
|
|
8
8
|
cdk_factory/configurations/base_config.py,sha256=eJ3Pl3GWk1jVr_bYQaaWlw4_-ZiFGaiXllI_fOOX1i0,9323
|
|
@@ -34,7 +34,7 @@ cdk_factory/configurations/resources/ecr.py,sha256=iJEtKqBT7vQU0LU4urIglraIR7cPZ
|
|
|
34
34
|
cdk_factory/configurations/resources/ecs_cluster.py,sha256=mQYJu7SUPDl5E4dMR6HCPFoWvFA3RGIb0iMNn-K7LX8,3635
|
|
35
35
|
cdk_factory/configurations/resources/ecs_service.py,sha256=bOWjVECd6Kbc5NGGSnDaopnKrjRsUfmaZ6-qrsmTs3Q,6468
|
|
36
36
|
cdk_factory/configurations/resources/exisiting.py,sha256=EVOLnkB-DGfTlmDgyQ5DD5k2zYfpFxqI3gugDR7mifI,478
|
|
37
|
-
cdk_factory/configurations/resources/lambda_edge.py,sha256=
|
|
37
|
+
cdk_factory/configurations/resources/lambda_edge.py,sha256=C0S6HrQe2QPfmhj1PhZ7FEnT2EidOg5t-pUFUsOzaDc,3855
|
|
38
38
|
cdk_factory/configurations/resources/lambda_function.py,sha256=VENZ9-ABJ5mjcN8J8wdLH4KHDYr1kWO0iFDH0B2mJXA,14659
|
|
39
39
|
cdk_factory/configurations/resources/lambda_layers.py,sha256=gVeP_-LC3Eq0lkPaG_JfFUwboM5evRPr99SfKj53m7A,633
|
|
40
40
|
cdk_factory/configurations/resources/lambda_triggers.py,sha256=MD7cdMNKEulNBhtMLIFnWJuJ5R-yyIqa0LHUgbSQerA,834
|
|
@@ -100,8 +100,9 @@ cdk_factory/stack_library/ecr/ecr_stack.py,sha256=KLbd5WN5-ZiojsS5wJ4PX-tIL0cCyl
|
|
|
100
100
|
cdk_factory/stack_library/ecs/__init__.py,sha256=o5vGDtD_h-gVXb3-Ysr8xUNpEcMsnmMVgZv2Pupcdow,219
|
|
101
101
|
cdk_factory/stack_library/ecs/ecs_cluster_stack.py,sha256=sAPTLU5CAwMoLTW_pNy_cd0OtVkfDR7IxxsSq5AE0yo,12091
|
|
102
102
|
cdk_factory/stack_library/ecs/ecs_service_stack.py,sha256=KB4YCIsMm5JIGM9Bm-bKcr3eX5xXFgnoA7jST_ekK44,28209
|
|
103
|
+
cdk_factory/stack_library/lambda_edge/EDGE_LOG_RETENTION_TODO.md,sha256=nD49nLm5OyrZUvcGNFBy9H1MfSUOuZ7sasHNI-IO0Zk,6635
|
|
103
104
|
cdk_factory/stack_library/lambda_edge/__init__.py,sha256=ByBJ_CWdc4UtTmFBZH-6pzBMNkjkdtE65AmnB0Fs6lM,156
|
|
104
|
-
cdk_factory/stack_library/lambda_edge/lambda_edge_stack.py,sha256=
|
|
105
|
+
cdk_factory/stack_library/lambda_edge/lambda_edge_stack.py,sha256=b8PE4v5zGsqu_mVOaPejb8JKkV6b83N-VS0AxSlLTtk,20119
|
|
105
106
|
cdk_factory/stack_library/load_balancer/__init__.py,sha256=wZpKw2OecLJGdF5mPayCYAEhu2H3c2gJFFIxwXftGDU,52
|
|
106
107
|
cdk_factory/stack_library/load_balancer/load_balancer_stack.py,sha256=ApW5q3SAvSJtiK0RInNljmubqXqKZU5QBAaUoeIW-pM,28287
|
|
107
108
|
cdk_factory/stack_library/monitoring/__init__.py,sha256=k1G_KDx47Aw0UugaL99PN_TKlyLK4nkJVApCaAK7GJg,153
|
|
@@ -136,8 +137,8 @@ cdk_factory/utilities/os_execute.py,sha256=5Op0LY_8Y-pUm04y1k8MTpNrmQvcLmQHPQITE
|
|
|
136
137
|
cdk_factory/utils/api_gateway_utilities.py,sha256=If7Xu5s_UxmuV-kL3JkXxPLBdSVUKoLtohm0IUFoiV8,4378
|
|
137
138
|
cdk_factory/validation/config_validator.py,sha256=Pb0TkLiPFzUplBOgMorhRCVm08vEzZhRU5xXCDTa5CA,17602
|
|
138
139
|
cdk_factory/workload/workload_factory.py,sha256=yDI3cRhVI5ELNDcJPLpk9UY54Uind1xQoV3spzT4z7E,6068
|
|
139
|
-
cdk_factory-0.19.
|
|
140
|
-
cdk_factory-0.19.
|
|
141
|
-
cdk_factory-0.19.
|
|
142
|
-
cdk_factory-0.19.
|
|
143
|
-
cdk_factory-0.19.
|
|
140
|
+
cdk_factory-0.19.19.dist-info/METADATA,sha256=syphI_KKN3_606LBfCKYQLU_3YX4ppprIwsKcAENNBk,2452
|
|
141
|
+
cdk_factory-0.19.19.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
142
|
+
cdk_factory-0.19.19.dist-info/entry_points.txt,sha256=S1DPe0ORcdiwEALMN_WIo3UQrW_g4YdQCLEsc_b0Swg,53
|
|
143
|
+
cdk_factory-0.19.19.dist-info/licenses/LICENSE,sha256=NOtdOeLwg2il_XBJdXUPFPX8JlV4dqTdDGAd2-khxT8,1066
|
|
144
|
+
cdk_factory-0.19.19.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|