-
Notifications
You must be signed in to change notification settings - Fork 341
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Provide support for AWS S3 Public Access Blocking (#171)
* Provide support for AWS S3 Public Access Blocking * Documentation * Execute get_bucket_public_access only if required * changelog * Add missing version_added entries to doc Resolves issue #144
- Loading branch information
Showing
5 changed files
with
242 additions
and
3 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 managing the ``public_access`` settings (https://github.com/ansible-collections/amazon.aws/pull/171). |
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 |
---|---|---|
|
@@ -6,6 +6,7 @@ dotted | |
tags | ||
encryption_kms | ||
encryption_sse | ||
public_access | ||
|
||
[all:vars] | ||
ansible_connection=local | ||
|
114 changes: 114 additions & 0 deletions
114
tests/integration/targets/s3_bucket/roles/s3_bucket/tasks/public_access.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,114 @@ | ||
--- | ||
- module_defaults: | ||
group/aws: | ||
aws_access_key: "{{ aws_access_key }}" | ||
aws_secret_key: "{{ aws_secret_key }}" | ||
security_token: "{{ security_token | default(omit) }}" | ||
region: "{{ aws_region }}" | ||
block: | ||
|
||
# ============================================================ | ||
|
||
- name: 'Create a simple bucket with public access block configuration' | ||
s3_bucket: | ||
name: '{{ bucket_name }}' | ||
state: present | ||
public_access: | ||
block_public_acls: true | ||
block_public_policy: true | ||
ignore_public_acls: true | ||
restrict_public_buckets: true | ||
register: output | ||
|
||
- assert: | ||
that: | ||
- output.changed | ||
- output.public_access_block | ||
- output.public_access_block.BlockPublicAcls | ||
- output.public_access_block.BlockPublicPolicy | ||
- output.public_access_block.IgnorePublicAcls | ||
- output.public_access_block.RestrictPublicBuckets | ||
|
||
- name: 'Re-configure public access block configuration' | ||
s3_bucket: | ||
name: '{{ bucket_name }}' | ||
state: present | ||
public_access: | ||
block_public_acls: true | ||
block_public_policy: false | ||
ignore_public_acls: true | ||
restrict_public_buckets: false | ||
register: output | ||
|
||
- assert: | ||
that: | ||
- output.changed | ||
- output.public_access_block | ||
- output.public_access_block.BlockPublicAcls | ||
- not output.public_access_block.BlockPublicPolicy | ||
- output.public_access_block.IgnorePublicAcls | ||
- not output.public_access_block.RestrictPublicBuckets | ||
|
||
- name: 'Re-configure public access block configuration (idempotency)' | ||
s3_bucket: | ||
name: '{{ bucket_name }}' | ||
state: present | ||
public_access: | ||
block_public_acls: true | ||
block_public_policy: false | ||
ignore_public_acls: true | ||
restrict_public_buckets: false | ||
register: output | ||
|
||
- assert: | ||
that: | ||
- output is not changed | ||
- output.public_access_block | ||
- output.public_access_block.BlockPublicAcls | ||
- not output.public_access_block.BlockPublicPolicy | ||
- output.public_access_block.IgnorePublicAcls | ||
- not output.public_access_block.RestrictPublicBuckets | ||
|
||
- name: 'Delete public access block configuration' | ||
s3_bucket: | ||
name: '{{ bucket_name }}' | ||
state: present | ||
delete_public_access: true | ||
register: output | ||
|
||
- assert: | ||
that: | ||
- output is changed | ||
- not output.public_access_block|bool | ||
|
||
- name: 'Delete public access block configuration (idempotency)' | ||
s3_bucket: | ||
name: '{{ bucket_name }}' | ||
state: present | ||
delete_public_access: true | ||
register: output | ||
|
||
- assert: | ||
that: | ||
- output is not changed | ||
- not output.public_access_block|bool | ||
|
||
# ============================================================ | ||
|
||
- name: Delete testing s3 bucket | ||
s3_bucket: | ||
name: '{{ bucket_name }}' | ||
state: absent | ||
register: output | ||
|
||
- assert: | ||
that: | ||
- output.changed | ||
|
||
# ============================================================ | ||
always: | ||
- name: Ensure all buckets are deleted | ||
s3_bucket: | ||
name: '{{ bucket_name }}' | ||
state: absent | ||
ignore_errors: yes |
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