Skip to content

Converting CloudFormation into CDK? #30134

Answered by Flupinochan
awhillas asked this question in Q&A
Discussion options

You must be logged in to vote

Hello,
In summary, you need to use Ref to reference the Internet Gateway ID as follows:

self.internet_gateway = ec2.CfnInternetGateway(self, "InternetGateway")

ec2.CfnRoute(
    self,
    "InternetRoute",
    route_table_id=self.route_table.attr_route_table_id,
    destination_cidr_block="0.0.0.0/0",
    gateway_id=self.internet_gateway.ref,
)

or

self.internet_gateway = ec2.CfnInternetGateway(self, "InternetGateway")

ec2.CfnRoute(
    self,
    "InternetRoute",
    route_table_id=self.route_table.attr_route_table_id,
    destination_cidr_block="0.0.0.0/0",
    gateway_id=self.internet_gateway.attr_internet_gateway_id,
)

In CDK, there are construct levels. You are using Level 1, so you n…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Flupinochan
Comment options

Answer selected by awhillas
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants