aws-containers / ecsdemo-frontend

MIT License
18 stars 358 forks source link

cdk/app.py Service Autoscaling NameError #18

Open SSE69 opened 3 months ago

SSE69 commented 3 months ago

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
        )

Then all is well!