-
Notifications
You must be signed in to change notification settings - Fork 342
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
s3_bucket transfer accleration (#2046)
Add support for S3 Bucket Transfer Acceleration: https://docs.aws.amazon.com/AmazonS3/latest/userguide/transfer-acceleration.html Reviewed-by: Helen Bailey <[email protected]> Reviewed-by: Alina Buzachis Reviewed-by: Mike Graves <[email protected]>
- Loading branch information
Showing
4 changed files
with
325 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
minor_changes: | ||
- s3_bucket - Add support for enabling Amazon S3 Transfer Acceleration by setting the ``accelerate_enabled`` option (https://github.com/ansible-collections/amazon.aws/pull/2046). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ encryption_sse | |
public_access | ||
acl | ||
object_lock | ||
accelerate | ||
|
||
[all:vars] | ||
ansible_connection=local | ||
|
215 changes: 215 additions & 0 deletions
215
tests/integration/targets/s3_bucket/roles/s3_bucket/tasks/accelerate.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,215 @@ | ||
--- | ||
- module_defaults: | ||
group/aws: | ||
access_key: "{{ aws_access_key }}" | ||
secret_key: "{{ aws_secret_key }}" | ||
session_token: "{{ security_token | default(omit) }}" | ||
region: "{{ aws_region }}" | ||
block: | ||
- ansible.builtin.set_fact: | ||
local_bucket_name: "{{ bucket_name | hash('md5')}}-accelerate" | ||
|
||
# ============================================================ | ||
|
||
- name: Create a simple bucket | ||
amazon.aws.s3_bucket: | ||
name: "{{ local_bucket_name }}" | ||
state: present | ||
register: output | ||
|
||
- ansible.builtin.assert: | ||
that: | ||
- output.changed | ||
- not output.accelerate_enabled | ||
|
||
- name: Re-disable transfer acceleration (idempotency) | ||
amazon.aws.s3_bucket: | ||
name: "{{ local_bucket_name }}" | ||
state: present | ||
accelerate_enabled: false | ||
register: output | ||
|
||
- ansible.builtin.assert: | ||
that: | ||
- not output.changed | ||
- not output.accelerate_enabled | ||
|
||
- name: Enable transfer acceleration | ||
amazon.aws.s3_bucket: | ||
name: "{{ local_bucket_name }}" | ||
state: present | ||
accelerate_enabled: true | ||
register: output | ||
ignore_errors: false | ||
|
||
- ansible.builtin.assert: | ||
that: | ||
- output.changed | ||
- output.accelerate_enabled | ||
|
||
- name: Assert transfer acceleration enabled | ||
amazon.aws.s3_bucket_info: | ||
name: "{{ local_bucket_name }}" | ||
bucket_facts: | ||
bucket_accelerate_configuration: true | ||
register: output | ||
|
||
- ansible.builtin.assert: | ||
that: | ||
- item.bucket_accelerate_configuration["Status"] == "Enabled" | ||
loop: "{{ output.buckets }}" | ||
loop_control: | ||
label: "{{ item.name }}" | ||
|
||
- name: Re-Enable transfer acceleration (idempotency) | ||
amazon.aws.s3_bucket: | ||
name: "{{ local_bucket_name }}" | ||
state: present | ||
accelerate_enabled: true | ||
register: output | ||
|
||
- ansible.builtin.assert: | ||
that: | ||
- not output.changed | ||
- output.accelerate_enabled | ||
|
||
- name: Assert transfer acceleration enabled | ||
amazon.aws.s3_bucket_info: | ||
name: "{{ local_bucket_name }}" | ||
bucket_facts: | ||
bucket_accelerate_configuration: true | ||
register: output | ||
|
||
- ansible.builtin.assert: | ||
that: | ||
- item.bucket_accelerate_configuration["Status"] == "Enabled" | ||
loop: "{{ output.buckets }}" | ||
loop_control: | ||
label: "{{ item.name }}" | ||
|
||
- name: Delete test s3 bucket | ||
amazon.aws.s3_bucket: | ||
name: "{{ local_bucket_name }}" | ||
state: absent | ||
register: output | ||
|
||
- ansible.builtin.assert: | ||
that: | ||
- output.changed | ||
|
||
# ============================================================ | ||
|
||
- name: Create a bucket with transfer accelerate enabled | ||
amazon.aws.s3_bucket: | ||
name: "{{ local_bucket_name }}-2" | ||
state: present | ||
accelerate_enabled: true | ||
register: output | ||
|
||
- ansible.builtin.assert: | ||
that: | ||
- output.changed | ||
- output.accelerate_enabled | ||
|
||
- name: Assert transfer acceleration enabled | ||
amazon.aws.s3_bucket_info: | ||
name: "{{ local_bucket_name }}" | ||
bucket_facts: | ||
bucket_accelerate_configuration: true | ||
register: output | ||
|
||
- ansible.builtin.assert: | ||
that: | ||
- item.bucket_accelerate_configuration["Status"] == "Enabled" | ||
loop: "{{ output.buckets }}" | ||
loop_control: | ||
label: "{{ item.name }}" | ||
|
||
- name: Disable transfer accelerate | ||
amazon.aws.s3_bucket: | ||
name: "{{ local_bucket_name }}-2" | ||
state: present | ||
accelerate_enabled: false | ||
register: output | ||
ignore_errors: false | ||
|
||
- ansible.builtin.assert: | ||
that: | ||
- output.changed | ||
- not output.accelerate_enabled | ||
|
||
- name: Assert transfer acceleration disabled | ||
amazon.aws.s3_bucket_info: | ||
name: "{{ local_bucket_name }}" | ||
bucket_facts: | ||
bucket_accelerate_configuration: true | ||
register: output | ||
|
||
- ansible.builtin.assert: | ||
that: | ||
- item.bucket_accelerate_configuration["Status"] == "Disabled" | ||
loop: "{{ output.buckets }}" | ||
loop_control: | ||
label: "{{ item.name }}" | ||
|
||
- name: Re-Enable transfer accelerate (idempotency) | ||
amazon.aws.s3_bucket: | ||
name: "{{ local_bucket_name }}-2" | ||
state: present | ||
accelerate_enabled: true | ||
register: output | ||
|
||
- ansible.builtin.assert: | ||
that: | ||
- output.changed | ||
- output.accelerate_enabled | ||
|
||
- name: Assert transfer acceleration enabled | ||
amazon.aws.s3_bucket_info: | ||
name: "{{ local_bucket_name }}" | ||
bucket_facts: | ||
bucket_accelerate_configuration: true | ||
register: output | ||
|
||
- ansible.builtin.assert: | ||
that: | ||
- item.bucket_accelerate_configuration["Status"] == "Enabled" | ||
loop: "{{ output.buckets }}" | ||
loop_control: | ||
label: "{{ item.name }}" | ||
|
||
- name: Touch bucket with transfer accelerate enabled (idempotency) | ||
amazon.aws.s3_bucket: | ||
name: "{{ local_bucket_name }}-2" | ||
state: present | ||
accelerate_enabled: true | ||
register: output | ||
|
||
- ansible.builtin.assert: | ||
that: | ||
- not output.changed | ||
- output.accelerate_enabled | ||
|
||
- name: Delete test s3 bucket | ||
amazon.aws.s3_bucket: | ||
name: "{{ local_bucket_name }}-2" | ||
state: absent | ||
register: output | ||
|
||
- ansible.builtin.assert: | ||
that: | ||
- output.changed | ||
|
||
# ============================================================ | ||
always: | ||
- name: Ensure all buckets are deleted | ||
amazon.aws.s3_bucket: | ||
name: "{{ local_bucket_name }}" | ||
state: absent | ||
ignore_errors: true | ||
|
||
- name: Ensure all buckets are deleted | ||
amazon.aws.s3_bucket: | ||
name: "{{ local_bucket_name }}-2" | ||
state: absent | ||
ignore_errors: true |