Reputation: 7856
In my AWS CDK/ Typescript project I have 1 main stack i.e. aws-microservices-stack.ts
rest all typescript files are just constructs extended in aws-microservices-stack.ts
But when I run cdk deploy
I get error
Since this app includes more than a single stack, specify which stacks to use (wildcards are supported) or specify
--all
Stacks: AwsMicroservicesStack · AwsMicroservicesStack/Database · AwsMicroservicesStack/Microservices · AwsMicroservicesStack/ApiGateway
How can I mark aws-microservices-stack.ts
so that deploy command picks up only that stack
aws-microservices-stack.ts
import { Stack, StackProps } from 'aws-cdk-lib';;
import { Construct } from 'constructs';
import { SwnApiGateway } from './apigateway';
import { SwnDatabase } from './database';
import { SwnMicroServices } from './microservices';
export class AwsMicroservicesStack extends Stack {
constructor(scope: Construct, id: string, props?: StackProps) {
super(scope, id, props);
const database = new SwnDatabase(this, 'Database');
....
}
}
database.ts
import { RemovalPolicy, Stack } from 'aws-cdk-lib';
import { AttributeType, BillingMode, ITable, Table } from 'aws-cdk-lib/aws-dynamodb';
import { Construct } from 'constructs';
export class SwnDatabase extends Stack {
public readonly productTable: ITable;
constructor(scope: Construct, id: string) {
super(scope, id);
// DynamoDb Table
const productTable = new Table(this, 'product', {
partitionKey: {
name: 'id',
type: AttributeType.STRING
},
tableName: 'product',
removalPolicy: RemovalPolicy.DESTROY,
billingMode: BillingMode.PAY_PER_REQUEST
});
this.productTable = productTable;
}
}
Upvotes: 9
Views: 13392
Reputation: 488
With specific profile and region
cdk deploy <stackname> --profile <profilename> --region <region>
Upvotes: 3
Reputation: 566
You can do
cdk deploy $stack_name --exclusively
From the CLI help docs:
-e, --exclusively Only deploy requested stacks, don't include dependencies [boolean]
Upvotes: 7