# How to download a s3 folder using playbook

**URL:** <https://forum.ansible.com/t/how-to-download-a-s3-folder-using-playbook/33771>\
**Category:** Ansible Project\
**Created:** [September 9, 2020, 6:16am UTC](https://forum.ansible.com/t/how-to-download-a-s3-folder-using-playbook/33771 "2020-09-09T06:16:25Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![surabhy\_vaishakh](https://avatars.discourse-cdn.com/v4/letter/s/f07891/32.png) [@surabhy\_vaishakh](https://forum.ansible.com/u/surabhy_vaishakh)\
**Post date:** [September 9, 2020, 6:16am UTC](https://forum.ansible.com/t/how-to-download-a-s3-folder-using-playbook/33771/1 "2020-09-09T06:16:25Z")

</div>

Can anyone help with this?  
I am trying to download a s3folder using ansible playbook.

---

<div class="post-metadata">

**Author:** ![Tom\_Black](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Tom\_Black](https://forum.ansible.com/u/Tom_Black)\
**Post date:** [September 9, 2020, 6:34am UTC](https://forum.ansible.com/t/how-to-download-a-s3-folder-using-playbook/33771/2 "2020-09-09T06:34:07Z")

</div>

surabhy vaishakh wrote:

> Can anyone help with this?  
> I am trying to download a s3folder using ansible playbook.

You should be able to use s3 SDK for this stuff.

aws s3 cp s3://Bucket/Folder LocalFolder --recursive

regards.

---

<div class="post-metadata">

**Author:** ![surabhy\_vaishakh](https://avatars.discourse-cdn.com/v4/letter/s/f07891/32.png) [@surabhy\_vaishakh](https://forum.ansible.com/u/surabhy_vaishakh)\
**Post date:** [September 9, 2020, 6:39am UTC](https://forum.ansible.com/t/how-to-download-a-s3-folder-using-playbook/33771/3 "2020-09-09T06:39:10Z")

</div>

Can you pls provide an example playbook

---

<div class="post-metadata">

**Author:** ![Mauro\_Ferrigno](https://avatars.discourse-cdn.com/v4/letter/m/c5a1d2/32.png) [@Mauro\_Ferrigno](https://forum.ansible.com/u/Mauro_Ferrigno)\
**Post date:** [September 9, 2020, 7:06am UTC](https://forum.ansible.com/t/how-to-download-a-s3-folder-using-playbook/33771/4 "2020-09-09T07:06:25Z")

</div>

Hello,  
I used aws\_s3 and file module to pull s3 bucket to local with folders and subfolders and files related, but please next time show your stuff and ask where you are in stuck

- name: get s3\_bucket\_items  
aws\_s3:  
mode: list  
bucket: “{{ automation\_bucket }}”  
register: s3\_bucket\_items

- name: “Create inventory folder recursively”  
file:  
path: “{{ item| dirname }}”  
state: directory  
recurse: true  
with\_items: “{{ s3\_bucket\_items.s3\_keys }}”

- name: “Download files from S3”  
aws\_s3:  
mode: get  
bucket: “{{ automation\_bucket }}”  
object: “{{ item }}”  
dest: “{{ item| dirname }}/{{ item|basename }}”  
with\_items: “{{ s3\_bucket\_items.s3\_keys }}”

---

<div class="post-metadata">

**Author:** ![surabhy\_vaishakh](https://avatars.discourse-cdn.com/v4/letter/s/f07891/32.png) [@surabhy\_vaishakh](https://forum.ansible.com/u/surabhy_vaishakh)\
**Post date:** [September 9, 2020, 7:23am UTC](https://forum.ansible.com/t/how-to-download-a-s3-folder-using-playbook/33771/5 "2020-09-09T07:23:38Z")

</div>

Where do you specify s3 url?  
I have used a synchronized module but it throws errors as below.

 ![image.png](https://us1.discourse-cdn.com/ansible/original/2X/0/0f13154a2981ad6c978a12f716826287a067df49.png)

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [September 9, 2020, 9:17am UTC](https://forum.ansible.com/t/how-to-download-a-s3-folder-using-playbook/33771/6 "2020-09-09T09:17:50Z")

</div>

Can you post the actual text instead of an (unreadable) screenshot?
