compose-x / ecs_composex

Manage, Configure and Deploy your services and AWS services and applications from your docker-compose definitions
https://docs.compose-x.io
Mozilla Public License 2.0
165 stars 17 forks source link

[DOCS] Nginx example x-elbv2 schema #768

Closed mrmattwilkins closed 1 month ago

mrmattwilkins commented 3 months ago

Hi John, In your aws-compose-x.yaml you have a x-elbv2 section that doesn't appear to parse properly.

> ecs-compose-x plan -f docker-compose.yaml -f aws-compose-x.yaml -n frontend-app

2024-06-07 11:15:48 [    INFO] Update service frontend image to blah.dkr.ecr.ap-southeast-2.amazonaws.com/frontend@sha256:stuff
2024-06-07 11:15:48 [    INFO] services.frontend - No Launch Type defined. Using default: FARGATE
2024-06-07 11:15:50 [    INFO] frontend - No scan to be evaluated.
2024-06-07 11:15:50 [    INFO] frontend.frontend - ECR Scan Pass (No vulnerabilities found)
2024-06-07 11:15:50 [    INFO] Service families to process ['frontend']
2024-06-07 11:15:50 [    INFO] No cluster information provided. Creating a new one
Loaded x-elbv2 elbv2 elbv2 /var/tmp/venvs/aws/lib/python3.12/site-packages/ecs_composex/elbv2
2024-06-07 11:15:50 [   ERROR] elbv2.public-alb - Definition is not conform to schema.
Traceback (most recent call last):
  File "/var/tmp/venvs/aws/bin/ecs-compose-x", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/var/tmp/venvs/aws/lib/python3.12/site-packages/ecs_composex/cli.py", line 206, in main
    root_stack = generate_full_template(settings)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/var/tmp/venvs/aws/lib/python3.12/site-packages/ecs_composex/ecs_composex.py", line 248, in generate_full_template
    settings.mod_manager.init_mods_resources(settings)
  File "/var/tmp/venvs/aws/lib/python3.12/site-packages/ecs_composex/mods_manager.py", line 307, in init_mods_resources
    module.set_resources(settings)
  File "/var/tmp/venvs/aws/lib/python3.12/site-packages/ecs_composex/mods_manager.py", line 266, in set_resources
    new_definition = self.resource_class(
                     ^^^^^^^^^^^^^^^^^^^^
  File "/var/tmp/venvs/aws/lib/python3.12/site-packages/ecs_composex/elbv2/elbv2_stack/elbv2.py", line 75, in __init__
    super().__init__(name, definition, module, settings)
  File "/var/tmp/venvs/aws/lib/python3.12/site-packages/ecs_composex/compose/x_resources/network_x_resources.py", line 37, in __init__
    super().__init__(name, definition, module, settings)
  File "/var/tmp/venvs/aws/lib/python3.12/site-packages/ecs_composex/compose/x_resources/services_resources.py", line 39, in __init__
    super().__init__(name, definition, module, settings)
  File "/var/tmp/venvs/aws/lib/python3.12/site-packages/ecs_composex/compose/x_resources/__init__.py", line 79, in __init__
    self.validate_schema(name, definition, module.mod_key)
  File "/var/tmp/venvs/aws/lib/python3.12/site-packages/ecs_composex/compose/x_resources/__init__.py", line 191, in validate_schema
    _eval.validate(definition)
  File "/var/tmp/venvs/aws/lib/python3.12/site-packages/jsonschema/validators.py", line 451, in validate
    raise error
jsonschema.exceptions.ValidationError: [{'name': 'frontend:frontend', 'port': 80, 'protocol': 'HTTP', 'healthcheck': '80:HTTP:/:200'}] is not of type 'object'

Failed validating 'type' in schema['properties']['Services']:
    {'additionalProperties': False,
     'patternProperties': {'^[a-zA-Z0-9\\:_\\-]+$': {'$ref': '#/definitions/TargetDef'},
                           'x-': {}},
     'type': 'object'}

On instance['Services']:
    [{'healthcheck': '80:HTTP:/:200',
      'name': 'frontend:frontend',
      'port': 80,
      'protocol': 'HTTP'}]

Perhaps the example needs updating? Thanks!

JohnPreston commented 3 months ago

Thank you @mrmattwilkins for the report. I will look into all that

mrmattwilkins commented 3 months ago

Hi John, I'm giving copilot a go now, it seems to do what I need thanks!

JohnPreston commented 1 month ago

Should be fixed with https://github.com/compose-x/ecs_composex/commit/da8c52890279a810c856e03fa0b89da0f72bcbd7