From 281c083e47725776d2c533ac83c300036513a73e Mon Sep 17 00:00:00 2001 From: Elad Ben-Israel Date: Mon, 17 Sep 2018 17:36:41 +0300 Subject: [PATCH] fix(cdk): temporary fix to java "cdk init" template (#732) 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 awslabs/jsii#233 is fixed. But at least we want to make sure the init template compiles. --- .../app/java/src/main/java/com/myorg/HelloConstruct.java | 9 +++++---- .../app/java/src/main/java/com/myorg/HelloStack.java | 3 ++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/aws-cdk/lib/init-templates/app/java/src/main/java/com/myorg/HelloConstruct.java b/packages/aws-cdk/lib/init-templates/app/java/src/main/java/com/myorg/HelloConstruct.java index c001a279f70fa..7a2b629a6135b 100644 --- a/packages/aws-cdk/lib/init-templates/app/java/src/main/java/com/myorg/HelloConstruct.java +++ b/packages/aws-cdk/lib/init-templates/app/java/src/main/java/com/myorg/HelloConstruct.java @@ -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; @@ -17,7 +18,7 @@ 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())); } } @@ -25,7 +26,7 @@ public HelloConstruct(final Construct parent, final String name, final HelloCons * 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, "*")); } } diff --git a/packages/aws-cdk/lib/init-templates/app/java/src/main/java/com/myorg/HelloStack.java b/packages/aws-cdk/lib/init-templates/app/java/src/main/java/com/myorg/HelloStack.java index f351203771146..de0bc3c99da70 100644 --- a/packages/aws-cdk/lib/init-templates/app/java/src/main/java/com/myorg/HelloStack.java +++ b/packages/aws-cdk/lib/init-templates/app/java/src/main/java/com/myorg/HelloStack.java @@ -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; @@ -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); } }