-
Notifications
You must be signed in to change notification settings - Fork 2
EC2
All EC2 related actions support alternate profile and region. You could either configure them
through the fzfaws.yml config file or you could pass in command line options. The command line
option takes higher precedence and will override the config file settings.
fzfaws ec2 start --profileConfigure fzfaws.yml to set default profile and region for all EC2 actions, this will override
the global settings of profile and region. In the example below, the default profile and us-east-1 will
be used for all other services, but EC2 service will use the rootprofile profile and ap-southeast-2
by default.
global:
profile: default
region: us-east-1
services:
ec2:
keypair: ~/.ssh
profile: rootprofile
region: ap-southeast-2Reference individual option flag through the help manual fzfaws ec2 ssh -h.
The connection to all instances uses fall back, Public DNS -> Public IP -> Private IP.
Before running any commands below, make sure that you have followed the instructions
here
to inform fzfaws where your keypair/pem keys are located.
Alternatively, you could specify the path to the key.
fzfaws ec2 ssh --path ~/.ssh/keypair.pemWithout any arguments:
- Select an instance
- You will be connected to the instnace using the user
ec2-user
fzfaws ec2 sshChange the default user, maybe when connecting to an ubuntu machine.
fzfaws ec2 ssh --user ubuntuLet's say in your aws environment, most machine is ubuntu, you could configure the fzfaws.yml
config file to always have the --user ubuntu flag, and yet you could still override this setting using --user flag
if you want to switch to different user.
services:
ec2:
keypair: ~/.ssh
default_args:
ssh: --user ubuntufzfaws support 2 forms of tunnelling. Under the hood, both are using the ssh -A flag
to enable the ssh key forwarding. Hence before attempting to run any of it, make sure to add
the key to ssh-agent.
ssh-add -K [Your key path]Just like ssh, you could give fzfaws the -A flag to enable the key forwarding
and then you can manually connect to other instance.
fzfaws ec2 ssh -AUsing the -t or --tunnel flag will enable you select 2 instance. The first one
being the jump box and the second one being the destination instance. You could
specify an optional user name to connect to the second instance.
The connection to the second instance uses fall back, DNS -> public IP -> private IP.
# connect to the first instance using the user name cloud_user and the destination using ubuntu.
fzfaws ec2 ssh --user cloud_user --tunnel ubuntuIn the demo, the "default-ubuntu" only accepts connection through the security group associated with "default-general" machine, we cannot directly connect to the ubuntu machine.

Reference individual option flag through the help manual fzfaws ec2 start -h.
Without any arguments:
- Select instances (support multi selection)
- Selected instance will be started
fzfaws ec2 startYou could wait for EC2 start operation to complete, checkout #waiting-for-ec2-operation-to-complete.

Reference individual option flag through the help manual fzfaws ec2 stop -h.
Without any arguments:
- Select instances (support multi selection)
- Selected instance will be stopped
fzfaws ec2 stopIf the instance support hibernate. Note: don't add --hibernate for no reason, fzfaws
can't detect --hibernate failure.
fzfaws ec2 stop --hibernateYou could wait for EC2 stop operation to complete, checkout #waiting-for-ec2-operation-to-complete.
Reference individual option flag through the help manual fzfaws ec2 terminate -h.
Without any arguments:
- Select instances (support multi selection)
- Selected instance will be terminated
fzfaws ec2 terminateYou could wait for EC2 terminate operation to complete, checkout #waiting-for-ec2-operation-to-complete.
Reference individual option flag through the help manual fzfaws ec2 reboot -h.
Without any arguments:
- Select instances (support multi selection)
- Selected instance will be rebooted
fzfaws ec2 rebootCheckout the dedicated section
for extending fzfaws functionalities which explains how and why for the ls commands.
The ls command will just print out information without doing any actions.
Consult the help manual to see the available options.
fzfaws ec2 ls --helpThe wait behaviour is configured through fzfaws.yml waiter section, consult the default config file's comment for more details.
In most EC2 related operations, you can apply --wait flag to wait for the operation
to complete before exiting fzfaws.
fzfaws ec2 start --waitIt is recommended to set --wait as the default args in the config file so you don't need to explicitly specify it, you can always stop the wait be hitting ctrl-c.
services:
ec2:
keypair: ~/.ssh
waiter:
delay: 10
max_attempts: 60
default_args:
start: --wait
stop: --wait
terminate: --wait