-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added functionality for AWS SSM #40
Conversation
I noticed that the existing application had nearly everything needed to do SSM sessions. I have modified the application to allow the ability to use your existing profiles and connect via SSM.
My team wants to start using SSM and we use your package pretty extensively. I made a few tweaks and I was able to get it to work with Session Manager. |
ENV_SSH_USER, | ||
ENV_TUNNEL_SSH_USER, | ||
ENV_TUNNEL_KEY_PATH, | ||
AWS_REGIONS, | ||
AWS_DEFAULT_PROFILE, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Had to pull in the default profile from the environment variable so that you could change it needed.
@@ -64,7 +68,7 @@ def entrypoint(use_private_ip, key_path, user, ip_only, no_cache, tunnel, tunnel | |||
} | |||
cache.close() | |||
except Exception as e: | |||
print('Exception occured while getting cache, getting instances from AWS api: %s' % e) | |||
print('Exception occurred while getting cache, getting instances from AWS api: %s' % e) | |||
if cache: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed a typo there
user=ENV_TUNNEL_SSH_USER or tunnel_user, | ||
key=ENV_TUNNEL_KEY_PATH or tunnel_key_path, | ||
host=choice(fuzzysearch_bash_command), | ||
if use_ssm or ENV_USE_SSM: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a conditional branch to just incorporate all the ssh vs ssm logic in one area
@@ -126,7 +139,11 @@ def choice(fuzzysearch_bash_command): | |||
except subprocess.CalledProcessError: | |||
exit(1) | |||
|
|||
return choice.split(SEPARATOR)[1].rstrip() | |||
if use_ssm: | |||
output = choice.split(' ')[1].replace('(', '').replace(')', '').rstrip() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of stripping out the IP address, I have it pulling the instance id from the string.
ENV_USE_PUBLIC_DNS_OVER_IP = os.getenv('AWS_FUZZ_DNS_OVER_IP', False) # use public DNS over IP (both public or private) | ||
ENV_TUNNEL_SSH_USER = os.getenv('AWS_FUZZ_TUNNEL_USER') | ||
ENV_TUNNEL_KEY_PATH = os.getenv('AWS_FUZZ_TUNNEL_KEY_PATH') | ||
ENV_SSH_COMMAND_TEMPLATE = os.getenv('AWS_FUZZ_SSH_COMMAND_TEMPLATE', "ssh {key} {user}{host}") | ||
ENV_SSM_COMMAND_TEMPLATE = os.getenv('AWS_FUZZ_SSM_COMMAND_TEMPLATE', "aws ssm start-session --profile {profile} --target {target}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just needed a different kind of template for find and replace.
Great work, thank you! This is definitely getting merged, I'll soon bump the version and release it to pip. |
I'm very excited to see this come out. Do you have an idea of what the ETA looks like? We're going to start using it immediately. Thanks again! |
@jwhaley-togetherwork I'll try to release to pip tomorrow, I'll @ you when it's out. |
That’s so exciting! Thanks !
…On Mon, Feb 22, 2021 at 7:13 PM Piotr Mazurek ***@***.***> wrote:
@jwhaley-togetherwork <https://github.com/jwhaley-togetherwork> I'll try
to release to pip tomorrow, I'll @ you when it's out.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#40 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAEE74RB4POMJBRYUGISU5TTALXJNANCNFSM4XTW767Q>
.
|
@jwhaley-togetherwork fyi I just released v1.1.1 to pip, thanks for your contribution! :) |
I noticed that the existing application had nearly everything needed to do SSM sessions. I have modified the application to allow the ability to use your existing profiles and connect via SSM.