aws-sdk-rust icon indicating copy to clipboard operation
aws-sdk-rust copied to clipboard

S3: put_bucket_acl(), and acl() on create_bucket() silently fail to apply ACL policy

Open Church- opened this issue 3 years ago • 6 comments
trafficstars

Describe the bug

When creating a bucket with a default ACL policy to be applied, or calling pucket_bucket_acl() to apply a policy to a bucket, there seems to be no change to the policy. Attempting to apply the BucketCannedAcl::Private policy to a bucket has no effect, leaving the bucket in the default state of publicly accessible.

Expected Behavior

I expect for the ACL of the created bucket to be set to private, accessible only to people with the correct IAM privileges.

Current Behavior

ACL defaults to public access and is never updated despite calling methods to do so.

Reproduction Steps

  async fn maybe_set_bucket_acl(client: &S3Client, bucket_name: &str) -> Result<()> {
      client                                                                         
          .put_bucket_acl()                                                       
          .acl(BucketCannedAcl::Private)                                          
          .bucket(bucket_name)                                                    
          .send()                                                                 
          .await?;                                                                
                                                                                  
      Ok(())                                                                      
  } 

Or

async fn maybe_generate_bucket(client: &S3Client, bucket_name: &str, region: &str) -> Result<()> {
    let cfg = match region {                                                    
        "us-east-1" => None,                                                    
        _ => {                                                                  
            let constraint = BucketLocationConstraint::from(region);            
            Some(                                                               
                CreateBucketConfiguration::builder()                            
                    .location_constraint(constraint)                            
                    .build(),                                                   
            )                                                                   
        }                                                                       
    };                                                                          
                                                                                
    client                                                                      
        .create_bucket()
        .acl(BucketCannedAcl::Private)                                                        
        .set_create_bucket_configuration(cfg)                                                                                                               
        .bucket(bucket_name.to_string())                                                                                                                    
        .send()                                                                                                                                             
        .await?;                                                                                                                                            
                                                                                                                                                            
    Ok(())                                                                                                                                                  
}

Possible Solution

No response

Additional Information/Context

No response

Version

├── aws-config v0.15.0
│   ├── aws-http v0.15.0
│   │   ├── aws-smithy-http v0.45.0
│   │   │   ├── aws-smithy-eventstream v0.45.0
│   │   │   │   ├── aws-smithy-types v0.45.0
│   │   │   │   │   ├── itoa v1.0.2
│   │   │   │   │   ├── num-integer v0.1.45
│   │   │   │   │   │   └── num-traits v0.2.15
│   │   │   │   │   │       [build-dependencies]
│   │   │   │   │   │       └── autocfg v1.1.0
│   │   │   │   │   │   [build-dependencies]
│   │   │   │   │   │   └── autocfg v1.1.0
│   │   │   │   │   ├── ryu v1.0.10
│   │   │   │   │   └── time v0.3.11
│   │   │   │   │       ├── libc v0.2.126
│   │   │   │   │       └── num_threads v0.1.6
│   │   │   │   ├── bytes v1.2.0
│   │   │   │   └── crc32fast v1.3.2
│   │   │   │       └── cfg-if v1.0.0
│   │   │   ├── aws-smithy-types v0.45.0 (*)
│   │   │   ├── bytes v1.2.0
│   │   │   ├── bytes-utils v0.1.2
│   │   │   │   ├── bytes v1.2.0
│   │   │   │   └── either v1.7.0
│   │   │   ├── futures-core v0.3.21
│   │   │   ├── http v0.2.8
│   │   │   │   ├── bytes v1.2.0
│   │   │   │   ├── fnv v1.0.7
│   │   │   │   └── itoa v1.0.2
│   │   │   ├── http-body v0.4.5
│   │   │   │   ├── bytes v1.2.0
│   │   │   │   ├── http v0.2.8 (*)
│   │   │   │   └── pin-project-lite v0.2.9
│   │   │   ├── hyper v0.14.20
│   │   │   │   ├── bytes v1.2.0
│   │   │   │   ├── futures-channel v0.3.21
│   │   │   │   │   └── futures-core v0.3.21
│   │   │   │   ├── futures-core v0.3.21
│   │   │   │   ├── futures-util v0.3.21
│   │   │   │   │   ├── futures-core v0.3.21
│   │   │   │   │   ├── futures-macro v0.3.21 (proc-macro)
│   │   │   │   │   │   ├── proc-macro2 v1.0.40
│   │   │   │   │   │   │   └── unicode-ident v1.0.2
│   │   │   │   │   │   ├── quote v1.0.20
│   │   │   │   │   │   │   └── proc-macro2 v1.0.40 (*)
│   │   │   │   │   │   └── syn v1.0.98
│   │   │   │   │   │       ├── proc-macro2 v1.0.40 (*)
│   │   │   │   │   │       ├── quote v1.0.20 (*)
│   │   │   │   │   │       └── unicode-ident v1.0.2
│   │   │   │   │   ├── futures-task v0.3.21
│   │   │   │   │   ├── pin-project-lite v0.2.9
│   │   │   │   │   ├── pin-utils v0.1.0
│   │   │   │   │   └── slab v0.4.7
│   │   │   │   │       [build-dependencies]
│   │   │   │   │       └── autocfg v1.1.0
│   │   │   │   ├── h2 v0.3.13
│   │   │   │   │   ├── bytes v1.2.0
│   │   │   │   │   ├── fnv v1.0.7
│   │   │   │   │   ├── futures-core v0.3.21
│   │   │   │   │   ├── futures-sink v0.3.21
│   │   │   │   │   ├── futures-util v0.3.21 (*)
│   │   │   │   │   ├── http v0.2.8 (*)
│   │   │   │   │   ├── indexmap v1.9.1
│   │   │   │   │   │   └── hashbrown v0.12.3
│   │   │   │   │   │   [build-dependencies]
│   │   │   │   │   │   └── autocfg v1.1.0
│   │   │   │   │   ├── slab v0.4.7 (*)
│   │   │   │   │   ├── tokio v1.20.0
│   │   │   │   │   │   ├── bytes v1.2.0
│   │   │   │   │   │   ├── libc v0.2.126
│   │   │   │   │   │   ├── memchr v2.5.0
│   │   │   │   │   │   ├── mio v0.8.4
│   │   │   │   │   │   │   ├── libc v0.2.126
│   │   │   │   │   │   │   └── log v0.4.17
│   │   │   │   │   │   │       └── cfg-if v1.0.0
│   │   │   │   │   │   ├── num_cpus v1.13.1
│   │   │   │   │   │   │   └── libc v0.2.126
│   │   │   │   │   │   ├── once_cell v1.13.0
│   │   │   │   │   │   ├── parking_lot v0.12.1
│   │   │   │   │   │   │   ├── lock_api v0.4.7
│   │   │   │   │   │   │   │   └── scopeguard v1.1.0
│   │   │   │   │   │   │   │   [build-dependencies]
│   │   │   │   │   │   │   │   └── autocfg v1.1.0
│   │   │   │   │   │   │   └── parking_lot_core v0.9.3
│   │   │   │   │   │   │       ├── cfg-if v1.0.0
│   │   │   │   │   │   │       ├── libc v0.2.126
│   │   │   │   │   │   │       └── smallvec v1.9.0
│   │   │   │   │   │   ├── pin-project-lite v0.2.9
│   │   │   │   │   │   ├── signal-hook-registry v1.4.0
│   │   │   │   │   │   │   └── libc v0.2.126
│   │   │   │   │   │   ├── socket2 v0.4.4
│   │   │   │   │   │   │   └── libc v0.2.126
│   │   │   │   │   │   └── tokio-macros v1.8.0 (proc-macro)
│   │   │   │   │   │       ├── proc-macro2 v1.0.40 (*)
│   │   │   │   │   │       ├── quote v1.0.20 (*)
│   │   │   │   │   │       └── syn v1.0.98 (*)
│   │   │   │   │   │   [build-dependencies]
│   │   │   │   │   │   └── autocfg v1.1.0
│   │   │   │   │   ├── tokio-util v0.7.3
│   │   │   │   │   │   ├── bytes v1.2.0
│   │   │   │   │   │   ├── futures-core v0.3.21
│   │   │   │   │   │   ├── futures-sink v0.3.21
│   │   │   │   │   │   ├── pin-project-lite v0.2.9
│   │   │   │   │   │   ├── tokio v1.20.0 (*)
│   │   │   │   │   │   └── tracing v0.1.35
│   │   │   │   │   │       ├── cfg-if v1.0.0
│   │   │   │   │   │       ├── log v0.4.17 (*)
│   │   │   │   │   │       ├── pin-project-lite v0.2.9
│   │   │   │   │   │       ├── tracing-attributes v0.1.22 (proc-macro)
│   │   │   │   │   │       │   ├── proc-macro2 v1.0.40 (*)
│   │   │   │   │   │       │   ├── quote v1.0.20 (*)
│   │   │   │   │   │       │   └── syn v1.0.98 (*)
│   │   │   │   │   │       └── tracing-core v0.1.28
│   │   │   │   │   │           └── once_cell v1.13.0
│   │   │   │   │   └── tracing v0.1.35 (*)
│   │   │   │   ├── http v0.2.8 (*)
│   │   │   │   ├── http-body v0.4.5 (*)
│   │   │   │   ├── httparse v1.7.1
│   │   │   │   ├── httpdate v1.0.2
│   │   │   │   ├── itoa v1.0.2
│   │   │   │   ├── pin-project-lite v0.2.9
│   │   │   │   ├── socket2 v0.4.4 (*)
│   │   │   │   ├── tokio v1.20.0 (*)
│   │   │   │   ├── tower-service v0.3.2
│   │   │   │   ├── tracing v0.1.35 (*)
│   │   │   │   └── want v0.3.0
│   │   │   │       ├── log v0.4.17 (*)
│   │   │   │       └── try-lock v0.2.3
│   │   │   ├── once_cell v1.13.0
│   │   │   ├── percent-encoding v2.1.0
│   │   │   ├── pin-project-lite v0.2.9
│   │   │   ├── tokio v1.20.0 (*)
│   │   │   ├── tokio-util v0.7.3 (*)
│   │   │   └── tracing v0.1.35 (*)
│   │   ├── aws-smithy-types v0.45.0 (*)
│   │   ├── aws-types v0.15.0
│   │   │   ├── aws-smithy-async v0.45.0
│   │   │   │   ├── futures-util v0.3.21 (*)
│   │   │   │   ├── pin-project-lite v0.2.9
│   │   │   │   ├── tokio v1.20.0 (*)
│   │   │   │   └── tokio-stream v0.1.9
│   │   │   │       ├── futures-core v0.3.21
│   │   │   │       ├── pin-project-lite v0.2.9
│   │   │   │       └── tokio v1.20.0 (*)
│   │   │   ├── aws-smithy-client v0.45.0
│   │   │   │   ├── aws-smithy-async v0.45.0 (*)
│   │   │   │   ├── aws-smithy-http v0.45.0 (*)
│   │   │   │   ├── aws-smithy-http-tower v0.45.0
│   │   │   │   │   ├── aws-smithy-http v0.45.0 (*)
│   │   │   │   │   ├── bytes v1.2.0
│   │   │   │   │   ├── http v0.2.8 (*)
│   │   │   │   │   ├── http-body v0.4.5 (*)
│   │   │   │   │   ├── pin-project-lite v0.2.9
│   │   │   │   │   ├── tower v0.4.13
│   │   │   │   │   │   ├── futures-core v0.3.21
│   │   │   │   │   │   ├── futures-util v0.3.21 (*)
│   │   │   │   │   │   ├── pin-project v1.0.11
│   │   │   │   │   │   │   └── pin-project-internal v1.0.11 (proc-macro)
│   │   │   │   │   │   │       ├── proc-macro2 v1.0.40 (*)
│   │   │   │   │   │   │       ├── quote v1.0.20 (*)
│   │   │   │   │   │   │       └── syn v1.0.98 (*)
│   │   │   │   │   │   ├── pin-project-lite v0.2.9
│   │   │   │   │   │   ├── tokio v1.20.0 (*)
│   │   │   │   │   │   ├── tower-layer v0.3.1
│   │   │   │   │   │   ├── tower-service v0.3.2
│   │   │   │   │   │   └── tracing v0.1.35 (*)
│   │   │   │   │   └── tracing v0.1.35 (*)
│   │   │   │   ├── aws-smithy-types v0.45.0 (*)
│   │   │   │   ├── bytes v1.2.0
│   │   │   │   ├── fastrand v1.7.0
│   │   │   │   ├── http v0.2.8 (*)
│   │   │   │   ├── http-body v0.4.5 (*)
│   │   │   │   ├── hyper v0.14.20 (*)
│   │   │   │   ├── hyper-rustls v0.22.1
│   │   │   │   │   ├── ct-logs v0.8.0
│   │   │   │   │   │   └── sct v0.6.1
│   │   │   │   │   │       ├── ring v0.16.20
│   │   │   │   │   │       │   ├── libc v0.2.126
│   │   │   │   │   │       │   ├── once_cell v1.13.0
│   │   │   │   │   │       │   ├── spin v0.5.2
│   │   │   │   │   │       │   └── untrusted v0.7.1
│   │   │   │   │   │       │   [build-dependencies]
│   │   │   │   │   │       │   └── cc v1.0.73
│   │   │   │   │   │       └── untrusted v0.7.1
│   │   │   │   │   ├── futures-util v0.3.21 (*)
│   │   │   │   │   ├── hyper v0.14.20 (*)
│   │   │   │   │   ├── log v0.4.17 (*)
│   │   │   │   │   ├── rustls v0.19.1
│   │   │   │   │   │   ├── base64 v0.13.0
│   │   │   │   │   │   ├── log v0.4.17 (*)
│   │   │   │   │   │   ├── ring v0.16.20 (*)
│   │   │   │   │   │   ├── sct v0.6.1 (*)
│   │   │   │   │   │   └── webpki v0.21.4
│   │   │   │   │   │       ├── ring v0.16.20 (*)
│   │   │   │   │   │       └── untrusted v0.7.1
│   │   │   │   │   ├── rustls-native-certs v0.5.0
│   │   │   │   │   │   ├── openssl-probe v0.1.5
│   │   │   │   │   │   └── rustls v0.19.1 (*)
│   │   │   │   │   ├── tokio v1.20.0 (*)
│   │   │   │   │   ├── tokio-rustls v0.22.0
│   │   │   │   │   │   ├── rustls v0.19.1 (*)
│   │   │   │   │   │   ├── tokio v1.20.0 (*)
│   │   │   │   │   │   └── webpki v0.21.4 (*)
│   │   │   │   │   └── webpki v0.21.4 (*)
│   │   │   │   ├── lazy_static v1.4.0
│   │   │   │   ├── pin-project-lite v0.2.9
│   │   │   │   ├── tokio v1.20.0 (*)
│   │   │   │   ├── tower v0.4.13 (*)
│   │   │   │   └── tracing v0.1.35 (*)
│   │   │   ├── aws-smithy-http v0.45.0 (*)
│   │   │   ├── aws-smithy-types v0.45.0 (*)
│   │   │   ├── http v0.2.8 (*)
│   │   │   ├── tracing v0.1.35 (*)
│   │   │   └── zeroize v1.5.6
│   │   │   [build-dependencies]
│   │   │   └── rustc_version v0.4.0
│   │   │       └── semver v1.0.12
│   │   ├── http v0.2.8 (*)
│   │   ├── lazy_static v1.4.0
│   │   ├── percent-encoding v2.1.0
│   │   └── tracing v0.1.35 (*)
│   ├── aws-sdk-sso v0.15.0
│   │   ├── aws-endpoint v0.15.0
│   │   │   ├── aws-smithy-http v0.45.0 (*)
│   │   │   ├── aws-types v0.15.0 (*)
│   │   │   ├── http v0.2.8 (*)
│   │   │   ├── regex v1.6.0
│   │   │   │   ├── aho-corasick v0.7.18
│   │   │   │   │   └── memchr v2.5.0
│   │   │   │   ├── memchr v2.5.0
│   │   │   │   └── regex-syntax v0.6.27
│   │   │   └── tracing v0.1.35 (*)
│   │   ├── aws-http v0.15.0 (*)
│   │   ├── aws-sig-auth v0.15.0
│   │   │   ├── aws-sigv4 v0.15.0
│   │   │   │   ├── aws-smithy-eventstream v0.45.0 (*)
│   │   │   │   ├── aws-smithy-http v0.45.0 (*)
│   │   │   │   ├── bytes v1.2.0
│   │   │   │   ├── form_urlencoded v1.0.1
│   │   │   │   │   ├── matches v0.1.9
│   │   │   │   │   └── percent-encoding v2.1.0
│   │   │   │   ├── hex v0.4.3
│   │   │   │   ├── http v0.2.8 (*)
│   │   │   │   ├── once_cell v1.13.0
│   │   │   │   ├── percent-encoding v2.1.0
│   │   │   │   ├── regex v1.6.0 (*)
│   │   │   │   ├── ring v0.16.20 (*)
│   │   │   │   ├── time v0.3.11 (*)
│   │   │   │   └── tracing v0.1.35 (*)
│   │   │   ├── aws-smithy-eventstream v0.45.0 (*)
│   │   │   ├── aws-smithy-http v0.45.0 (*)
│   │   │   ├── aws-types v0.15.0 (*)
│   │   │   ├── http v0.2.8 (*)
│   │   │   └── tracing v0.1.35 (*)
│   │   ├── aws-smithy-async v0.45.0 (*)
│   │   ├── aws-smithy-client v0.45.0 (*)
│   │   ├── aws-smithy-http v0.45.0 (*)
│   │   ├── aws-smithy-http-tower v0.45.0 (*)
│   │   ├── aws-smithy-json v0.45.0
│   │   │   └── aws-smithy-types v0.45.0 (*)
│   │   ├── aws-smithy-types v0.45.0 (*)
│   │   ├── aws-types v0.15.0 (*)
│   │   ├── bytes v1.2.0
│   │   ├── http v0.2.8 (*)
│   │   ├── tokio-stream v0.1.9 (*)
│   │   └── tower v0.4.13 (*)
│   ├── aws-sdk-sts v0.15.0
│   │   ├── aws-endpoint v0.15.0 (*)
│   │   ├── aws-http v0.15.0 (*)
│   │   ├── aws-sig-auth v0.15.0 (*)
│   │   ├── aws-smithy-async v0.45.0 (*)
│   │   ├── aws-smithy-client v0.45.0 (*)
│   │   ├── aws-smithy-http v0.45.0 (*)
│   │   ├── aws-smithy-http-tower v0.45.0 (*)
│   │   ├── aws-smithy-query v0.45.0
│   │   │   ├── aws-smithy-types v0.45.0 (*)
│   │   │   └── urlencoding v2.1.0
│   │   ├── aws-smithy-types v0.45.0 (*)
│   │   ├── aws-smithy-xml v0.45.0
│   │   │   └── xmlparser v0.13.3
│   │   ├── aws-types v0.15.0 (*)
│   │   ├── bytes v1.2.0
│   │   ├── http v0.2.8 (*)
│   │   └── tower v0.4.13 (*)
│   ├── aws-smithy-async v0.45.0 (*)
│   ├── aws-smithy-client v0.45.0 (*)
│   ├── aws-smithy-http v0.45.0 (*)
│   ├── aws-smithy-http-tower v0.45.0 (*)
│   ├── aws-smithy-json v0.45.0 (*)
│   ├── aws-smithy-types v0.45.0 (*)
│   ├── aws-types v0.15.0 (*)
│   ├── bytes v1.2.0
│   ├── hex v0.4.3
│   ├── http v0.2.8 (*)
│   ├── hyper v0.14.20 (*)
│   ├── ring v0.16.20 (*)
│   ├── tokio v1.20.0 (*)
│   ├── tower v0.4.13 (*)
│   ├── tracing v0.1.35 (*)
│   └── zeroize v1.5.6
├── aws-sdk-ec2 v0.15.0
│   ├── aws-endpoint v0.15.0 (*)
│   ├── aws-http v0.15.0 (*)
│   ├── aws-sig-auth v0.15.0 (*)
│   ├── aws-smithy-async v0.45.0 (*)
│   ├── aws-smithy-client v0.45.0 (*)
│   ├── aws-smithy-http v0.45.0 (*)
│   ├── aws-smithy-http-tower v0.45.0 (*)
│   ├── aws-smithy-query v0.45.0 (*)
│   ├── aws-smithy-types v0.45.0 (*)
│   ├── aws-smithy-xml v0.45.0 (*)
│   ├── aws-types v0.15.0 (*)
│   ├── bytes v1.2.0
│   ├── fastrand v1.7.0
│   ├── http v0.2.8 (*)
│   ├── tokio-stream v0.1.9 (*)
│   └── tower v0.4.13 (*)
├── aws-sdk-iam v0.15.0
│   ├── aws-endpoint v0.15.0 (*)
│   ├── aws-http v0.15.0 (*)
│   ├── aws-sig-auth v0.15.0 (*)
│   ├── aws-smithy-async v0.45.0 (*)
│   ├── aws-smithy-client v0.45.0 (*)
│   ├── aws-smithy-http v0.45.0 (*)
│   ├── aws-smithy-http-tower v0.45.0 (*)
│   ├── aws-smithy-query v0.45.0 (*)
│   ├── aws-smithy-types v0.45.0 (*)
│   ├── aws-smithy-xml v0.45.0 (*)
│   ├── aws-types v0.15.0 (*)
│   ├── bytes v1.2.0
│   ├── http v0.2.8 (*)
│   ├── tokio-stream v0.1.9 (*)
│   └── tower v0.4.13 (*)
├── aws-sdk-s3 v0.15.0
│   ├── aws-endpoint v0.15.0 (*)
│   ├── aws-http v0.15.0 (*)
│   ├── aws-sig-auth v0.15.0 (*)
│   ├── aws-sigv4 v0.15.0 (*)
│   ├── aws-smithy-async v0.45.0 (*)
│   ├── aws-smithy-client v0.45.0 (*)
│   ├── aws-smithy-eventstream v0.45.0 (*)
│   ├── aws-smithy-http v0.45.0 (*)
│   ├── aws-smithy-http-tower v0.45.0 (*)
│   ├── aws-smithy-types v0.45.0 (*)
│   ├── aws-smithy-xml v0.45.0 (*)
│   ├── aws-types v0.15.0 (*)
│   ├── bytes v1.2.0
│   ├── http v0.2.8 (*)
│   ├── md-5 v0.10.1
│   │   └── digest v0.10.3
│   │       ├── block-buffer v0.10.2
│   │       │   └── generic-array v0.14.5
│   │       │       └── typenum v1.15.0
│   │       │       [build-dependencies]
│   │       │       └── version_check v0.9.4
│   │       └── crypto-common v0.1.6
│   │           ├── generic-array v0.14.5 (*)
│   │           └── typenum v1.15.0
│   ├── tokio-stream v0.1.9 (*)
│   └── tower v0.4.13 (*)
├── aws-types v0.15.0 (*)

Environment details (OS name and version, etc.)

Ubuntu Focal

Logs

No response

Church- avatar Jul 24 '22 19:07 Church-

@jmklix When you have time, can you reproduce this issue with another SDK or the CLI? That'll tell us whether it's an S3 or SDK issue.

Velfi avatar Jul 25 '22 15:07 Velfi

put_bucket_acl() will only apply to an object that already exists:

Uses the acl subresource to set the access control list (ACL) permissions for an object that already exists in a bucket. You must have WRITE_ACP permission to set the ACL of an object.

As for on create_bucket() I'm not sure why it isn't working for you. Are you trying to reuse an existing bucket name? As you noticed in us-east-1, you don't get an error when doing this, but it resets the bucket access control lists (ACLs).

jmklix avatar Aug 04 '22 07:08 jmklix

@jmklix Is that API link meant to refer to put_object_acl? Because that's what it's pointing to.

Also I did test it after creating a bucket in a region.

As for when using create_bucket, not trying to re-use a bucket name.

And when this code was tested it was mainly in us-west-1 and ap-northeast-1 so the legacy issue with us-east-1 wouldn't apply.

Church- avatar Aug 06 '22 22:08 Church-

Sorry for the incorrect link. I was able to test this and switch between different policies using the rust sdk. Just making sure you are looking at the permissions tab for the bucket you want to change. And then look at the acl section?

Below is the code I ran which is just copied from your sample above and added to the s3/bin folder: cargo run --bin maybe-set-bucket-acl -- -b some-random-test-string-bucket-name

use aws_config::meta::region::RegionProviderChain;
use aws_sdk_s3::model::{BucketCannedAcl};
use aws_sdk_s3::{Client, Error, Region};
use structopt::StructOpt;

#[derive(Debug, StructOpt)]
struct Opt {
    /// The AWS Region.
    #[structopt(short, long)]
    region: Option<String>,

    /// The name of the bucket.
    #[structopt(short, long)]
    bucket: String,
}

async fn maybe_set_bucket_acl(client: &Client, bucket_name: &str) -> Result<(), Error> {
    client
        .put_bucket_acl()
        .acl(BucketCannedAcl::Private)
        //.acl(BucketCannedAcl::AuthenticatedRead)
        .bucket(bucket_name)
        .send()
        .await?;
    println!("Changing acl for {}", bucket_name);
    Ok(())
}

#[tokio::main]
async fn main() -> Result<(), Error> {
    tracing_subscriber::fmt::init();

    let Opt {
        region,
        bucket,
    } = Opt::from_args();

    let region_provider = RegionProviderChain::first_try(region.map(Region::new))
        .or_default_provider()
        .or_else(Region::new("us-west-2"));

    println!();
    println!("Test acl for {}", bucket);

    let shared_config = aws_config::from_env().region(region_provider).load().await;
    let client = Client::new(&shared_config);

    maybe_set_bucket_acl(&client, &bucket).await
}

jmklix avatar Aug 15 '22 08:08 jmklix

@jmklix So I think a possible misunderstanding, I see that upon running that that access is set as Objects can be public instead of Bucket and objects not public

I'm assuming the implication is that the acl is set to private unless someone gives it access?

Where as I want to turn off public access entirely.

Church- avatar Aug 17 '22 17:08 Church-

I think you want to use 'public access block' rather than than ACL for this.

    let configblock = PublicAccessBlockConfiguration::builder()
        .block_public_acls(true)
        .ignore_public_acls(true)
        .block_public_policy(true)
        .restrict_public_buckets(true)
        .build();
    client
        .put_public_access_block()
        .public_access_block_configuration(configblock)
        .bucket(bucket_name)
        .send()
        .await?;
    println!("Blocking all public access for {}", bucket_name);
    Ok(())

jmklix avatar Aug 18 '22 18:08 jmklix

Greetings! It looks like this issue hasn’t been active in longer than a week. We encourage you to check if this is still an issue in the latest release. Because it has been longer than a week since the last update on this, and in the absence of more information, we will be closing this issue soon. If you find that this is still a problem, please feel free to provide a comment or add an upvote to prevent automatic closure, or if the issue is already closed, please feel free to open a new one.

github-actions[bot] avatar Aug 25 '22 19:08 github-actions[bot]