Trying to get a simple example of mode geturl in ansible module aws_s3. I tried searching online but didn't see any help.
Went through the official doc as well Docs but no luck.
Any help would be appreciated.
Trying to get a simple example of mode geturl in ansible module aws_s3. I tried searching online but didn't see any help.
Went through the official doc as well Docs but no luck.
Any help would be appreciated.
I don't have an S3 access to test against.... but from what I can see in the documentation and more specifically in the return values, you should be able to transform any get existing example, e.g.
- name: Simple geturl operation
aws_s3:
bucket: mybucket
object: /my/desired/key.txt
mode: geturl
register: geturl_result
- name: Use result
debug:
msg: >-
The url for the latest geturl operation is {{ geturl_result.url }}
and is valid for the next {{ geturl_result.expiry }} seconds
The solution posted by @Zeitounator should work :) . Just want to add what I have tested. Please check if this works for you.
- name: Simple GET URL operation
aws_s3:
bucket: "{{ bucket_name }}"
aws_access_key: "{{ var_aws_access_key }}"
aws_secret_key: "{{ var_aws_secret_key }}"
object: "{{ dir1 }}/{{ filename }}"
expiration: 10800
mode: geturl
register: url_output
Here
bucket_name : is the name of the bucket
object: is the key-for-the-object
expiration: is the expiration time for the URL in seconds
The rest of the values are self explainatory.