@Generated(value="jsii-pacmak/1.67.0 (build 2c027f5)", date="2022-09-28T18:14:31.764Z") @Stability(value=Stable) 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 . |
software.amazon.jsii.JsiiObject.InitializationMode
IConstruct.Jsii$Default, IConstruct.Jsii$Proxy
Modifier | Constructor and Description |
---|---|
|
App()
Initializes a CDK application.
|
|
App(AppProps props)
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 Boolean |
isApp(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
jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSet
protected App(software.amazon.jsii.JsiiObjectRef objRef)
protected App(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
@Stability(value=Stable) public App(@Nullable AppProps props)
props
- initialization properties.@Stability(value=Stable) public App()
Copyright © 2022. All rights reserved.