Class App
A construct which represents an entire CDK app. This construct is normally the root of the construct tree.
Inherited Members
Namespace: Amazon.CDK
Assembly: Amazon.CDK.dll
Syntax (csharp)
public class App : Stage, IConstruct, IDependable
Syntax (vb)
Public Class App
Inherits Stage
Implements IConstruct, IDependable
Remarks
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.
See: https://docs.aws.amazon.com/cdk/latest/guide/apps.html
ExampleMetadata: lit=test/authorizers/integ.token-authorizer.lit.ts infused
Examples
using Path;
using Amazon.CDK.AWS.Lambda;
using Amazon.CDK;
using Amazon.CDK.AWS.APIGateway;
/*
* 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
*/
var app = new App();
var stack = new Stack(app, "TokenAuthorizerInteg");
var authorizerFn = new Function(stack, "MyAuthorizerFunction", new FunctionProps {
Runtime = Runtime.NODEJS_14_X,
Handler = "index.handler",
Code = AssetCode.FromAsset(Join(__dirname, "integ.token-authorizer.handler"))
});
var restapi = new RestApi(stack, "MyRestApi");
var authorizer = new TokenAuthorizer(stack, "MyAuthorizer", new TokenAuthorizerProps {
Handler = authorizerFn
});
restapi.Root.AddMethod("ANY", new MockIntegration(new IntegrationOptions {
IntegrationResponses = new [] { new IntegrationResponse { StatusCode = "200" } },
PassthroughBehavior = PassthroughBehavior.NEVER,
RequestTemplates = new Dictionary<string, string> {
{ "application/json", "{ \"statusCode\": 200 }" }
}
}), new MethodOptions {
MethodResponses = new [] { new MethodResponse { StatusCode = "200" } },
Authorizer = authorizer
});
Synopsis
Constructors
App(IAppProps) | Initializes a CDK application. |
App(ByRefValue) | Used by jsii to construct an instance of this class from a Javascript-owned object reference |
App(DeputyBase.DeputyProps) | Used by jsii to construct an instance of this class from DeputyProps |
Methods
IsApp(Object) | Checks if an object is an instance of the |
Constructors
App(IAppProps)
Initializes a CDK application.
public App(IAppProps props = null)
Parameters
- props IAppProps
initialization properties.
App(ByRefValue)
Used by jsii to construct an instance of this class from a Javascript-owned object reference
protected App(ByRefValue reference)
Parameters
- reference Amazon.JSII.Runtime.Deputy.ByRefValue
The Javascript-owned object reference
App(DeputyBase.DeputyProps)
Used by jsii to construct an instance of this class from DeputyProps
protected App(DeputyBase.DeputyProps props)
Parameters
- props Amazon.JSII.Runtime.Deputy.DeputyBase.DeputyProps
The deputy props
Methods
IsApp(Object)
Checks if an object is an instance of the App
class.
public static bool IsApp(object obj)
Parameters
- obj System.Object
The object to evaluate.
Returns
System.Boolean
true
if obj
is an App
.