https://pulumi.com logo
#java
Title
# java
a

astonishing-minister-81878

05/11/2022, 4:24 PM
Hello, So excited for Java release. I am trying to use Input Bucket Resource properties (currently publicAccessBlockConfiguration, later on loggingConfiguration etc)… but am not able to move ahead. Are Input available in Java? Any code snipplets around these would be super helpful. Thanks!
t

tall-librarian-49374

05/11/2022, 4:26 PM
Not sure I understand the question. Yes, they are… Could you show a code snippet that is problematic for you?
There’s no Input<T> type if that’s your question
a

astonishing-minister-81878

05/11/2022, 5:26 PM
Copy code
var bucket = new Bucket("my-bucket",
                BucketArgs.builder()
                        .publicAccessBlockConfiguration(bucketPublicAccessBlockConfiguration) <--- Not compiling
                .build()
☝️ not sure how to go from here…
Copy code
var bucketPublicAccessBlockConfiguration = new BucketPublicAccessBlockConfiguration(true,true,true,true);
☝️ BucketPublicAccessBlockConfiguration has private access…
how can I assign bucket resource properties to a bucket, is what I am a little lost…
t

tall-librarian-49374

05/11/2022, 5:34 PM
Okay, so your docs point to AWS Native - which is confusingly not supported yet despite the docs suggesting otherwise. Are you actually using the AWS (classic) provider?
a

astonishing-minister-81878

05/11/2022, 8:17 PM
Thanks @tall-librarian-49374. So this was my yesterday and didn’t go anywhere and I thought I should be using aws-native 😞
How should I be able to block public ACLs on buckets? Which API will help me do this and later assign it to Bucket object?
Copy code
var bucket = new Bucket("my-bucket", BucketArgs.builder()
                .acl("private")
                .policy("{\n" +
                        "      \"PublicAccessBlockConfiguration\":{\n" +
                        "         \"BlockPublicAcls\":true,\n" +
                        "         \"IgnorePublicAcls\":false,\n" +
                        "         \"BlockPublicPolicy\":true,\n" +
                        "         \"RestrictPublicBuckets\":true\n" +
                        "      }\n" +
                        "}")
                .build());
I get below error
Copy code
* creating urn:pulumi:dev::s3_provisioning::aws:s3/bucket:Bucket::my-bucket: 1 error occurred:
    	* Error putting S3 policy: MalformedPolicy: Unknown field PublicAccessBlockConfiguration
Am I on the right track of assigning Block policy through JSON?
t

tall-librarian-49374

05/11/2022, 9:12 PM
Sorry I don’t know this part of AWS… Are you looking for this resource https://www.pulumi.com/registry/packages/aws/api-docs/s3/bucketpublicaccessblock/?
a

astonishing-minister-81878

05/11/2022, 11:09 PM
t

tall-librarian-49374

05/11/2022, 11:10 PM
So go ahead and use it
a

astonishing-minister-81878

05/11/2022, 11:11 PM
Basically be able to do this thru pulumi
t

tall-librarian-49374

05/11/2022, 11:11 PM
You should be able to do that with the resource that I linked
a

astonishing-minister-81878

05/11/2022, 11:11 PM
Trying to use it in
Copy code
var bucket = new Bucket("my-bucket", BucketArgs.builder()
                .acl("private")
                .policy("{\n" +
                        "      \"PublicAccessBlockConfiguration\":{\n" +
                        "         \"BlockPublicAcls\":true,\n" +
                        "         \"BlockPublicPolicy\":true,\n" +
                        "         \"RestrictPublicBuckets\":true\n" +
                        "      }\n" +
                        "}")
                .build());
t

tall-librarian-49374

05/11/2022, 11:12 PM
That’s
Bucket
you need to add
new BucketPublicAccessBlock
as a separate resource
a

astonishing-minister-81878

05/11/2022, 11:18 PM
ok … Thanks 🙂
So, this is what is deployed successfully
Copy code
var exampleBucketV2 = new BucketV2("exampleBucketV2");

        var exampleBucketPublicAccessBlock = new BucketPublicAccessBlock("exampleBucketPublicAccessBlock", BucketPublicAccessBlockArgs.builder()
                .bucket(exampleBucketV2.getId())
                .blockPublicAcls(true)
                //.restrictPublicBuckets(true)
                .blockPublicPolicy(true)
                .build());
However, I still don’t see Block public access enabled.. on aws console…
How can I make sure, I am dealing with the right property (Pulumi API?)
Tried https://www.pulumi.com/registry/packages/aws/api-docs/s3/bucketpublicaccessblock/ with Java and Python. Couldn’t get it working… I will appreciate if someone else tries, to make sure I am not going blind 🤣 . Thanks!
3 Views