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 }}