Skip to content

Latest commit

 

History

History
53 lines (38 loc) · 1.92 KB

File metadata and controls

53 lines (38 loc) · 1.92 KB

Stacks

A |stack| is an |cdk| construct that can be deployed into an AWS environment. The combination of region and account becomes the stack's environment, as described in :ref:`environments`. Most production apps consist of multiple stacks of resources that are deployed as a single transaction using a resource provisioning service like |CFN|. Any resources added directly or indirectly as children of a stack are included in the stack's template as it is synthesized by your |cdk| program.

Define an application stack by extending the |stack-class| class, as shown in the following example.

import { Stack, StackProps } from '@aws-cdk/cdk'

interface MyStackProps extends StackProps {
    encryptedStorage: boolean;
}

class MyStack extends Stack {
    constructor(parent: Construct, name: string, props?: MyStackProps) {
        super(parent, name, props);

        new MyStorageLayer(this, 'Storage', { encryptedStorage: props.encryptedStorage });
        new MyControlPlane(this, 'CPlane');
        new MyDataPlane(this, 'DPlane');
    }
}

And then, add instances of this class to your app:

const app = new App();

new MyStack(app, 'NorthAmerica', { env: { region: 'us-east-1' } });
new MyStack(app, 'Europe', { env: { region: 'us-west-2' } });