Note
Currently the |cdk| only supports applets published as JavaScript modules.
Applets are files in the YAML or JSON format that have the following root attribute,
where MODULE can represent
a local file, such as ./my-module
,
a local dependency, such as my-dependency
,
or a global module, such as @aws-cdk/aws-s3
and CLASS is the name of a class exported by the module.
applet: MODULE[:CLASS]
If CLASS is not specified, Applet
is used as the default class name.
Therefore, you need only refer to |cdk| construct libraries that export
an Applet
class by their library name.
The rest of the YAML file is applet-dependent.
The object is passed as props
when the applet object is instantiated
and added to an |cdk| app created by cdk-applet-js.
Use cdk-applet-js applet to run the applet, create an |cdk| app, and use that with the |cdk| tools, as shown in the following example.
cdk --app "cdk-applet-js ./my-applet.yaml" synth
To make the applet file executable and use the host as a shebang on Unix-based systems, such as Linux, MacOS, or Windows Bash shell, create a script similar to the following.
#!/usr/bin/env cdk-applet-js
applet: aws-cdk-codebuild
source: arn:aws:codecommit:::my-repository
image: node:8.9.4
compute: large
build:
- npm install --unsafe-perm
- npm test
- npm pack --unsafe-perm
To execute the applet and synthesize an |CFN| template, use the following command.
cdk synth --app "./build.yaml"
To avoid needing --app for every invocation, add the following entry to cdk.json.
{
"app": "./build.yaml"
}