How to execute AWS CLI command which is stored in variable from ansible playbook

How to execute AWS CLI command dynamically that is stored in variable of ansible playbook. Please share respective ansible script.

Server has AWS CLI utility that is in below path
path: /usr/local/bin/aws

ansibledba is the OS user which need to run the ansbible playbook using sudo command

You can do that, but instead of running a custom aws command from a variable, you should see if the aws collection has a module for what you’re trying to do.

- hosts: all
  vars:
    custom_awscli_command: somecommand
  tasks:
    - name: Run variable command
      ansible.builtin.shell:
        cmd: /usr/local/bin/aws {{ custom_awscli_command }}