@Generated(value="jsii-pacmak/1.74.0 (build 6d08790)", date="2023-03-28T21:34:13.837Z") public class App extends Stage
You would normally define an App
instance in your program's entrypoint,
then define constructs where the app is used as the parent scope.
After all the child constructs are defined within the app, you should call
app.synth()
which will emit a "cloud assembly" from this app into the
directory specified by outdir
. Cloud assemblies includes artifacts such as
CloudFormation templates and assets that are needed to deploy this app into
the AWS cloud.
Example:
import path.*; import software.amazon.awscdk.services.lambda.*; import software.amazon.awscdk.core.App; import software.amazon.awscdk.core.Stack; import software.amazon.awscdk.services.apigateway.MockIntegration; import software.amazon.awscdk.services.apigateway.PassthroughBehavior; import software.amazon.awscdk.services.apigateway.RestApi; import software.amazon.awscdk.services.apigateway.TokenAuthorizer; /* * Stack verification steps: * * `curl -s -o /dev/null -w "%{http_code}" <url>` should return 401 * * `curl -s -o /dev/null -w "%{http_code}" -H 'Authorization: deny' <url>` should return 403 * * `curl -s -o /dev/null -w "%{http_code}" -H 'Authorization: allow' <url>` should return 200 */ App app = new App(); Stack stack = new Stack(app, "TokenAuthorizerInteg"); Function authorizerFn = Function.Builder.create(stack, "MyAuthorizerFunction") .runtime(Runtime.NODEJS_14_X) .handler("index.handler") .code(AssetCode.fromAsset(join(__dirname, "integ.token-authorizer.handler"))) .build(); RestApi restapi = new RestApi(stack, "MyRestApi"); TokenAuthorizer authorizer = TokenAuthorizer.Builder.create(stack, "MyAuthorizer") .handler(authorizerFn) .build(); restapi.root.addMethod("ANY", MockIntegration.Builder.create() .integrationResponses(List.of(IntegrationResponse.builder().statusCode("200").build())) .passthroughBehavior(PassthroughBehavior.NEVER) .requestTemplates(Map.of( "application/json", "{ \"statusCode\": 200 }")) .build(), MethodOptions.builder() .methodResponses(List.of(MethodResponse.builder().statusCode("200").build())) .authorizer(authorizer) .build());
Modifier and Type | Class and Description |
---|---|
static class |
App.Builder
A fluent builder for
App . |
IConstruct.Jsii$Default, IConstruct.Jsii$Proxy
Modifier | Constructor and Description |
---|---|
|
App()
Initializes a CDK application.
|
protected |
App(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) |
protected |
App(software.amazon.jsii.JsiiObjectRef objRef) |
Modifier and Type | Method and Description |
---|---|
static java.lang.Boolean |
isApp(java.lang.Object obj)
Checks if an object is an instance of the `App` class.
|
getAccount, getArtifactId, getAssetOutdir, getOutdir, getParentStage, getRegion, getStageName, isStage, of, synth, synth
getNode, isConstruct, onPrepare, onSynthesize, onValidate, prepare, synthesize, validate