Fixed usage of aws instance

This commit is contained in:
Shay Nehmad 2019-04-10 16:28:16 +03:00
parent 30972d926a
commit 66b90f6bfe
2 changed files with 5 additions and 1 deletions

View File

@ -5,6 +5,9 @@ __author__ = 'itay.mizeretz'
class AwsInstance(object): class AwsInstance(object):
"""
Class which gives useful information about the current instance you're on.
"""
def __init__(self): def __init__(self):
try: try:
self.instance_id = urllib2.urlopen('http://169.254.169.254/latest/meta-data/instance-id', timeout=2).read() self.instance_id = urllib2.urlopen('http://169.254.169.254/latest/meta-data/instance-id', timeout=2).read()

View File

@ -59,7 +59,8 @@ class AwsService(object):
:return: :return:
""" """
# local_ssm_client = boto3.client("ssm", region_name=AwsService.region) # local_ssm_client = boto3.client("ssm", region_name=AwsService.region)
local_ssm_client = boto3.client("ssm", region_name=AwsInstance.get_region()) current_instance = AwsInstance()
local_ssm_client = boto3.client("ssm", region_name=current_instance.get_region())
try: try:
response = local_ssm_client.describe_instance_information() response = local_ssm_client.describe_instance_information()