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 Answer
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
EXPERT
answered 9 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions