簡體   English   中英

使用 AWS CDK typescript 時默認堆棧不正確

[英]Default Stack not correct while using AWS CDK typescript

我想確認 cdk in./lib 生成的默認堆棧 VPC 是否正確。 這是我的步驟-

%% cdk --version
1.83.0 (build 827c5f4)
%% tsc --version
Version 4.1.3
mkdir vpc
cd vpc 
cdk init app --language=typescript

現在,如果我查看文件 ./lib/vpc-stack.ts

import * as cdk from '@aws-cdk/core';

export class VpcStack extends cdk.Stack {
  constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) {
    super(scope, id, props);

    // The code that defines your stack goes here
  }
}

但是,該文件應該是(我認為)

//vpc-stack.ts
import {App, Stack, StackProps} from '@aws-cdk/core';
import {Peer, Port, SecurityGroup, SubnetType, Vpc} from '@aws-cdk/aws-ec2'

export class VpcStack extends Stack {
    readonly vpc: Vpc;
    readonly ingressSecurityGroup: SecurityGroup;
    readonly egressSecurityGroup: SecurityGroup;

    constructor(scope: App, id: string, props?: StackProps) {
        super(scope, id, props);

        //Place resource definitions here.
    }
}

如果有人能指出缺少的步驟,我真的很感激。

謝謝 !

app模板創建一個空堆棧定義: https://docs.aws.amazon.com/cdk/latest/guide/cli.html#cli-init

TEMPLATE is an optional template. If the desired template is app, the default, you may omit it. The available templates are:

Template | Description
app (default) | Creates an empty AWS CDK app.
sample-app | Creates an AWS CDK app with a stack containing an Amazon SQS queue and an Amazon SNS topic.

The templates use the name of the project folder to generate names for files and classes inside your new app.

沒有資源的堆棧定義是預期的命令 output。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM