如何使用 AWS SDK 部署特定堆栈?
How to deploy a specific stack using AWS SDK?
在我的 AWS CDK/Typescript 项目中,我有 1 个主堆栈,即 aws-microservices-stack.ts
其余所有打字稿文件都只是在 aws-microservices-stack.ts
中扩展的结构
但是当我 运行 cdk deploy
我得到错误
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
我如何标记 aws-microservices-stack.ts
以便部署命令只选择那个堆栈
aws-微服务-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;
}
}
您不能将其“标记”为部署,您需要指定要部署的堆栈:
cdk deploy $yourstackname
声明堆栈的名称由
列出
cdk ls
Here 您可以阅读有关 cdk 堆栈处理的更多信息。
在我的 AWS CDK/Typescript 项目中,我有 1 个主堆栈,即 aws-microservices-stack.ts
其余所有打字稿文件都只是在 aws-microservices-stack.ts
但是当我 运行 cdk deploy
我得到错误
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
我如何标记 aws-microservices-stack.ts
以便部署命令只选择那个堆栈
aws-微服务-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;
}
}
您不能将其“标记”为部署,您需要指定要部署的堆栈:
cdk deploy $yourstackname
声明堆栈的名称由
列出cdk ls
Here 您可以阅读有关 cdk 堆栈处理的更多信息。