Skip to content
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 #144

Closed
sky-amoncadot opened this issue Aug 19, 2020 · 5 comments · Fixed by #171
Closed

Provide support for AWS S3 Public Access Blocking #144

sky-amoncadot opened this issue Aug 19, 2020 · 5 comments · Fixed by #171
Labels
affects_2.10 feature This issue/PR relates to a feature request module module needs_triage plugins plugin (any type)

Comments

@sky-amoncadot
Copy link

SUMMARY

Support public access blocking on S3 buckets.

ISSUE TYPE
  • Feature Idea
COMPONENT NAME

aws_s3.py and/or s3_bucket.py

ADDITIONAL INFORMATION

Original feature request here.

AWS release info.

Public access blocking is a new AWS S3 capability that ensures a bucket is much more private than even the default and that the bucket cannot subsequently be configured to have some public capabilities.

This is detached from S3 bucket policies or permissions as it is a separate API entirely. Its part of S3Control in botocore if I recall. An example of what is being requested as a native feature in Ansible:

aws s3api put-public-access-block --bucket "${BUCKET_NAME}" --public-access-block-configuration '{
  "BlockPublicAcls": true,
  "IgnorePublicAcls": true,
  "BlockPublicPolicy": true,
  "RestrictPublicBuckets": true
}'

(Above snippet taken from here.)

@ansibullbot
Copy link

Files identified in the description:

If these files are inaccurate, please update the component name section of the description or use the !component bot command.

click here for bot help

@ansibullbot
Copy link

@ansibullbot ansibullbot added affects_2.10 feature This issue/PR relates to a feature request module module needs_triage labels Aug 19, 2020
@ansibullbot ansibullbot added the plugins plugin (any type) label Aug 27, 2020
@tremble tremble assigned tremble and unassigned tremble Oct 6, 2020
@zeten30
Copy link
Contributor

zeten30 commented Oct 6, 2020

@sky-amoncadot I've hit the same problem with blocking public access. I'll try to prepare a merge request soon.

@zeten30
Copy link
Contributor

zeten30 commented Oct 7, 2020

So I have a working prototype:)

- hosts: localhost
  gather_facts: false

  tasks:
    - amazon.aws.s3_bucket:
        name: "<bucket_name>"
        state: present
        public_access:
          BlockPublicAcls: true
          # IgnorePublicAcls: false
          # BlockPublicPolicy: false
          # RestrictPublicBuckets: false
      register: module_result

    - debug:
        var: module_result
ansible-playbook -i ../inventory/ s3-bucket-testing.yml  

PLAY [localhost] **************************************************************************************************************************

TASK [amazon.aws.s3_bucket] ***************************************************************************************************************
changed: [localhost]

TASK [debug] ******************************************************************************************************************************
ok: [localhost] => 
  module_result:
    changed: true
    failed: false
    name: <bucket_name>
    policy: null
    public_access_block:
      BlockPublicAcls: true
      BlockPublicPolicy: false
      IgnorePublicAcls: false
      RestrictPublicBuckets: false
    requester_pays: false
    tags: {}
    versioning:
      MfaDelete: Disabled
      Versioning: Disabled

PLAY RECAP ********************************************************************************************************************************
localhost                  : ok=2    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0
aws s3api get-public-access-block --bucket <bucket_name>
{
    "PublicAccessBlockConfiguration": {
        "BlockPublicAcls": true,
        "IgnorePublicAcls": false,
        "BlockPublicPolicy": false,
        "RestrictPublicBuckets": false
    }
}

I'll do few more tests & prepare merge request.

@zeten30
Copy link
Contributor

zeten30 commented Oct 12, 2020

@sky-amoncadot another 'related' pull request:) - ansible-collections/community.aws#260

tremble pushed a commit that referenced this issue Nov 16, 2020
* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects_2.10 feature This issue/PR relates to a feature request module module needs_triage plugins plugin (any type)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants