# S3 - File download to EC2 Windows Instance

**URL:** <https://forum.ansible.com/t/s3-file-download-to-ec2-windows-instance/27405>\
**Category:** Ansible Project\
**Tags:** windows\
**Created:** [April 29, 2018, 8:59am UTC](https://forum.ansible.com/t/s3-file-download-to-ec2-windows-instance/27405 "2018-04-29T08:59:35Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ali.khawaja](https://avatars.discourse-cdn.com/v4/letter/a/e36b37/32.png) [@ali.khawaja](https://forum.ansible.com/u/ali.khawaja)\
**Post date:** [April 29, 2018, 8:59am UTC](https://forum.ansible.com/t/s3-file-download-to-ec2-windows-instance/27405/1 "2018-04-29T08:59:35Z")

</div>

I am trying to achieve the following:

1. Create ec2 instance (play 1)
2. Configure some services (play 2)
3. Download some iso from my s3 bucket to the ec2 instance (sql, etc)
4. Install

I have a play with hosts set to localhost to create ec2 instance. Its working fine.

- name: infrastructure setup

hosts: localhost

gather\_facts: no

vars\_files:

- testcfg.yml

tasks:

- ec2:

…

register: ec2\_result

- name: add hosts to group

add\_host:

…

group: windows

with\_items: “{{ ec2\_result.instances }}”

the second play uses hosts: windows (the host group that I created in previous play) to configure windows services. Its working fine as well

- name: Server Setup Play

hosts: windows

vars\_files:

- testcfg.yml

gather\_facts: false

tasks:

- win\_feature:

name: AS-Web-Support

now, I want to download a file from S3 into this ec2 instance. This is where I am having problem. What I have figured out (rightly or wrongly) is that I have to create a new play with hosts=localhost, otherwise if I stay within the previous play, the command will execute remotely over winrm which I don’t want to do. If I create a new play with hosts=localhost, how can I tell aws\_s3 what my destination will be?

- name: S3 Play

hosts: localhost

vars\_files:

- testcfg.yml

gather\_facts: false

tasks:

- name: get sql iso from s3 to the newly created server

aws\_s3:

region: ‘{{ region }}’

bucket: “{{ bucket }}”

object: …

dest: ???
