AWS CDK (TypeScript) - VPC, subnets and routing tables

0

Hello,

I am new to using AWS CDK, I need to set up the network infrastructure in code using AWS CDK(Typescript). I have tried setting some basic infrastructure and at it seems to work, however, I don't seem to have any control over being able to rename any of the stacks I have created to something simple like test-vpc instead of being given [STACK/STACKNAME/TEST-VPC/subnet. Also when creating the routing table for the VPC it created multiple extra tables that I did not define, almost like its creating default tables in addition to my code.

It seems to me anyway that its a lot easier to create this via cloud formation (more control of resource names and referencing)

My question - is there any tips or guides to help define the CDK code for networking, I have only got as far as the basics and still got a long way to go with the likes of creating TGWs, NFWs

Any good example of a VPC, subnet and route table association CDK stacks that I could use?

Thanks

1回答
0

Hi,

On your question about choosing physical stack names with CDK, look at https://docs.aws.amazon.com/cdk/v2/guide/stacks.html at end of section preceding section 'Stack API', you have examples in all languages

The physical names of the AWS CloudFormation stacks are automatically determined 
by the AWS CDK based on the stack's construct path in the tree. By default, a stack's 
name is derived from the construct ID of the Stack object. However, you can specify 
an explicit name by using the stackName prop (in Python, stack_name), as follows.

On good sample, see for example https://github.com/sebsto/cdk-vpc-example/blob/master/bin/vpc-ingress-routing.ts

class VpcIngressRoutingStack is a good example

Hope it helps!

Didier

profile pictureAWS
エキスパート
回答済み 10ヶ月前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ