Skip to content

Commit

Permalink
Fixed ec2_get_console_screenshot.py (#549)
Browse files Browse the repository at this point in the history
  • Loading branch information
kyhau authored Mar 4, 2024
1 parent 002a48f commit f5bf0bd
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions EC2/ec2_get_console_screenshot.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
"""
Retrieve a JPG-format screenshot of a running instance to help with troubleshooting.
"""
import click
import logging
import os

import click
from helper.aws import AwsApiHelper, get_tag_value


logging.getLogger().setLevel(logging.DEBUG)

OUTPUT_DIR = "ec2_console_screentshots"
Expand All @@ -18,7 +17,7 @@
class Helper(AwsApiHelper):
def __init__(self):
super().__init__()

def process_request(self, session, account_id, region, kwargs):
client = session.client("ec2", region_name=region)
for item in self.paginate(client, "describe_instances", kwargs):
Expand All @@ -43,7 +42,7 @@ def process_client_error(self, e, account_id, region):
@click.command()
@click.option("--instanceid", "-i", help="EC2 instance ID. Describe all instances if not specified.")
@click.option("--profile", "-p", help="AWS profile name. Use profiles in ~/.aws if not specified.")
@click.option("--region", "-r", default="ap-southeast-2", show_default=True, help="AWS Region. Use "all" for all regions.")
@click.option("--region", "-r", default="ap-southeast-2", show_default=True, help="AWS Region. Use `all` for all regions.")
def main(instanceid, profile, region):
kwargs = {"InstanceIds": [instanceid]} if instanceid else {}
Helper().start(profile, region, "ec2", kwargs)
Expand Down

0 comments on commit f5bf0bd

Please sign in to comment.