Use aws_ssm module for this purpose:
- name: example
rabbitmq_user:
user: "{{ lookup('aws_ssm', 'user', region='us-east-1') }}"
password: "{{ lookup('aws_ssm', 'password', region='us-east-1') }}
state: present
force: yes
become: yes
become_method: sudo
become_user: root
register: example
notify:
- restart rabbitmq-server