forked from ansible-collections/amazon.aws
-
Notifications
You must be signed in to change notification settings - Fork 0
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
Resolves issue ansible-collections#144 <ansible-collections#144>
- Loading branch information
Showing
3 changed files
with
151 additions
and
1 deletion.
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
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 | ||
|
77 changes: 77 additions & 0 deletions
77
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,77 @@ | ||
--- | ||
- 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: | ||
BlockPublicAcls: true | ||
BlockPublicPolicy: true | ||
IgnorePublicAcls: true | ||
RestrictPublicBuckets: true | ||
register: output | ||
|
||
- name: 'Re-configure public access block configuration' | ||
s3_bucket: | ||
name: '{{ bucket_name }}' | ||
state: present | ||
public_access: | ||
BlockPublicAcls: true | ||
BlockPublicPolicy: false | ||
IgnorePublicAcls: true | ||
RestrictPublicBuckets: false | ||
register: output | ||
|
||
- assert: | ||
that: | ||
- output.changed | ||
- output.public_access_block | ||
- not output.public_access_block.BlockPublicPolicy | ||
- not output.public_access_block.RestrictPublicBuckets | ||
|
||
- name: 'Re-configure public access block configuration (idempotency)' | ||
s3_bucket: | ||
name: '{{ bucket_name }}' | ||
state: present | ||
public_access: | ||
BlockPublicAcls: true | ||
BlockPublicPolicy: false | ||
IgnorePublicAcls: true | ||
RestrictPublicBuckets: false | ||
register: output | ||
|
||
- assert: | ||
that: | ||
- output is not changed | ||
- output.public_access_block | ||
- not output.public_access_block.BlockPublicPolicy | ||
- not output.public_access_block.RestrictPublicBuckets | ||
|
||
# ============================================================ | ||
|
||
- 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 |