#!/usr/bin/env python
from constructs import Construct
from cdktf import App, TerraformStack
from imports.aws import AwsProvider , Vpc , Subnet , InternetGateway
class MyStack(TerraformStack):
def init(self, scope: Construct, ns: str):
super().init(scope, ns)
# define resources here
regions="us-east-1"
vpcs="78.1.0.0/16"
zones=["us-east-1a" , "us-east-1b" , "us-east-1c"]
subnt1=["78.1.100.0/24" ,"78.1.101.0/24" , "78.1.102.0/24"]
subnt2=["78.1.10.0/24" ,"78.1.11.0/24" , "78.1.12.0/24"]
subnt3=["78.1.20.0/24" ,"78.1.21.0/24" , "78.1.22.0/24"]
tags1=["public1" , "public2" , "public3"]
tags2=["web1" , "web2" , "web3"]
tags3=["db1" , "db2" , "db3"]
AwsProvider(self , "Aws" , region=regions)
Vpc(self , "vpcrole" , cidr_block=vpcs)
Subnet(self , "sbnt1" , vpc_id="vpcrole" , availability_zone=zones , cidr_block=subnt1 ,
map_public_ip_on_launch=True , tags=tags1 ,count=3)
Subnet(self , "sbnt2" , vpc_id="vpcrole" , availability_zone=zones , cidr_block=subnt2 ,
tags=tags2 ,count=3)
Subnet(self , "sbnt3" , vpc_id="vpcrole" , availability_zone=zones , cidr_block=subnt3 ,
tags=tags3 ,count=3)
InternetGateway(self , "intgw" , vpc_id="vpcrole")
app = App()
MyStack(app, “projects-python”)
app.synth()
============
synthesizing…
[2021-10-31T15:15:40.227] [ERROR] default - Courtesy Notice: Pipenv found itself running within a virtual environment, so it will automatically use that environment, instead of creating its own for any project. You can set PIPENV_IGNORE_VIRTUALENVS=1 to force pipenv to ignore that environment and create its own instead. You can set PIPENV_VERBOSITY=-1 to suppress this warning.
⠧ synthesizing…
[2021-10-31T15:16:26.217] [ERROR] default - jsii.errors.JavaScriptError:
Error: Expected a string, got [“78.1.100.0/24”,“78.1.101.0/24”,“78.1.102.0/24”]
at Object.deserialize (C:\Users\MOHAMM~1\AppData\Local\Temp\tmp59jcomzu\lib\program.js:9145:31)
at Kernel._toSandbox (C:\Users\MOHAMM~1\AppData\Local\Temp\tmp59jcomzu\lib\program.js:8783:69)
at C:\Users\MOHAMM~1\AppData\Local\Temp\tmp59jcomzu\lib\program.js:9348:37
at mapValues (C:\Users\MOHAMM~1\AppData\Local\Temp\tmp59jcomzu\lib\program.js:9619:35)
at Object.deserialize (C:\Users\MOHAMM~1\AppData\Local\Temp\tmp59jcomzu\lib\program.js:9344:28)
at Kernel._toSandbox (C:\Users\MOHAMM~1\AppData\Local\Temp\tmp59jcomzu\lib\program.js:8783:69)
at C:\Users\MOHAMM~1\AppData\Local\Temp\tmp59jcomzu\lib\program.js:8831:42
at Array.map ()
at Kernel._boxUnboxParameters (C:\Users\MOHAMM~1\AppData\Local\Temp\tmp59jcomzu\lib\program.js:8831:27)
at Kernel._toSandboxValues (C:\Users\MOHAMM~1\AppData\Local\Temp\tmp59jcomzu\lib\program.js:8817:29)
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
[2021-10-31T15:16:26.220] [ERROR] default - File “E:\cdktf-python\projects-python\main.py”, line 35, in
MyStack(app, “projects-python”)
File “C:\Users\Mohammedbanabila.virtualenvs\projects-python-M_MdHqee\lib\site-packages\jsii_runtime.py”, line 86, in call inst = super().call(*args, **kwargs)
File “E:\cdktf-python\projects-python\main.py”, line 23, in init
Subnet(self , “sbnt1” , vpc_id=“vpcrole” , availability_zone=zones , cidr_block=subnt1 ,
File “C:\Users\Mohammedbanabila.virtualenvs\projects-python-M_MdHqee\lib\site-packages\jsii_runtime.py”, line 86, in call inst = super().call(*args, **kwargs)
File “E:\cdktf-python\projects-python\imports\aws_init_.py”, line 475997, in init
⠇ synthesizing…
[2021-10-31T15:16:26.349] [ERROR] default - jsii.create(self.class, self, [scope, id, config])
File “C:\Users\Mohammedbanabila.virtualenvs\projects-python-M_MdHqee\lib\site-packages\jsii_kernel_init_.py”, line 290, in create
[2021-10-31T15:16:26.350] [ERROR] default - response = self.provider.create(
File “C:\Users\Mohammedbanabila.virtualenvs\projects-python-M_MdHqee\lib\site-packages\jsii_kernel\providers\process.py”, line 344, in create
return self._process.send(request, CreateResponse)
File “C:\Users\Mohammedbanabila.virtualenvs\projects-python-M_MdHqee\lib\site-packages\jsii_kernel\providers\process.py”, line 326, in send
[2021-10-31T15:16:26.352] [ERROR] default - raise JSIIError(resp.error) from JavaScriptError(resp.stack)
jsii.errors.JSIIError: Expected a string, got [“78.1.100.0/24”,“78.1.101.0/24”,“78.1.102.0/24”]
cdktf encountered an error while synthesizing
Synth command: pipenv run python main.py
Error: non-zero exit code 1
Command output on stderr:
Courtesy Notice: Pipenv found itself running within a virtual environment, so it will automatically use that environment, instead of creating its own for any project. You can set PIPENV_IGNORE_VIRTUALENVS=1 to force pipenv to ignore that environment and
create its own instead. You can set PIPENV_VERBOSITY=-1 to suppress this warning.
jsii.errors.JavaScriptError:
Error: Expected a string, got [“78.1.100.0/24”,“78.1.101.0/24”,“78.1.102.0/24”]
at Object.deserialize (C:\Users\MOHAMM~1\AppData\Local\Temp\tmp59jcomzu\lib\program.js:9145:31)
at Kernel._toSandbox (C:\Users\MOHAMM~1\AppData\Local\Temp\tmp59jcomzu\lib\program.js:8783:69)
at C:\Users\MOHAMM~1\AppData\Local\Temp\tmp59jcomzu\lib\program.js:9348:37
at mapValues (C:\Users\MOHAMM~1\AppData\Local\Temp\tmp59jcomzu\lib\program.js:9619:35)
at Object.deserialize (C:\Users\MOHAMM~1\AppData\Local\Temp\tmp59jcomzu\lib\program.js:9344:28)
at Kernel._toSandbox (C:\Users\MOHAMM~1\AppData\Local\Temp\tmp59jcomzu\lib\program.js:8783:69)
at C:\Users\MOHAMM~1\AppData\Local\Temp\tmp59jcomzu\lib\program.js:8831:42
at Array.map ()
at Kernel._boxUnboxParameters (C:\Users\MOHAMM~1\AppData\Local\Temp\tmp59jcomzu\lib\program.js:8831:27)
at Kernel._toSandboxValues (C:\Users\MOHAMM~1\AppData\Local\Temp\tmp59jcomzu\lib\program.js:8817:29)
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "E:\cdktf-python\projects-python\main.py", line 35, in <module>
MyStack(app, "projects-python")
File "C:\Users\Mohammedbanabila\.virtualenvs\projects-python-M_MdHqee\lib\site-packages\jsii\_runtime.py", line 86, in __call__
inst = super().__call__(*args, **kwargs)
File "E:\cdktf-python\projects-python\main.py", line 23, in __init__
Subnet(self , "sbnt1" , vpc_id="vpcrole" , availability_zone=zones , cidr_block=subnt1 ,
File "C:\Users\Mohammedbanabila\.virtualenvs\projects-python-M_MdHqee\lib\site-packages\jsii\_runtime.py", line 86, in __call__
inst = super().__call__(*args, **kwargs)
File "E:\cdktf-python\projects-python\imports\aws\__init__.py", line 475997, in __init__
jsii.create(self.__class__, self, [scope, id, config])
File "C:\Users\Mohammedbanabila\.virtualenvs\projects-python-M_MdHqee\lib\site-packages\jsii\_kernel\__init__.py", line 290, in create
response = self.provider.create(
File "C:\Users\Mohammedbanabila\.virtualenvs\projects-python-M_MdHqee\lib\site-packages\jsii\_kernel\providers\process.py", line 344, in create
return self._process.send(request, CreateResponse)
File "C:\Users\Mohammedbanabila\.virtualenvs\projects-python-M_MdHqee\lib\site-packages\jsii\_kernel\providers\process.py", line 326, in send
raise JSIIError(resp.error) from JavaScriptError(resp.stack)
jsii.errors.JSIIError: Expected a string, got ["78.1.100.0/24","78.1.101.0/24","78.1.102.0/24"]