-
Notifications
You must be signed in to change notification settings - Fork 341
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide support for AWS S3 Public Access Blocking #171
Merged
Merged
Changes from 7 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
e95e81a
Provide support for AWS S3 Public Access Blocking
zeten30 322f4be
Fix missing empty line
zeten30 f5a21c0
Chnages requested in pull request #171
zeten30 7dcf2a1
Removing generated unused imports
zeten30 78f228e
Fix suboptions doc and brackets alignment
zeten30 3bcabc9
Documentation
zeten30 95e4b56
Execute get_bucket_public_access only if required
zeten30 276a0f0
changelog
tremble 98092b3
Add missing version_added entries to doc
tremble File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 | ||
|
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please also add a test to the 'basic' suite to make sure your PR doesn't change the default behaviour.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think I get this. Can you please explain in further detail? I don't see any file named basic in tests/. I've followed what's already in place for 'encryption_kms' test. It's in inventory and in tasks/. Thanks in advance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Simplest version would be to tweak https://github.com/ansible-collections/amazon.aws/blob/main/tests/integration/targets/s3_bucket/roles/s3_bucket/tasks/simple.yml and make sure that the returned values for public_access match those of Amazon's defaults if you didn't pass public_access.
The intention is to ensure that in adding the new public_access option you've not changed the default behaviour when someone creates a bucket.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, makes perfect sense now:) TY.