This Python package provides a L2 CDK Construct for spinning up a EC2 instance from a YAML configuration to quickly create and manage development instances.
The instances created have public IPs (cheaper than NAT Gateway for single instances) but has no open ports. All access to the instance should be done via System Manager Session Manager.
- Set up CDK. If unfamiliar with CDK see the Getting Started Guide
- Bootstrap your account for CDK deployments.
cdk bootstrap aws://{account_number}/{region}
- Create a configuration file based on the example (
config.example.yaml
) - Deploy the instance with CDK
cdk deploy
Work in progress!
-
Install the Session Manager plugin for the AWS CLI - Docs
-
Connect to your instance with Session Manager
aws ssm start-session --target {instance_id}
-
(Optional) Port Foward SSH to your local machine with SSH, for example if you want to use VSCode Remote-SSH - Docs.
Windows (Powershell):
aws ssm start-session ` --target {instance_id} ` --document-name AWS-StartPortForwardingSession ` --parameters portNumber="22",localPortNumber="40000"
Linux/Mac (bash):
aws ssm start-session \ --target {instance_id} \ --document-name AWS-StartPortForwardingSession \ --parameters "{"portNumber":["22"],"localPortNumber":["40000"]}"
-
(Optional) SSH into your instance
ssh -i /path/key-pair-name.pem -p 40000 ec2-user@localhost