Package software.amazon.awscdk.core
Class App
java.lang.Object
software.amazon.jsii.JsiiObject
software.constructs.Construct
software.amazon.awscdk.core.Construct
software.amazon.awscdk.core.Stage
software.amazon.awscdk.core.App
- All Implemented Interfaces:
IConstruct,IDependable,software.amazon.jsii.JsiiSerializable,software.constructs.IConstruct
@Generated(value="jsii-pacmak/1.84.0 (build 5404dcf)",
date="2023-06-19T16:29:54.781Z")
@Stability(Stable)
public class App
extends Stage
A construct which represents an entire CDK app. This construct is normally the root of the construct tree.
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());
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class software.amazon.jsii.JsiiObject
software.amazon.jsii.JsiiObject.InitializationModeNested classes/interfaces inherited from interface software.amazon.awscdk.core.IConstruct
IConstruct.Jsii$Default, IConstruct.Jsii$ProxyNested classes/interfaces inherited from interface software.constructs.IConstruct
software.constructs.IConstruct.Jsii$Default, software.constructs.IConstruct.Jsii$Proxy -
Constructor Summary
Constructors -
Method Summary
Methods inherited from class software.amazon.awscdk.core.Stage
getAccount, getArtifactId, getAssetOutdir, getOutdir, getParentStage, getRegion, getStageName, isStage, of, synth, synthMethods inherited from class software.amazon.awscdk.core.Construct
getNode, isConstruct, onPrepare, onSynthesize, onValidate, prepare, synthesize, validateMethods inherited from class software.constructs.Construct
toStringMethods inherited from class software.amazon.jsii.JsiiObject
jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSetMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface software.amazon.jsii.JsiiSerializable
$jsii$toJson
-
Constructor Details
-
App
protected App(software.amazon.jsii.JsiiObjectRef objRef) -
App
protected App(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) -
App
Initializes a CDK application.- Parameters:
props- initialization properties.
-
App
@Stability(Stable) public App()Initializes a CDK application.
-
-
Method Details
-
isApp
Checks if an object is an instance of theAppclass.- Parameters:
obj- The object to evaluate. This parameter is required.- Returns:
trueifobjis anApp.
-