Skip to content

Commit

Permalink
Fix java init template
Browse files Browse the repository at this point in the history
Fixes #711

Seems like jsii stopped generating method overloads
which is the reason some of the method signatures
caused compilation errors.

Also, IIdentityResource was renamed to IPrincipal.

We should revisit once aws/jsii#233 is fixed.

But at least we want to make sure the init template
compiles.
  • Loading branch information
Elad Ben-Israel committed Sep 17, 2018
1 parent 8e8c295 commit 6fa9748
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package com.myorg;

import software.amazon.awscdk.Construct;
import software.amazon.awscdk.services.iam.IIdentityResource;
import software.amazon.awscdk.services.iam.IPrincipal;
import software.amazon.awscdk.services.s3.Bucket;
import software.amazon.awscdk.services.s3.BucketProps;

import java.util.ArrayList;
import java.util.List;
Expand All @@ -17,15 +18,15 @@ public HelloConstruct(final Construct parent, final String name, final HelloCons
super(parent, name);

for (int i = 0; i < props.getBucketCount(); ++i) {
buckets.add(new Bucket(this, "Bucket" + String.valueOf(i)));
buckets.add(new Bucket(this, "Bucket" + String.valueOf(i), BucketProps.builder().build()));
}
}

/**
* Given an principal, grants it READ access on all buckets.
* @param principal The principal (User, Group, Role)
*/
public void grantRead(final IIdentityResource principal) {
buckets.forEach(b -> b.grantRead(principal));
public void grantRead(final IPrincipal principal) {
buckets.forEach(b -> b.grantRead(principal, "*"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import software.amazon.awscdk.Stack;
import software.amazon.awscdk.StackProps;
import software.amazon.awscdk.services.iam.User;
import software.amazon.awscdk.services.iam.UserProps;
import software.amazon.awscdk.services.sns.Topic;
import software.amazon.awscdk.services.sns.TopicProps;
import software.amazon.awscdk.services.sqs.Queue;
Expand Down Expand Up @@ -31,7 +32,7 @@ public HelloStack(final App parent, final String name, final StackProps props) {
.withBucketCount(5)
.build());

User user = new User(this, "MyUser");
User user = new User(this, "MyUser", UserProps.builder().build());
hello.grantRead(user);
}
}

0 comments on commit 6fa9748

Please sign in to comment.