Skip to content

Commit

Permalink
chore: refresh Java examples with latest syntax elements (#162)
Browse files Browse the repository at this point in the history
  • Loading branch information
RomainMuller authored and mergify[bot] committed Nov 23, 2019
1 parent 5475a12 commit 78bb11c
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 33 deletions.
14 changes: 7 additions & 7 deletions java/hello-world/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,38 +55,38 @@
<dependency>
<groupId>software.amazon.awscdk</groupId>
<artifactId>core</artifactId>
<version>1.14.0.DEVPREVIEW</version>
<version>[1.17.0.DEVPREVIEW, 2)</version>
</dependency>
<dependency>
<groupId>software.amazon.awscdk</groupId>
<artifactId>autoscaling</artifactId>
<version>1.14.0.DEVPREVIEW</version>
<version>[1.17.0.DEVPREVIEW, 2)</version>
</dependency>

<dependency>
<groupId>software.amazon.awscdk</groupId>
<artifactId>ec2</artifactId>
<version>1.14.0.DEVPREVIEW</version>
<version>[1.17.0.DEVPREVIEW, 2)</version>
</dependency>
<dependency>
<groupId>software.amazon.awscdk</groupId>
<artifactId>s3</artifactId>
<version>1.14.0.DEVPREVIEW</version>
<version>[1.17.0.DEVPREVIEW, 2)</version>
</dependency>
<dependency>
<groupId>software.amazon.awscdk</groupId>
<artifactId>sns</artifactId>
<version>1.14.0.DEVPREVIEW</version>
<version>[1.17.0.DEVPREVIEW, 2)</version>
</dependency>
<dependency>
<groupId>software.amazon.awscdk</groupId>
<artifactId>sqs</artifactId>
<version>1.14.0.DEVPREVIEW</version>
<version>[1.17.0.DEVPREVIEW, 2)</version>
</dependency>
<dependency>
<groupId>software.amazon.awscdk</groupId>
<artifactId>sns-subscriptions</artifactId>
<version>1.14.0.DEVPREVIEW</version>
<version>[1.17.0.DEVPREVIEW, 2)</version>
</dependency>

<!-- https://mvnrepository.com/artifact/junit/junit -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import software.amazon.awscdk.core.Stack;
import software.amazon.awscdk.core.Construct;
import software.amazon.awscdk.services.autoscaling.AutoScalingGroup;
import software.amazon.awscdk.services.autoscaling.AutoScalingGroupProps;
import software.amazon.awscdk.services.ec2.AmazonLinuxImage;
import software.amazon.awscdk.services.ec2.InstanceType;
import software.amazon.awscdk.services.ec2.Vpc;
Expand All @@ -19,7 +18,7 @@ class HelloJavaStack extends Stack {
public HelloJavaStack(final Construct parent, final String name) {
super(parent, name);

Vpc vpc = new Vpc(this, "VPC");
Vpc vpc = Vpc.Builder.create(this, "VPC").build();

MyAutoScalingGroupProps autoScalingGroupProps = new MyAutoScalingGroupProps();
autoScalingGroupProps.vpc = vpc;
Expand All @@ -43,11 +42,11 @@ static class MyAutoScalingGroup extends Construct {
MyAutoScalingGroup(final Construct parent, final String name, final MyAutoScalingGroupProps props) {
super(parent, name);

new AutoScalingGroup(this, "Compute", AutoScalingGroupProps.builder()
AutoScalingGroup.Builder.create(this, "Compute")
.instanceType(new InstanceType("t2.micro"))
.machineImage(new AmazonLinuxImage())
.vpc(props.vpc)
.build());
.build();
}

@Override
Expand Down
6 changes: 3 additions & 3 deletions java/lambda-cron/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,19 +55,19 @@
<dependency>
<groupId>software.amazon.awscdk</groupId>
<artifactId>core</artifactId>
<version>1.12.0.DEVPREVIEW</version>
<version>[1.17.0.DEVPREVIEW, 2)</version>
</dependency>

<dependency>
<groupId>software.amazon.awscdk</groupId>
<artifactId>lambda</artifactId>
<version>1.12.0.DEVPREVIEW</version>
<version>[1.17.0.DEVPREVIEW, 2)</version>
</dependency>

<dependency>
<groupId>software.amazon.awscdk</groupId>
<artifactId>events-targets</artifactId>
<version>1.12.0.DEVPREVIEW</version>
<version>[1.17.0.DEVPREVIEW, 2)</version>
</dependency>

<!-- https://mvnrepository.com/artifact/junit/junit -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import software.amazon.awscdk.services.lambda.Code;
import software.amazon.awscdk.services.lambda.Runtime;
import software.amazon.awscdk.services.lambda.SingletonFunction;
import software.amazon.awscdk.services.lambda.SingletonFunctionProps;

import java.util.UUID;

Expand All @@ -21,25 +20,21 @@ class LambdaCronStack extends Stack {
public LambdaCronStack(final Construct parent, final String name) {
super(parent, name);

SingletonFunction lambdaFunction = new SingletonFunction(this, "cdk-lambda-cron",
SingletonFunctionProps.builder()
.description("Lambda which prints \"I'm running\"")
.code(Code.fromInline(
"def main(event, context):\n" +
" print(\"I'm running!\")\n"))
.handler("index.main")
.timeout(Duration.seconds(300))
.runtime(Runtime.PYTHON_2_7)
.uuid(UUID.randomUUID().toString())
.build()
);
SingletonFunction lambdaFunction = SingletonFunction.Builder.create(this, "cdk-lambda-cron")
.description("Lambda which prints \"I'm running\"")
.code(Code.fromInline(
"def main(event, context):\n" +
" print(\"I'm running!\")\n"))
.handler("index.main")
.timeout(Duration.seconds(300))
.runtime(Runtime.PYTHON_2_7)
.uuid(UUID.randomUUID().toString())
.build();

Rule rule = new Rule(this, "cdk-lambda-cron-rule",
RuleProps.builder()
.description("Run every day at 6PM UTC")
.schedule(Schedule.expression("cron(0 18 ? * MON-FRI *)"))
.build()
);
Rule rule = Rule.Builder.create(this, "cdk-lambda-cron-rule")
.description("Run every day at 6PM UTC")
.schedule(Schedule.expression("cron(0 18 ? * MON-FRI *)"))
.build();

rule.addTarget(new LambdaFunction(lambdaFunction));
}
Expand Down

0 comments on commit 78bb11c

Please sign in to comment.