aws-cdk-lib.App

class App

LanguageType name
.NETAmazon.CDK.App
Gogithub.com/aws/aws-cdk-go/awscdk/v2#App
Javasoftware.amazon.awscdk.App
Pythonaws_cdk.App
TypeScript (source)aws-cdk-lib » App

Implements IConstruct, IDependable

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.

See also: https://docs.aws.amazon.com/cdk/latest/guide/apps.html

Example

import * as cdk from '../../core';
import * as servicediscovery from '../lib';

const app = new cdk.App();
const stack = new cdk.Stack(app, 'aws-servicediscovery-integ');

const namespace = new servicediscovery.PublicDnsNamespace(stack, 'Namespace', {
  name: 'foobar.com',
});

const service = namespace.createService('Service', {
  name: 'foo',
  dnsRecordType: servicediscovery.DnsRecordType.CNAME,
  dnsTtl: cdk.Duration.seconds(30),
});

service.registerCnameInstance('CnameInstance', {
  instanceCname: 'service.pizza',
});

app.synth();

Initializer

new App(props?: AppProps)

Parameters

  • props AppProps — initialization properties.

Initializes a CDK application.

Properties

NameTypeDescription
artifactIdstringArtifact ID of the assembly if it is a nested stage. The root stage (app) will return an empty string.
assetOutdirstringThe cloud assembly asset output directory.
nodeNodeThe tree node.
outdirstringThe cloud assembly output directory.
policyValidationBeta1IPolicyValidationPluginBeta1[]Validation plugins to run during synthesis.
stageNamestringThe name of the stage.
account?stringThe default account for all resources defined within this stage.
parentStage?StageThe parent stage or undefined if this is the app.
region?stringThe default region for all resources defined within this stage.

artifactId

Type: string

Artifact ID of the assembly if it is a nested stage. The root stage (app) will return an empty string.

Derived from the construct path.


assetOutdir

Type: string

The cloud assembly asset output directory.


node

Type: Node

The tree node.


outdir

Type: string

The cloud assembly output directory.


policyValidationBeta1

Type: IPolicyValidationPluginBeta1[]

Validation plugins to run during synthesis.

If any plugin reports any violation, synthesis will be interrupted and the report displayed to the user.


stageName

Type: string

The name of the stage.

Based on names of the parent stages separated by hypens.


account?

Type: string (optional)

The default account for all resources defined within this stage.


parentStage?

Type: Stage (optional)

The parent stage or undefined if this is the app.


region?

Type: string (optional)

The default region for all resources defined within this stage.

Methods

NameDescription
synth(options?)Synthesize this stage into a cloud assembly.
toString()Returns a string representation of this construct.
static isApp(obj)Checks if an object is an instance of the App class.

synth(options?)

public synth(options?: StageSynthesisOptions): CloudAssembly

Parameters

  • options StageSynthesisOptions

Returns

  • CloudAssembly

Synthesize this stage into a cloud assembly.

Once an assembly has been synthesized, it cannot be modified. Subsequent calls will return the same assembly.


toString()

public toString(): string

Returns

  • string

Returns a string representation of this construct.


static isApp(obj)

public static isApp(obj: any): boolean

Parameters

  • obj any — The object to evaluate.

Returns

  • boolean

Checks if an object is an instance of the App class.