Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add task to get a list of all ECS clusters #2056

Open
1 task done
b0tting opened this issue Mar 5, 2024 · 2 comments · May be fixed by #2058
Open
1 task done

Add task to get a list of all ECS clusters #2056

b0tting opened this issue Mar 5, 2024 · 2 comments · May be fixed by #2058

Comments

@b0tting
Copy link

b0tting commented Mar 5, 2024

Summary

We want to control our AWS ECS services, for example, to restart all services in all accounts when Fargate is updated. For this reason, we run our playbooks against many clusters and we want the cluster_name to be discovered. However, all of the community.aws ECS modules either require a cluster name variable or add one with a default value of "default". I could not find a way to list the ECS cluster names, ie. the equivalent of "aws ecs list-clusters".

Issue Type

Feature Idea

Component Name

community.aws.ecs_cluster

Additional Information

This could be implemented similar to the way services are handled in community.aws.ecs_service_info - if no service_name is given, all services are queried.

Code of Conduct

  • I agree to follow the Ansible Code of Conduct
@markuman
Copy link
Member

markuman commented Mar 5, 2024

Two ideas about it

  1. rework community.aws.ecs_service_info

If the cluster parameter is not given, it must return all services of all clusters.
I am not sure atm. Maybe it's just a bug and should work like that way already: https://github.com/ansible-collections/community.aws/blob/main/plugins/modules/ecs_service_info.py#L218

  1. new module community.aws.ecs_cluster_info

A new module that just returns all existing clusters.

@b0tting
Copy link
Author

b0tting commented Mar 5, 2024

Just tested it, when running without the cluster parameter:

- name: "List all services in cluster {{ ecs_cluster }}"
  community.aws.ecs_service_info:
#     cluster: "{{ ecs_cluster }}"
    region: "{{ selected_region }}"
    aws_access_key: "{{ aws_access_key }}"
    aws_secret_key: "{{ aws_secret_key }}"
    aws_session_token: "{{ aws_session_token }}"
  register: ecs_services

...the result is a ClusterNotFound failure, with the following invocation parameters:

  "invocation": {
        "module_args": {
            "access_key": "...",
            "aws_access_key": "...",
            "aws_ca_bundle": null,
            "aws_config": null,
            "aws_secret_key": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "aws_session_token": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "cluster": null,
            "debug_botocore_endpoint_logs": false,
            "details": false,
            "endpoint_url": null,
            "events": true,
            "profile": null,
            "region": "eu-west-1",
            "secret_key": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "service": null,
            "session_token": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "validate_certs": true
        }
    },

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants