def proxy_command(command, command_args, credentials):
# Unset variables for sanity sake
os.unsetenv('AWS_DEFAULT_PROFILE')
os.unsetenv('AWS_PROFILE')
os.unsetenv('AWS_ACCESS_KEY_ID')
os.unsetenv('AWS_SECRET_ACCESS_KEY')
os.unsetenv('AWS_SESSION_TOKEN')
os.unsetenv('AWS_SECURITY_TOKEN')
# Set AWS/Boto environemnt variables before executing target command
os.putenv('AWS_ACCESS_KEY_ID', (credentials['AccessKeyId']))
os.putenv('AWS_SECRET_ACCESS_KEY', (credentials['SecretAccessKey']))
os.putenv('AWS_SESSION_TOKEN', (credentials['SessionToken']))
os.putenv('AWS_SECURITY_TOKEN', (credentials['SessionToken']))
command_status = os.system(command + " " + " ".join(command_args))
exit(os.WEXITSTATUS(command_status))
评论列表
文章目录