Skip to content
Snippets Groups Projects
Commit 61975ba9 authored by Edward Hicks's avatar Edward Hicks :8ball:
Browse files

use urllib instead (ugh!)

parent f08345ae
No related branches found
No related tags found
No related merge requests found
Pipeline #92214 passed
......@@ -8,7 +8,7 @@ import re
import numbers
import json
import boto3
import requests
import urllib.request
from botocore.exceptions import ProfileNotFound, NoCredentialsError
from botocore.config import Config
......@@ -185,7 +185,6 @@ args = parser.parse_args()
ret = 1 # init as a failure code
logFile = False
Session = {}
Session['ec2id'] = requests.get('http://169.254.169.254/latest/meta-data/instance-id').text
Config = {}
Config['debug'] = False
......@@ -291,6 +290,16 @@ else:
printLog("Monitoring SNS topic '"+Config['topic']+"'", loglevels.INFO)
# Get the EC2 instance ID for this node
printLog("Retrieving EC2 instance ID", loglevels.INFO)
try:
instid = urllib.request.urlopen("http://169.254.169.254/latest/meta-data/instance-id")
Session['ec2id'] = instid.read()
except Exception as e:
printLog(e)
cleanup()
sys.exit(ret)
# Create a generic Boto3 session using the profile
printLog("Generating Boto3 session", loglevels.INFO)
try:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment