I’m running into errors while porting the reference example from Terraform Transit Gateway module using cdktf.
cdktf.json
{
"language": "python",
"app": "pipenv run python main.py",
"terraformProviders": ["aws@~> 2.0"],
"terraformModules": [
"terraform-aws-modules/vpc/aws",
"terraform-aws-modules/transit-gateway/aws"
],
"codeMakerOutput": "imports"
}
app.py:
#!/usr/bin/env python
from constructs import Construct
from cdktf import App, TerraformStack, Token, TerraformOutput
from imports.aws import SnsTopic, AwsProvider, DataAwsCallerIdentity
from imports.terraform_aws_modules.vpc.aws import Vpc
from imports.terraform_aws_modules.transit_gatway.aws import TransitGateway
class MyStack(TerraformStack):
def __init__(self, scope: Construct, ns: str):
super().__init__(scope, ns)
AwsProvider(self, 'Aws', region='us-west-2')
vpc1 = Vpc(self, 'AriVpc2',
name = 'ari-vpc1',
cidr = '10.10.0.0/16',
azs = ['us-west-2a', 'us-west-2b', 'us-west-2c'],
private_subnets = ['10.10.1.0/24', '10.10.2.0/24', '10.10.3.0/24'],
public_subnets = ['10.10.101.0/24', '10.10.102.0/24', '10.10.103.0/24'],
enable_nat_gateway = True)
vpc2 = Vpc(self, 'AriVpc2',
name = 'ari-vpc2',
cidr = '10.20.0.0/16',
azs = ['us-west-2a', 'us-west-2b', 'us-west-2c'],
private_subnets = ['10.20.1.0/24', '10.20.2.0/24', '10.20.3.0/24'])
TransitGateway(self, 'AriTGW',
name = 'ari-tgw',
amazon_side_asn = '64632',
enable_auto_accept_shared_attachements = True,
vpc_attachments = {{
vpc1: {
vpc_id: vpc1.id,
subnet_ids: vpc1.cloudformation_endpoint_subnet_ids,
dns_support: True,
ipv6_support: True,
transit_gateway_default_route_table_association: False,
transit_gateway_default_route_table_propagation: False,
tgw_routes: [
{
destination_cidr_block: "30.0.0.0/16"
},
{
blackhole: True,
destination_cidr_block: "0.0.0.0/0"
}
]
},
vpc2: {
vpc_id: vpc2.id,
subnet_ids: vpc2.cloudformation_endpoint_subnet_ids,
tgw_routes: [
{
destination_cidr_block: "50.0.0.0/16"
},
{
blackhole: True,
destination_cidr_block: "10.10.10.10/32"
}
]
}
}})
TerraformOutput(self, 'create_user_arn',
value=DataAwsCallerIdentity(self, 'current').arn)
app = App()
MyStack(app, "python-aws")
app.synth()
Error:
$ cdktf get
(I can see transit_gateway/aws is imported in 'imports')
$ cdktf synth
⠋ synthesizing ...
Traceback (most recent call last):
File "main.py", line 6, in <module>
from imports.terraform_aws_modules.transit_gatway.aws
import TransitGateway
⠸ synthesizing ...
non-zero exit code 1
What am I missing?