CloudFormation init requires the presence of helper script on the instance. Ubuntu does not come with it, so you have to set it up yourself.cfn-init
Here's the AWS guide that contains links to the installation scripts for Ubuntu 16.04/18.04/20.04. You need to add these to the prop of your instance. Then cloudformation-init will work.user_data
If you just want to create a file when the instance starts, though, you don't have to use at all - you could just supply the command that creates your file to the cfn-init prop directly:user_data
self.ec2_instance.user_data.add_commands("echo welcome > /home/ubuntu/textfile.txt")
Likely there is something else called ahead of the nodejs cdk package in your path. You can use the aws-cdk command to figure out what path is actually being called when you run which On my system, the nodejs cdk. package gets installed to aws-cdk./usr/local/bin/cdk
Try running and if you find that your shell tells you it's running a different which cdk binary, uninstall whatever that package is and retry.cdk
TLDR;
solved this same issue at my end.env/bin/pip3.8 install -r requirements.txt
Once you run it actually looks for python libraries on source .env/bin/activate (at least for me!). Thus running .env/lib/python3.8/site-packages which calls app.py will looks for aws_cdk in venv site package, not from system site-package as long as "include-system-site-packages = false" under .env/pyvenv.cfgcdk ls