When uncommenting lines 94-104 in /ecsdemo-frontend/cdk/app.py to enable autoscaling :
# Enable Service Autoscaling
self.autoscale = fargate_load_balanced_service.service.auto_scale_task_count(
min_capacity=1,
max_capacity=10
)
cdk synth yields:
Traceback (most recent call last):
File "xxx/ecsdemo-frontend/cdk/app.py", line 349, in <module>
FrontendService(app, stack_name, env=_env)
File "xxx/.venv/lib/python3.11/site-packages/jsii/_runtime.py", line 118, in __call__
inst = super(JSIIMeta, cast(JSIIMeta, cls)).__call__(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "xxx/ecsdemo-frontend/cdk/app.py", line 94, in __init__
self.autoscale = fargate_load_balanced_service.service.auto_scale_task_count(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
NameError: name 'fargate_load_balanced_service' is not defined
Subprocess exited with error 1
Fix to self.fargate_load_balanced_service.service.auto_scale_task_count(...) line 94
# Enable Service Autoscaling
self.autoscale = self.fargate_load_balanced_service.service.auto_scale_task_count(
min_capacity=1,
max_capacity=10
)
When uncommenting lines 94-104 in /ecsdemo-frontend/cdk/app.py to enable autoscaling :
cdk synth
yields:Fix to
self.fargate_load_balanced_service.service.auto_scale_task_count(...)
line 94Then all is well!