in code/java/main-workshop/src/main/java/com/myorg/CdkWorkshopStack.java [19:44]
public CdkWorkshopStack(final Construct parent, final String id, final StackProps props) {
super(parent, id, props);
// Defines a new lambda resource
final Function hello = Function.Builder.create(this, "HelloHandler")
.runtime(Runtime.NODEJS_14_X) // execution environment
.code(Code.fromAsset("lambda")) // code loaded from the "lambda" directory
.handler("hello.handler") // file is "hello", function is "handler"
.build();
// Defines our hitcounter resource
final HitCounter helloWithCounter = new HitCounter(this, "HelloHitCounter", HitCounterProps.builder()
.downstream(hello)
.build());
// Defines an API Gateway REST API resource backed by our "hello" function
LambdaRestApi.Builder.create(this, "Endpoint")
.handler(helloWithCounter.getHandler())
.build();
// Defines a viewer for the HitCounts table
TableViewer.Builder.create(this, "ViewerHitCount")
.title("Hello Hits")
.table(helloWithCounter.getTable())
.build();
}