Code Monkey home page Code Monkey logo

aws-simple-ec2-cli's Introduction

AWS Simple EC2 CLI

A CLI tool that simplifies the process of launching, connecting and terminating an EC2 instance.

go-version license


Summary

In order to launch a new EC2 instance, customers need to specify a lot of options, and it can be a slow and overwhelming task. It requires users to have an initial network stack (VPC-Id/Subnet-Id/Security-Groups), remote login, and many more. Often times, we require EC2 instance for adhoc testing for a short period of time without requiring complex networking infrastructure in place. AWS Simple EC2 CLI aims to solve this issue and make it easier for users to launch, connect and terminate EC2 instances with a single command

Major Features

  • Launch an instance using single command
  • Connect to an instance using single command
  • Terminate an instance using single command
  • Interactive mode that help users to decide parameters to use
  • Config file for more convenient launch

Installation and Configuration

Install AWS CLI

To execute the CLI, you will need AWS credentials configured. Take a look at the AWS CLI configuration documentation for details on the various ways to configure credentials. Alternatively, you can try out the AWS Simple EC2 CLI by populating following environment variables:

export AWS_ACCESS_KEY_ID="..."
export AWS_SECRET_ACCESS_KEY="..."
# Set default Region (optional)
export AWS_REGION="us-east-1" 

Install w/ Homebrew

brew tap aws/tap
brew install aws-simple-ec2-cli

Install w/ Curl

MacOS/Linux

curl -Lo simple-ec2 https://github.com/awslabs/aws-simple-ec2-cli/releases/download/v0.10.0/simple-ec2-`uname | tr '[:upper:]' '[:lower:]'`-amd64
chmod +x simple-ec2

ARM Linux

curl -Lo simple-ec2 https://github.com/awslabs/aws-simple-ec2-cli/releases/download/v0.10.0/simple-ec2-linux-arm
curl -Lo simple-ec2 https://github.com/awslabs/aws-simple-ec2-cli/releases/download/v0.10.0/simple-ec2-linux-arm64

Windows

curl -Lo simple-ec2 https://github.com/awslabs/aws-simple-ec2-cli/releases/download/v0.10.0/simple-ec2-windows-amd64.exe

Examples

Version

$ simple-ec2 version
Prints the version of this tool

Launch

All CLI Options

$ simple-ec2 launch -h
Launch an Amazon EC2 instance with the default configurations. All configurations can be overridden by configurations provided by configuration files or user input.

Usage:
  simple-ec2 launch [flags]

Flags:
  -a, --auto-termination-timer int       The auto-termination timer for the instance in minutes
  -b, --boot-script string               The absolute filepath to a bash script passed to the instance and executed after the instance starts (user data)
      --capacity-type string             Launch instance as "On-Demand" (the default) or "Spot"
  -h, --help                             help for launch
  -p, --iam-instance-profile string      The profile containing an IAM role to attach to the instance
  -m, --image-id string                  The image id of the AMI used to launch the instance
  -t, --instance-type string             The instance type of the instance
  -i, --interactive                      Interactive mode
  -k, --keep-ebs                         Keep EBS volumes after instance termination
  -l, --launch-template-id string        The launch template id with which the instance will be launched
  -v, --launch-template-version string   The launch template version with which the instance will be launched
  -r, --region string                    The region where the instance will be launched
  -c, --save-config                      Save config as a JSON config file
  -g, --security-group-ids strings       The security groups with which the instance will be launched
  -s, --subnet-id string                 The subnet id in which the instance will be launched
      --tags stringToString              The tags applied to instances and volumes at launch (Example: tag1=val1,tag2=val2) (default [])

Single Command Launch

$ simple-ec2 launch

Please confirm if you would like to launch instance with following options:

       CONFIGURATION                        │ VALUE                                                
     ───────────────────────────────────────┼──────────────────────────────────────────────────────
       Region                               │ us-east-1                                            
       VPC                                  │ vpc-example                
       Subnet                               │ subnet-example          
       Instance Type                        │ t1.micro                                             
       Capacity Type                        │ On-Demand                                                 
       Image                                │ ami-047a51fa27710816e                                
       Security Group                       │ sg-example  
       Keep EBS Volume(s) After Termination │ false                                                
       Auto Termination Timer in Minutes    │ None                                                   
       EBS Volumes                          │ /dev/xvda(gp2): 8 GiB                                
                                                                                                   
   >   Yes  
       No   
Options confirmed! Launching instance...
Launch Instance Success!
Instance ID: i-123example

Single Command Launch With Flags

$ simple-ec2 launch -r us-east-2 -m ami-123example -t t2.micro -s subnet-123example -g sg-123example

Please confirm if you would like to launch instance with following options:

       CONFIGURATION                        │ VALUE                                                
     ───────────────────────────────────────┼──────────────────────────────────────────────────────
       Region                               │ us-east-2                                            
       VPC                                  │ vpc-example                
       Subnet                               │ subnet-123example          
       Instance Type                        │ t2.micro                                             
       Capacity Type                        │ On-Demand                                                 
       Image                                │ ami-123example
       Security Group                       │ sg-123example  
       Keep EBS Volume(s) After Termination │ false                                                
       Auto Termination Timer in Minutes    │ None                                                   
       EBS Volumes                          │ /dev/xvda(gp2): 8 GiB                                
                                                                                                   
   >   Yes  
       No   
Options confirmed! Launching instance...
Launch Instance Success!
Instance ID: i-123example

Interactive Mode Launch

$ simple-ec2 launch -i


Select a region for the instance:

       REGION         │ DESCRIPTION                
     ─────────────────┼────────────────────────────
       ap-northeast-1 │ Asia Pacific (Tokyo)       
       ap-northeast-2 │ Asia Pacific (Seoul)       
       ap-northeast-3 │ Asia Pacific (Osaka)       
       ap-south-1     │ Asia Pacific (Mumbai)      
       ap-southeast-1 │ Asia Pacific (Singapore)   
       ap-southeast-2 │ Asia Pacific (Sydney)      
       ca-central-1   │ Canada (Central)           
       eu-central-1   │ Europe (Frankfurt)         
       eu-north-1     │ Europe (Stockholm)         
       eu-west-1      │ Europe (Ireland)           
       eu-west-2      │ Europe (London)            
       eu-west-3      │ Europe (Paris)             
       sa-east-1      │ South America (Sao Paulo)  
       us-east-1      │ US East (N. Virginia)      
   >   us-east-2      │ US East (Ohio)             
       us-west-1      │ US West (N. California)    
       us-west-2      │ US West (Oregon)           

How do you want to choose the instance type?

       Enter the instance type                          
       Provide vCPUs and memory information for advice  
   >   Use the default instance type, [t3.micro]        

Select an AMI for the instance:

       OPERATING SYSTEM │ IMAGE ID              │ CREATION DATE             
     ───────────────────┼───────────────────────┼───────────────────────────
   >   Amazon Linux 2   │ ami-017a73c6475f1cefe │ 2022-07-22T22:59:04.000Z  
       Ubuntu           │ ami-0c1efade7e2a5a12e │ 2022-08-10T12:06:14.000Z  
       Amazon Linux     │ ami-02a1b876e6016a354 │ 2022-07-16T02:38:59.000Z  
       Red Hat          │ ami-078cbc4c2d057c244 │ 2022-05-13T11:53:05.000Z  
       SUSE Linux       │ ami-0535d9b70179f9734 │ 2022-07-23T07:01:55.000Z  
       Windows          │ ami-04d1c6a7290ee815a │ 2022-08-10T07:21:08.000Z  

Persist EBS Volume(s) after the instance is terminated?

       Yes  
   >   No   

After how many minutes should the instance terminate? (0 for no auto-termination)

   > 25 

Select the VPC for the instance:

       VPC                                            │ CIDR BLOCK     
     ─────────────────────────────────────────────────┼────────────────
   >   vpc-123example                                 │ 172.31.0.0/16  
       vpc-example                                    │ 172.31.0.0/16  
       Create new VPC with default CIDR and 3 subnets │                

Select the subnet for the instance:

       SUBNET            │ AVAILABILITY ZONE │ CIDR BLOCK      
     ────────────────────┼───────────────────┼─────────────────
   >   subnet-123example │ us-east-2a        │ 172.31.0.0/24   
       subnet-456example │ us-east-2b        │ 172.31.16.0/24  
       subnet-789example │ us-east-2c        │ 172.31.32.0/24  

Select the security groups for the instance:

           SECURITY GROUP                               │ DESCRIPTION                             
         ───────────────────────────────────────────────┼─────────────────────────────────────────
     [x]   sg-123example                                │ My Favorite Security Group
     [ ]   sg-456example                                │ default VPC security group              
     [ ]   Create a new security group that enables SSH │                                         
                                                                                                                            
         [ SUBMIT ]                                                                                                         

Select an IAM Profile:

       PROFILE NAME              │ PROFILE ID            │ CREATION DATE                  
     ────────────────────────────┼───────────────────────┼────────────────────────────────
       Instance-Profile-1        │ AIPAXP7DUN6CORG253IFG │ 2021-01-20 14:31:28 +0000 UTC  
       Instance-Profile-2        │ AIPAXP7DUN6CJLXGLI2M5 │ 2021-01-20 14:31:51 +0000 UTC  
   >   Do not attach IAM profile │                       │                                

Would you like to add a filepath to the instance boot script?

       Yes  
   >   No   

Would you like to add tags to instances and persisted volumes?

       Yes  
   >   No   

Select capacity type. Spot instances are available at up to a 90% discount compared to On-Demand instances,
but they may get interrupted by EC2 with a 2-minute warning

       CAPACITY TYPE │ PRICE       
     ────────────────┼─────────────
   >   On-Demand     │ $0.0104/hr  
       Spot          │ $0.0031/hr  

Please confirm if you would like to launch instance with following options:
(Or select a configuration to repeat a question)

       CONFIGURATION                        │ VALUE                                                
     ───────────────────────────────────────┼──────────────────────────────────────────────────────
       Region                               │ us-east-2                                            
       VPC                                  │ vpc-123example                
       Subnet                               │ subnet-123example          
       Instance Type                        │ t3.micro                                             
       Capacity Type                        │ On-Demand                                            
       Image                                │ ami-017a73c6475f1cefe                                
       Security Group                       │ sg-123example  
       Keep EBS Volume(s) After Termination │ false                                                
       Auto Termination Timer in Minutes    │ 25                                                   
       EBS Volumes                          │ /dev/xvda(gp2): 8 GiB                                
                                                                                                   
   >   Yes  
       No   
Options confirmed! Launching instance...
Launch Instance Success!
Instance ID: i-123example

Do you want to save the configuration above as a JSON file that can be used in non-interactive mode and as question defaults

   >   Yes  
       No   
Saving config...
Config successfully saved: /Users/${USER}/.simple-ec2/simple-ec2.json

Connect

All CLI Options

$ simple-ec2 connect -h
Connect to an Amazon EC2 Instance, given the region and instance id

Usage:
  simple-ec2 connect [flags]

Flags:
  -h, --help                 help for connect
  -n, --instance-id string   The instance id of the instance you want to connect to
  -i, --interactive          Interactive mode
  -r, --region string        The region in which the instance you want to connect locates

Single Command Connect

$ simple-ec2 connect -r us-east-2 -n i-123example
Last login: Wed Jul 29 21:01:45 2020 from 52.95.4.1

       __|  __|_  )
       _|  (     /   Amazon Linux 2 AMI
      ___|\___|___|

https://aws.amazon.com/amazon-linux-2/
14 package(s) needed for security, out of 31 available
Run "sudo yum update" to apply all updates.
[ec2-user@ip-example ~]$ exit
logout

Interactive Mode Connect

$ simple-ec2 connect -i

Select a region for the instance:

       REGION         │ DESCRIPTION                
     ─────────────────┼────────────────────────────
       ap-northeast-1 │ Asia Pacific (Tokyo)       
       ap-northeast-2 │ Asia Pacific (Seoul)       
       ap-northeast-3 │ Asia Pacific (Osaka)       
       ap-south-1     │ Asia Pacific (Mumbai)      
       ap-southeast-1 │ Asia Pacific (Singapore)   
       ap-southeast-2 │ Asia Pacific (Sydney)      
       ca-central-1   │ Canada (Central)           
       eu-central-1   │ Europe (Frankfurt)         
       eu-north-1     │ Europe (Stockholm)         
       eu-west-1      │ Europe (Ireland)           
       eu-west-2      │ Europe (London)            
       eu-west-3      │ Europe (Paris)             
       sa-east-1      │ South America (Sao Paulo)  
       us-east-1      │ US East (N. Virginia)      
   >   us-east-2      │ US East (Ohio)             
       us-west-1      │ US West (N. California)    
       us-west-2      │ US West (Oregon)           

Select the instance you want to connect to: 

       INSTANCE            │ TAG-KEY                       │ TAG-VALUE                                   
     ──────────────────────┼───────────────────────────────┼─────────────────────────────────────────────
   >   i-123example        │ CreatedBy                     │ simple-ec2                                  
                           │ CreatedTime                   │ 2022-08-19 14:04:08 CDT                     
       i-456example        │ CreatedBy                     │ simple-ec2                                  
                           │ CreatedTime                   │ 2022-08-19 13:58:33 CDT                     

       __|  __|_  )
       _|  (     /   Amazon Linux 2 AMI
      ___|\___|___|

https://aws.amazon.com/amazon-linux-2/
14 package(s) needed for security, out of 31 available
Run "sudo yum update" to apply all updates.
[ec2-user@ip-example ~]$ exit
logout

Terminate

All CLI Options

$ simple-ec2 terminate -h
Terminate Amazon EC2 Instances, given the region and instance ids or tag values

Usage:
  simple-ec2 terminate [flags]

Flags:
  -h, --help                   help for terminate
  -n, --instance-ids strings   The instance ids of the instances you want to terminate
  -i, --interactive            Interactive mode
  -r, --region string          The region in which the instances you want to terminate locates
        --tags stringToString    Terminate instances containing EXACT tag key-pair (Example: CreatedBy=simple-ec2) (default [])

One Command Terminate

$ simple-ec2 terminate -r us-east-2 -n i-123example
Terminating instances
Instances [i-123example] terminated successfully

One Command Terminate using tags

$ simple-ec2 terminate -r us-east-1 --tags CreatedBy=simple-ec2
Terminating instances
Instances [i-123example i-456example] terminated successfully

Interactive Terminate

$ simple-ec2 terminate -i
Select a region for the instance:

       REGION         │ DESCRIPTION                
     ─────────────────┼────────────────────────────
       ap-northeast-1 │ Asia Pacific (Tokyo)       
       ap-northeast-2 │ Asia Pacific (Seoul)       
       ap-northeast-3 │ Asia Pacific (Osaka)       
       ap-south-1     │ Asia Pacific (Mumbai)      
       ap-southeast-1 │ Asia Pacific (Singapore)   
       ap-southeast-2 │ Asia Pacific (Sydney)      
       ca-central-1   │ Canada (Central)           
       eu-central-1   │ Europe (Frankfurt)         
       eu-north-1     │ Europe (Stockholm)         
       eu-west-1      │ Europe (Ireland)           
       eu-west-2      │ Europe (London)            
       eu-west-3      │ Europe (Paris)             
       sa-east-1      │ South America (Sao Paulo)  
       us-east-1      │ US East (N. Virginia)      
   >   us-east-2      │ US East (Ohio)             
       us-west-1      │ US West (N. California)    
       us-west-2      │ US West (Oregon)           

Select the instances you want to terminate: 

           INSTANCE            │ TAG-KEY                       │ TAG-VALUE                                   
         ──────────────────────┼───────────────────────────────┼─────────────────────────────────────────────
     [x]   i-123example        │ CreatedBy                     │ simple-ec2                                  
                               │ CreatedTime                   │ 2022-08-19 14:05:29 CDT                     
     [x]   i-456example        │ CreatedTime                   │ 2022-08-19 14:18:10 CDT                     
                               │ CreatedBy                     │ simple-ec2                                  
                                                                                                             
         [ SUBMIT ]                                                                                          

Are you sure you want to terminate 2 instance(s): [i-123example i-456example] 

   >   Yes  
       No   
Terminating instances
Instances [i-123example i-456example] terminated successfully

Building

For build instructions please consult BUILD.md.

Communication

If you've run into a bug or have a new feature request, please open an issue.

Contributing

Contributions are welcome! Please read our guidelines and our Code of Conduct

License

This project is licensed under the Apache-2.0 License.

aws-simple-ec2-cli's People

Contributors

amazon-auto avatar brycahta avatar bwagner5 avatar dependabot[bot] avatar gavinburris42 avatar haugenj avatar icarthick avatar imuqtadir avatar likithavemulapalli avatar pdk27 avatar snay2 avatar zyyhhxx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

aws-simple-ec2-cli's Issues

CLI should have an inbuilt way to display its version number

Describe the feature
Currently there is no command to display the version number of the simple-ec2 executable. This makes it harder for users and maintainers working on bug reports to identify which version of the software is affected by the report.

Is the feature request related to a problem?
This does not affect the functioning of the software, it's merely a convenience for users and maintainers.

Describe alternatives you've considered
If the user installed through homebrew, they can run brew info aws-simple-ec2-cli to get the version number. If they built from source, they can inspect the "Install w/ Curl" section of README.md. If they installed via Curl, I'm not sure how to find the version number.

manually specify key pair name when launching ec2?

Describe the feature
I want to specify a key pair name when launching an instance so that I can connect to the instance via SSH. I need to use SSH because I want to use SSH Agent Forwarding and SSH Tunnels which are not supported by simple-ec2 connect.

Is the feature request related to a problem?
I saw there's a PEM file in the ~/simple-ec2 folder but I can't use it to SSH like: ssh -i ~/.simple-ec2/instance_connect.pem [email protected].

Describe alternatives you've considered
I could just make the EC2 on the AWS Console but what's the fun in that :)

Default options change for simple-ec2 config

Describe the feature
A concise description of the feature and desired behavior.
When using the interactive mode for simple-ec2 launch the defaults for each question are static and defined by pre-set values. These default values should instead be the defaults set in the simple-ec2.json file that are used to set the defaults in the non interactive mode.

Is the feature request related to a problem?
A description of what the problem is. For example: I'm frustrated when [...]
When using interactive mode I would want to change one or two configurations. Having the defaults represent the user set configurations will make it so they don't have to re-insert them. They can just hit enter instead of having to retype everything.

Describe alternatives you've considered
A description of any alternative solutions or features you've considered.
The flags can be used instead to skip these steps, but this also involves typing out already set defaults.

Invalid interactive input proceeds with defaults

Describe the bug
The user is allowed to enter invalid input and proceed (unknowingly until end summary) with defaults when using simple-ec2 in interactive mode.

Steps to reproduce

  • Start simple-ec2 launch in interactive mode
  • When asked to provide an input, enter invalid input
  • Hit enter until pre-launch summary
  • Note the default value where you entered invalid input

Expected outcome
After entering invalid input, the app should re-prompt:

Instance Type (eg. m5.xlarge, c5.xlarge) [t1.micro]:  meep
Input invalid. Please try again.
Instance Type (eg. m5.xlarge, c5.xlarge) [t1.micro]:

If user hits enter, it will proceed with default as expected OR they enter valid input OR enter invalid input and repeat loop.

Application Logs


+--------+-----------------------------------------------+----------------+
| OPTION |                LAUNCH TEMPLATE                | LATEST VERSION |
+--------+-----------------------------------------------+----------------+
| 1.     | Test_w_spot(lt-0df2e6bd72274f663)             | 1              |
+--------+-----------------------------------------------+----------------+
| 2.     | simple-lt-used-by-fleet(lt-002cf32cc66212864) | 1              |
+--------+-----------------------------------------------+----------------+
| 3.     | test-no-spot(lt-0abdca811f31d268f)            | 1              |
+--------+-----------------------------------------------+----------------+
| 4.     | Do not use launch template                    |
+--------+-----------------------------------------------+----------------+
Launch Template [Do not use launch template]:

1. I will enter the instance type
2. I need advice given vCPUs and memory
Instance Select Method [t1.micro]:  1

Instance Type (eg. m5.xlarge, c5.xlarge) [t1.micro]:  meep
Input invalid. Please try again.


+--------+------------------+-----------------------+--------------------------+
| OPTION | OPERATING SYSTEM |       IMAGE ID        |      CREATION DATE       |
+--------+------------------+-----------------------+--------------------------+
| 1.     | Amazon Linux 2   | ami-00af37d1144686454 | 2022-04-28T21:39:48.000Z |
+--------+------------------+-----------------------+--------------------------+
| 2.     | Ubuntu           | ami-0e8e7369d92f16d0a | 2022-05-06T19:22:40.000Z |
+--------+------------------+-----------------------+--------------------------+
| 3.     | Amazon Linux     | ami-01eef5991d5b0b06c | 2022-05-04T21:38:21.000Z |
+--------+------------------+-----------------------+--------------------------+
| 4.     | Red Hat          | ami-04a616933df665b44 | 2022-05-13T11:43:00.000Z |
+--------+------------------+-----------------------+--------------------------+
| 5.     | SUSE Linux       | ami-02d3156c437db95c5 | 2022-04-27T09:34:54.000Z |
+--------+------------------+-----------------------+--------------------------+
| 6.     | Windows          | ami-00a1fa460823055a5 | 2022-05-11T06:38:40.000Z |
+--------+------------------+-----------------------+--------------------------+
[ any image id ]: Select the image id
AMI [Latest Amazon Linux 2 image]:  merp
Input invalid. Please try again.

Environment

  • Austin, TX ; muggy
  • App Version: ALL
  • OS/Arch: ALL

Revamp the UX to use Bubble Tea

Describe the feature

The current UX for Simple-EC2 lacks some features that a Terminal User Interface (TUI) library like Bubble Tea would afford. Let's rewrite the interactive questionnaire to use Bubble Tea, and improve some of the questions where possible.

Is the feature request related to a problem?

The default value for any given list is shown in square brackets next to the prompt. The user has to read the table, read the default, and then evaluate whether that's the value they want. We could instead write these tables with a scrollable list that positions the cursor on the default when first rendered, making it very clear which option the user will get if they just hit enter and take the default.

Selecting security groups is particularly difficult in the current implementation. The user is presented with the list of available security groups multiple times and asked to select an additional one or say they're done adding groups. This would be much easier with a multi-select list.

Terminating multiple instances also has this issue and would be better with a multi-select list.

Entering tags for an instance requires the user to type a very specific syntax (tag|value,tag|value), which is easy to mess up. We could write a more intuitive interface for this that clearly outlines the "key" and "value" inputs and shows a table for tags already added to the instance. The table could also allow us to delete existing tags.

Describe alternatives you've considered

The existing UX is fine and it works, but this would be a usability improvement.

Request Spot instance

Describe the feature
I'd like to request a Spot instance using simple-ec2 cli

Is the feature request related to a problem?
N/A

Describe alternatives you've considered
Using on-demand instance and not saving up to 90%

Ability to launch accelerated compute instances

Describe the feature
Not sure if it's a bug, but I'm unable to launch g5 family instances.
Is the feature request related to a problem?
When launching a g5.2xlarge, I get:

Creating spot instance failed: AMI 'ami-x' with an instance-store root device is not supported for the instance type 'g5.2xlarge'.

I've tried with both Ubuntu and Amazon Linux AMIs.

Auto-terminate doesn't work on Windows instances

Describe the bug
simple-ec2 offers a feature to auto-terminate an instance you launch a certain number of minutes after its creation. This is nice for testing where you only need an instance for a short amount of time, since you don't have to worry about cleanup.

However, this mechanism only works on Linux instances, not Windows instances.

Steps to reproduce:

  1. Run simple-ec2 launch -i
  2. Use any values you like but specify the following:
    1. Windows AMI
    2. Auto-terminate timer of some short duration (e.g., 15 minutes)
  3. Launch the instance, wait a few minutes, and verify that the instance is running (it will show up in the AWS Console or in the list in simple-ec2 connect -i
  4. Wait 15 minutes

Result: The Windows instance is still running and it did not terminate

Expected outcome:

The Windows instance should terminate after the set time. If this is not possible, simple-ec2 should not give the user that option when selecting a Windows AMI.

This mechanism is implemented with a "shut down in the future" command in the userdata script, but that command is specific to Linux. It may be possible to do this in Windows with the following PowerShell command:

shutdown -s -t <TimeInSeconds>

Workaround:

Manually terminate the instance with simple-ec2 terminate or via the AWS Console

Environment

  • App Version: 0.6.0
  • OS/Arch: MacOS 12.2 Intel

Creating Multiple SSH Security Groups

Describe the bug
A concise description of what the bug is.
When given options to create security groups in the simple-ec2 CLI tool, the user is given the option to create a new security group that enables SSH. However, if they have already created a security group that enables SSH simple-ec2 will return an error as the security groups GroupName field is hardcoded, instead of having a unique value.

Steps to reproduce
A step-by-step description on how to reproduce the problem.

  1. Use interactive mode on simple-ec2.
  2. In the security group selection step, choose the option to create a new security group that enables SSH.
  3. If this was the first time selecting the "create a new security group that enables SSH" option, then repeat steps 1 and 2.

Expected outcome
A concise description of what you expected to happen.
One of the following:

  1. Multiple SSH security groups can be created
  2. Only one SSH security group can be created, and the option to create more is removed

Application Logs
The log output when experiencing the issue.
Creating new security group for SSH failed: InvalidGroup.Duplicate: The security group 'simple-ec2 SSH' already exists for VPC 'vpc-07a5eb4bd9c8f9fcd' status code: 400, request id: 92971c58-1945-4afb-b92c-3347de5c175a

Environment
Simple-EC2 using Mac terminal

  • App Version:
  • OS/Arch:

Can't supply an AMI ID in the interactive interface

Describe the bug
Supplying my own AMI ID directly via flags works fine, but trying to supply one via the interactive interface fails.

Steps to reproduce

  1. Run simple-ec2 launch -i
  2. Follow all the prompts but select an ARM instance type, such as t4g.micro (This might not be necessary, but the AMI ID I'm using is ARM64)
  3. When you get to the AMI selection screen, paste in ami-088e1f338c3b87d1a

Result: simple-ec2 crashes.

Expected outcome
simple-ec2 should accept that AMI ID and continue on

Workaround:

Supplying the AMI ID directly on the command line works fine, such as

simple-ec2 launch -t t4g.micro -m ami-088e1f338c3b87d1a ...

Environment

  • App Version: 0.6.0
  • OS/Arch: MacOS 12.2 Intel

Tags incorrect for Spot instance

Describe the bug
(h/t @AustinSiu for finding this)

The Spot code does not properly set tags on the instance. I imagine this has something to do with using launch templates or CreateFleet API, rather than RunInstances like our On-Demand code path uses.

The spot support feature is on main but has not yet been released: #55. We should fix this before release.

Steps to reproduce
I used simple-ec2 launch -i to launch two instances with the same specs, one On-Demand and one Spot, and I set a tag myTag=myTagValue on both:

+--------------------------------------+-----------------------------------------------------+
| Region                               | us-east-2                                           |
| VPC                                  | simple-ec2 VPC(vpc-0646e30a60e5cfbee)               |
| Subnet                               | simple-ec2 Subnet(subnet-03f49777a68f0e0bc)         |
| Instance Type                        | t2.micro                                            |
| Capacity Type                        | On-Demand                                           |
| Image                                | ami-017a73c6475f1cefe                               |
| Security Group                       | simple-ec2 SSH Security Group(sg-0140d6773625eedd8) |
| Keep EBS Volume(s) After Termination | false                                               |
| Auto Termination Timer in Minutes    | 30                                                  |
| EBS Volumes                          | /dev/xvda(gp2): 8 GiB                               |
| Tag Specification(key|value)         | myTag|myTagValue                                    |
+--------------------------------------+-----------------------------------------------------+

+--------------------------------------+-----------------------------------------------------+
| Region                               | us-east-2                                           |
| VPC                                  | simple-ec2 VPC(vpc-0646e30a60e5cfbee)               |
| Subnet                               | simple-ec2 Subnet(subnet-03f49777a68f0e0bc)         |
| Instance Type                        | t2.micro                                            |
| Capacity Type                        | Spot                                                |
| Image                                | ami-017a73c6475f1cefe                               |
| Security Group                       | simple-ec2 SSH Security Group(sg-0140d6773625eedd8) |
| Keep EBS Volume(s) After Termination | false                                               |
| Auto Termination Timer in Minutes    | 30                                                  |
| EBS Volumes                          | /dev/xvda(gp2): 8 GiB                               |
| Tag Specification(key|value)         | myTag|myTagValue                                    |
+--------------------------------------+-----------------------------------------------------+

Expected outcome
When I run simple-ec2 connect -i, you can see the tags for each instance. The first one in this list is the Spot instance, and you'll notice the lack of tags CreatedBy and CreatedTime (added automatically by Simple-EC2) and myTag (requested by me).

+--------+---------------------+-------------------------------+--------------------------------------------+
| OPTION |      INSTANCE       |            TAG-KEY            |                 TAG-VALUE                  |
+--------+---------------------+-------------------------------+--------------------------------------------+
| 1.     | i-0787ce0ef3ad5a97a | aws:ec2launchtemplate:id      | lt-05a49f8daa6e98b80                       |
|        |                     | aws:ec2:fleet-id              | fleet-9f3feb84-5326-ecbe-aeba-858ad9094622 |
|        |                     | aws:ec2launchtemplate:version | 1                                          |
| 2.     | i-0c944fe3155bc43fe | myTag                         | myTagValue                                 |
|        |                     | CreatedBy                     | simple-ec2                                 |
|        |                     | CreatedTime                   | 2022-08-03 09:44:51 CDT                    |
+--------+---------------------+-------------------------------+--------------------------------------------+

The tags for a Spot instance should match those for an On-Demand instance.

Application Logs
See output above.

Environment

  • App Version: v0.8.2-2-g20ee196
  • OS/Arch: macOS 12.4

Connecting to an Ubuntu instance fails

Describe the bug
When using simple-ec2 connect to log in to an EC2 instance using an AMI that is not a flavor of Amazon Linux, user encounters an SSH error "Permission denied (publickey)". This is because our EC2 Instance Connect helper code hardcodes the username of ec2-user, which is not correct for Ubuntu. The username in that case should be ubuntu. Red Hat and SUSE instances also fail to connect, but I'm not sure if they are because of the username or something else.

Steps to reproduce

  1. Launch an instance with any configuration and an Ubuntu AMI, using simple-ec2 launch
  2. Attempt to connect to that instance with simple-ec2 connect

Expected outcome
simple-ec2 connect should open an SSH connection and present the user with a shell to the instance. These steps work correctly for instances based on an Amazon Linux AMI.

Application Logs

Connecting to instance failed: exit status 255Warning: Permanently added 'ec2-3-143-5-51.us-east-2.compute.amazonaws.com' (ED25519) to the list of known hosts.
[email protected]: Permission denied (publickey).

Environment

  • App Version: 0.8.2
  • OS/Arch: macOS 12.4

Update the default operating system images

Describe the feature
simple-ec2 suggests AMIs for several different operating system types (Amazon Linux, Windows, Ubuntu, etc.). Some of these may be outdated now. One particular example is Ubuntu: we are using 18.04 LTS, but there is a more recent long-term support version: 20.04. We should use that instead, and see if any of the other operating system versions ought to be bumped up as well.

(Or if wait for another month or two, we can upgrade directly to Ubuntu 22.04 LTS, which should be released in April 2022.)

Is the feature request related to a problem?
Using more recent OS versions will give users the latest features and security fixes. The biggest advantage is that the software repos (available via apt, yum, etc.) will have more recent versions of software users are likely to want to install once they get their instance.

Describe alternatives you've considered
Users can manually supply an AMI they prefer.

Upgrade ubuntu image to the latest LTS

Describe the feature

"instance-store": "ubuntu/images/hvm-instance/ubuntu-bionic-18.04-*-server-????????",

If you see above, ubuntu version being used is 18.04. It would be great if this can be upgraded to the latest LTS release viz 22.04

If 22.04 cannot be default i would be a great UX to show a list where the user can choose which is the version of ubuntu they want

Feature request: stop & restart an instance

This is a great CLI tool - and it could be even better if it also supported

  • stopping a running EC2 instance
  • restarting a stopped EC2 instance

Many thanks for making AWS better every day!

`CreatedTime` date formatting doesn't conform to ISO 8601

Describe the bug
When launching an instance via simple-ec2 launch, one of the tags on the instance is CreatedTime. This tag has a date that lacks leading zeros for single-digit months and dates. It would look better if we formatted the date in ISO 8601 (YYYY-MM-DD).

Steps to reproduce
Launch an instance using any options in simple-ec2 launch. Then, run simple-ec2 connect -i to get the list of instances in interactive mode. Sample output shows the date format:

+--------+---------------------+-------------+-----------------------+
| OPTION |      INSTANCE       |   TAG-KEY   |       TAG-VALUE       |
+--------+---------------------+-------------+-----------------------+
| 1.     | i-01b40315751cf876e | CreatedBy   | simple-ec2            |
|        |                     | CreatedTime | 2022-4-6 13:55:24 CDT |
+--------+---------------------+-------------+-----------------------+
Select the instance you want to connect to: :

Expected outcome
The date should be formatted as 2022-04-06. Not sure if the time formatting has the same issue, but it's worth checking too.

Application Logs
N/A

Environment

  • App Version: 0.8.0
  • OS/Arch: MacOS 12.3, amd64

No way to specify capacity type with CLI flag

Describe the bug
The Simple-EC2 CLI has flags for all attributes of an instance. However, when we added Spot support recently (#55), we did not include a CLI flag to choose between Spot and On-Demand. The only way to choose capacity type is through interactive mode.

Steps to reproduce
simple-ec2 launch -h does not list an option for specifying capacity type.

Expected outcome
We should add a new flag to set this attribute from the CLI, perhaps called --capacity-type. It should accept case-insensitive values of "spot" or "on-demand" and have appropriate parsing and error handling logic.

Application Logs
N/A

Environment

  • App Version: v0.8.2-2-g20ee196
  • OS/Arch: macOS 12.4

Support authentication with AWS SSO

I am using AWS SSO with temporary credentials, and need to switch between different roles. Perhaps that's worth supporting, e.g. via a --profile argument?

Incorrect region applied when interactive mode is used.

Describe the bug
When launching via interactive mode, if the "eu-west-1" region is selected, the proceeding steps create resources in the eu-central-2 region, which is not included in the orginal list selection in the first place (probably as it is an opt-in region)

Steps to reproduce
Quick launch an instance with -i flag

Expected outcome
Would expect eu-west-1 region to apply when selected

Application Logs
see image
Screenshot 2023-07-03 at 17 35 57

Environment
zsh iterm2 shell

  • App Version: 0.10.0
  • OS/Arch: zsh, MacOS Monterrey 12.6.6
    zsh, MacOS Monterrey 12.6.6

Offer an easy way to launch ARM64 instances in interactive mode

Describe the feature
As ARM64-based instances become more popular, developers may want to launch such instances with simple-ec2. The default instance type and all the suggested AMIs are AMD64-based. So while it is possible to to launch an ARM64 instance in interactive mode, there is not an easy default configuration, and it has some sharp edges (e.g., see this issue).

It would be nice if the interactive CLI gave a suggestion for an ARM64 instance type as well as an AMD64 instance type, even if AMD64 remains the default.

It would also be nice if, after the user selects and ARM64 instance type, the AMI sugggestions include only AMIs that will actually run on that instance type.

Is the feature request related to a problem?
This is a developer pain point, even though it's not a bug per se.

Describe alternatives you've considered
If you already know the instance type and AMI ID you want, you can theoretically launch ARM64 instances with either interactive mode or command-line flags.

ssh connection should use "IdentitiesOnly yes" option

In some circumstances if your ssh-agent has a lot of keys, connecting fails e.g.:

Select the instance you want to connect to:

       INSTANCE                                │ TAG-KEY │ TAG-VALUE
     ──────────────────────────────────────────┼─────────┼────────────
   >   rt-dockertest12343(i-06ab0e3ff8715cad5) │         │
Connecting to instance failed: exit status 255Received disconnect from 34.236.152.159 port 22:2: Too many authentication failures
Disconnected from 34.236.152.159 port 22

A similar thing happens when trying to use the normal cli ssh command.

This issue is solved on the ssh command line with -o "IdentitiesOnly yes"; it would be good for this to also pass that option.

Output software version?

I installed simple-ec2 on my Mac via homebrew, following the instructions on the README.md page. The version I got didn't support the --tags argument of the simple-ec2 launch command.

When I re-installed the latest release from github

curl -Lo simple-ec2 https://github.com/awslabs/aws-simple-ec2-cli/releases/download/v0.7.0/simple-ec2-`uname | tr '[:upper:]' '[:lower:]'`-amd64
chmod +x simple-ec2

I got a later (?) version of the CLI that knew about the --tags argument.

Perhaps it would be useful to output the version of the installed CLI (e.g. via a --version / -v argument), so users can see quickly whether have the latest version installed?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.