cdk-factory 0.14.1__py3-none-any.whl → 0.15.0__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.

Potentially problematic release.


This version of cdk-factory might be problematic. Click here for more details.

@@ -292,8 +292,9 @@ class CloudFrontDistributionConstruct(Construct):
292
292
  logger.info(f"Using IP gate Lambda ARN from SSM: {ip_gate_ssm_path}")
293
293
 
294
294
  # Add the IP gating Lambda@Edge association
295
+ # MUST use viewer-request to run BEFORE cache check!
295
296
  lambda_edge_associations = [{
296
- "event_type": "origin-request",
297
+ "event_type": "viewer-request",
297
298
  "lambda_arn": f"{{{{ssm:{ip_gate_ssm_path}}}}}",
298
299
  "include_body": False
299
300
  }]
@@ -178,7 +178,58 @@ def lambda_handler(event, context):
178
178
  print(f"IP {client_ip} is allowed")
179
179
  return request
180
180
 
181
- # IP not allowed - redirect to maintenance page
181
+ # IP not allowed - either redirect or proxy maintenance page
182
+ # Check response mode from SSM (default: redirect for backward compatibility)
183
+ response_mode_param = f"/{function_name}/response-mode"
184
+ response_mode = get_ssm_parameter(response_mode_param, default='redirect')
185
+
186
+ if response_mode == 'proxy':
187
+ # Proxy mode: Fetch and return maintenance content (keeps URL the same)
188
+ print(f"IP {client_ip} is NOT allowed, proxying content from {maint_cf_host}")
189
+
190
+ try:
191
+ import urllib3
192
+ http = urllib3.PoolManager()
193
+
194
+ # Fetch the maintenance page
195
+ maint_response = http.request(
196
+ 'GET',
197
+ f'https://{maint_cf_host}',
198
+ headers={'User-Agent': 'CloudFront-IP-Gate-Proxy'},
199
+ timeout=3.0
200
+ )
201
+
202
+ # Return the maintenance content
203
+ response = {
204
+ 'status': str(maint_response.status),
205
+ 'statusDescription': 'OK' if maint_response.status == 200 else 'Service Unavailable',
206
+ 'headers': {
207
+ 'content-type': [{
208
+ 'key': 'Content-Type',
209
+ 'value': maint_response.headers.get('Content-Type', 'text/html')
210
+ }],
211
+ 'cache-control': [{
212
+ 'key': 'Cache-Control',
213
+ 'value': 'no-cache, no-store, must-revalidate, max-age=0'
214
+ }],
215
+ 'x-ip-gate-mode': [{
216
+ 'key': 'X-IP-Gate-Mode',
217
+ 'value': 'proxy'
218
+ }]
219
+ },
220
+ 'body': maint_response.data.decode('utf-8')
221
+ }
222
+
223
+ print(f"Successfully proxied maintenance page (status {maint_response.status})")
224
+ return response
225
+
226
+ except Exception as proxy_error:
227
+ print(f"Error proxying maintenance content: {str(proxy_error)}")
228
+ # Fall back to redirect if proxy fails
229
+ print(f"Falling back to redirect mode")
230
+ response_mode = 'redirect'
231
+
232
+ # Redirect mode (default): HTTP 302 redirect to maintenance site
182
233
  print(f"IP {client_ip} is NOT allowed, redirecting to {maint_cf_host}")
183
234
 
184
235
  response = {
@@ -192,6 +243,10 @@ def lambda_handler(event, context):
192
243
  'cache-control': [{
193
244
  'key': 'Cache-Control',
194
245
  'value': 'no-cache, no-store, must-revalidate'
246
+ }],
247
+ 'x-ip-gate-mode': [{
248
+ 'key': 'X-IP-Gate-Mode',
249
+ 'value': 'redirect'
195
250
  }]
196
251
  }
197
252
  }
cdk_factory/version.py CHANGED
@@ -1 +1 @@
1
- __version__ = "0.14.1"
1
+ __version__ = "0.15.0"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cdk_factory
3
- Version: 0.14.1
3
+ Version: 0.15.0
4
4
  Summary: CDK Factory. A QuickStarter and best practices setup for CDK projects
5
5
  Author-email: Eric Wilson <eric.wilson@geekcafe.com>
6
6
  License: MIT License
@@ -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=DcrUHmqhXJJz-Sh-CsHfn9W6Q5OL-VL2FalGEX5hy6E,23
5
+ cdk_factory/version.py,sha256=wGIgxINRfcIKyk0LjIbc9UF9UwuclyCQZv_axTUzwNw,23
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=JKjhNsy0RCUZy1s8n5D_aXXI-upR9izaLtCTfKYiV9k,9624
@@ -50,7 +50,7 @@ cdk_factory/configurations/resources/security_group.py,sha256=8kQtaaRVEn2aDm8XoC
50
50
  cdk_factory/configurations/resources/security_group_full_stack.py,sha256=x5MIMCa_olO7prFBKx9zVOfvsVdKo-2mWyhrCy27dFw,2031
51
51
  cdk_factory/configurations/resources/sqs.py,sha256=fAh2dqttJ6PX46enFRULuiLEu3TEj0Vb2xntAOgUpYE,4346
52
52
  cdk_factory/configurations/resources/vpc.py,sha256=sNn6w76bHFwmt6N76gZZhqpsuNB9860C1SZu6tebaXY,3835
53
- cdk_factory/constructs/cloudfront/cloudfront_distribution_construct.py,sha256=Co3pQ5NQVd5mXzPeGNN4UabvQVWyWL44xDyscNGAXUQ,21967
53
+ cdk_factory/constructs/cloudfront/cloudfront_distribution_construct.py,sha256=gFQw96rfSX7n3-YaK4AWyF2NNzJezgZpmnAcxZpmgxs,22036
54
54
  cdk_factory/constructs/ecr/ecr_construct.py,sha256=JLz3gWrsjlM0XghvbgxuoGlF-VIo_7IYxtgX7mTkidE,10660
55
55
  cdk_factory/constructs/lambdas/lambda_function_construct.py,sha256=SQ5SEXn4kezVAzXuv_A_JB3o_svyBXOMi-htvfB9HQs,4516
56
56
  cdk_factory/constructs/lambdas/lambda_function_docker_construct.py,sha256=O8aiHpNQ59eE3qEttEHVxbvp06v4byXOeYCVTAOI_Cg,9993
@@ -66,7 +66,7 @@ cdk_factory/interfaces/istack.py,sha256=bhTBs-o9FgKwvJMSuwxjUV6D3nUlvZHVzfm27jP9
66
66
  cdk_factory/interfaces/live_ssm_resolver.py,sha256=3FIr9a02SXqZmbFs3RT0WxczWEQR_CF7QSt7kWbDrVE,8163
67
67
  cdk_factory/interfaces/ssm_parameter_mixin.py,sha256=uA2j8HmAOpuEA9ynRj51s0WjUHMVLsbLQN-QS9NKyHA,12089
68
68
  cdk_factory/lambdas/health_handler.py,sha256=dd40ykKMxWCFEIyp2ZdQvAGNjw_ylI9CSm1N24Hp2ME,196
69
- cdk_factory/lambdas/edge/ip_gate/handler.py,sha256=I1LN7vuz8qZ7vhgG91yxCEm4uFqqOghsJzurT0DngcI,7396
69
+ cdk_factory/lambdas/edge/ip_gate/handler.py,sha256=pQzCK3r8Hc_XhR2A5FW5nlShi5c9z7By8Czd9Uqd3ws,9935
70
70
  cdk_factory/pipeline/path_utils.py,sha256=fvWdrcb4onmpIu1APkHLhXg8zWfK74HcW3Ra2ynxfXM,2586
71
71
  cdk_factory/pipeline/pipeline_factory.py,sha256=rvtkdlTPJG477nTVRN8S2ksWt4bwpd9eVLFd9WO02pM,17248
72
72
  cdk_factory/pipeline/stage.py,sha256=Be7ExMB9A-linRM18IQDOzQ-cP_I2_ThRNzlT4FIrUg,437
@@ -129,8 +129,8 @@ cdk_factory/utilities/lambda_function_utilities.py,sha256=S1GvBsY_q2cyUiaud3HORJ
129
129
  cdk_factory/utilities/os_execute.py,sha256=5Op0LY_8Y-pUm04y1k8MTpNrmQvcLmQHPQITEP7EuSU,1019
130
130
  cdk_factory/utils/api_gateway_utilities.py,sha256=If7Xu5s_UxmuV-kL3JkXxPLBdSVUKoLtohm0IUFoiV8,4378
131
131
  cdk_factory/workload/workload_factory.py,sha256=mM8GU_5mKq_0OyK060T3JrUSUiGAcKf0eqNlT9mfaws,6028
132
- cdk_factory-0.14.1.dist-info/METADATA,sha256=CeDWK6i4lTujrWo11UnQ49_HrdhmIsOSilsQppIGE_o,2451
133
- cdk_factory-0.14.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
134
- cdk_factory-0.14.1.dist-info/entry_points.txt,sha256=S1DPe0ORcdiwEALMN_WIo3UQrW_g4YdQCLEsc_b0Swg,53
135
- cdk_factory-0.14.1.dist-info/licenses/LICENSE,sha256=NOtdOeLwg2il_XBJdXUPFPX8JlV4dqTdDGAd2-khxT8,1066
136
- cdk_factory-0.14.1.dist-info/RECORD,,
132
+ cdk_factory-0.15.0.dist-info/METADATA,sha256=Da_9MBQTbK6XRX6OrC1ooR-ixBJLcfuTqmyg-dqQeVc,2451
133
+ cdk_factory-0.15.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
134
+ cdk_factory-0.15.0.dist-info/entry_points.txt,sha256=S1DPe0ORcdiwEALMN_WIo3UQrW_g4YdQCLEsc_b0Swg,53
135
+ cdk_factory-0.15.0.dist-info/licenses/LICENSE,sha256=NOtdOeLwg2il_XBJdXUPFPX8JlV4dqTdDGAd2-khxT8,1066
136
+ cdk_factory-0.15.0.dist-info/RECORD,,