I needed a tool to utilise the ~/.aws/config
file to launch a session via AWS Systems Manager
to an instance in the cloud.
Written in Go, this tool allows you to launch the aws cli ssm components.
if you do not set an environment variable for the AWS_PROFILE
it will interrogate the ones found in ~/.aws/config
and provide you a list to pick from before .
Once the profile is set, it will get a list of the EC2 instances.
usage:
AWS_PROFILE=<profile_name> gossm
[1] i-AAAAAAAAAAAAAAAAA svr1.example.com (1)
[2] i-BBBBBBBBBBBBBBBBBB svr2.example.com
[3] i-CCCCCCCCCCCCCCCCCC svr3.example.com
Launch number:> 2 (2)
-
The list of instances to pick from.
-
The command prompt to enter the number representing the list above.
Once you select the instance, it will launch the session via the command line application, in the following way : aws --profile <AWS_PROFILE> ssm start-session --target <i-BBBBBBBBBBBBBBBBBB>
You can further filter the list by specifying tag values, that will eb checked.
eg gossm prd web
will look for machines tagged with both prd
and web
and present you a list of instances.
Note
|
It does not check that the SSM agent is running on these instances. |
Not really in scope for this tool, but I have a list of AWS profiles in ~/.aws/config
and the connection credentials are stored in ~/.aws/credentials
see AWS Documentation for more information on the ~/.aws/*
files.
[profile SAMPLE-PROFILE] (1)
region = ap-southeast-2 (2)
role_arn = arn:aws:iam::1234567890:role/FullAWSAccess (3)
source_profile = sample-admin-account (4)
-
Name of the profile, used by
gossm
. -
The region to use for the profile.
-
The role to use for the profile. This is the role in the account you want to utilise.
-
The account from the
~/.aws/credentials
you want to use.
[sample-admin-account] (1)
aws_access_key_id = ABCD... (2)
aws_secret_access_key = ABCD... (3)
-
the name you specify for the config, also used for the connection, eg
gossm sample-admin-acount
-
access key from AWS
-
the secre from AWS
To grab the latest build from github, run the following command.
go install github.com/bovinemagnet/gossm@latest
This will install the latest built version.
Important
|
Pressing ctrl-Z will suspend the gossm process not the process on the remote |
On arch linux, I ran the following: