pip3 install poetry
(poetry is the package manager used for this library)poetry shell
- source into a virtual environment (create a new one if it doesn't exist)poetry install
- install the dependencies for this package
- run
deployments-cli
- (this CLI will be added to your path duringpoetry install
)- create-ec2-security-group Create a security group that can be accessed from anywhere
- list-ec2 Lists all non-terminated instances.
- list-security-groups Lists all security groups
- spin-down-ec2 Spins down all instances associated with a specific keyname-pair
- spin-up-ec2 Spin up EC2 instance(s)
Note about Spin-up-ec2, it is recommended that you spin up using a permissioned file that you already have saved in AWS
pem-file. The public/secret pem-file combo should be saved in AWS under a specific name. When running spin-up-ec2
provide that name, as spin-up-ec2 -k <keypair_name>
.
Note: run deployments-cli --help
or deployments-cli <subcommand> --help
for help.
- You need to create a security group that can be accessed from anywhere first. So use :
deployments-cli create-ec2-security-group -v <vpc-id>
and thendeployments-cli list-security-groups
to create such a security group. It will print out something of the formsg-0da77507b0dfbec4c
(Note the first call may error out, if the security group already exists) - Then you need to create EC2 instances that are attached to that security group, use :
deployments-cli spin-up-ec2 -k <ec2-keypair> -N ## -s <security-group-id>
- Then to confirm their status run
deployments-cli list-ec2 -k <ec2-keypair>
- When done, run
deployments-cli spin-down-ec2 -k <ec2-keypair>
- Note: if you do not include
-k <keypair>
, all instances will be shutdown. CAREFUL!
- Note: if you do not include
- https://boto3.amazonaws.com/v1/documentation/api/latest/guide/quickstart.html#installation
- https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ec2.html
- https://stackoverflow.com/questions/13585857/how-to-launch-ec2-instance-with-boto-specifying-size-of-ebs
- https://hands-on.cloud/working-with-ec2-instances-using-boto3-in-python/
- https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-security-groups.html