I have written a simple Ansible yaml script for copying files from local to S3 bucket for restored it which deployed files in client instance. Variables are {{SERVICE}}}, {{CONFIG_LOCATION}}, {{APP_NAME}} and {{ S3_BUCKET }} you have to specify in vars-main.yaml file


---
- hosts: hostname
  become: yes
  become_user: username
## You can include vars_files
  vars_files:
    - vars-main.yml
## Restart the service once you made any changes
  handlers:
    - name: restart "{{ SERVICE }}"
      service: name={{SERVICE}}.service state=restarted
  tasks:
    - name: Copying credentials and confg files are from your location to .aws
      copy:
        src: "{{CONFIG_LOCATION}}/{{item}}"
        dest: /username/.aws
        owner: username
        group: username
        mode: 0600
      with_items:
        ['credentials', 'config']

#### S3
    - name: "copy to S3 bucket"
      s3_sync:
        bucket: your-bucket-name
        file_username: "/tmp/{{APP_NAME}}_rollback"
        key_prefix: Deployment/{{APP_NAME}}_rollback
        file_change_strategy: force
        include: "*"
        permission: private
        mode: push

    - name: Remove credentials and config files
      file:
        path: /username/.aws/{{item}}
        state: absent
      with_items:
        ['credentials', 'config']