Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
add AMI id to instance info on builds
Browse files Browse the repository at this point in the history
  • Loading branch information
larroy committed Feb 21, 2020
1 parent 9dcf71d commit 88509d1
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions ci/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,18 +96,19 @@ def under_ci() -> bool:

def ec2_instance_info() -> str:
import requests
urls = [
"http://instance-data/latest/meta-data/instance-type",
"http://instance-data/latest/meta-data/instance-id",
"http://instance-data/latest/meta-data/public-hostname",
"http://instance-data/latest/meta-data/ami-id"
]
if under_ci():
result = []
try:
r = requests.get("http://instance-data/latest/meta-data/instance-type")
if r.status_code == 200:
result.append(r.content.decode())
r = requests.get("http://instance-data/latest/meta-data/instance-id")
if r.status_code == 200:
result.append(r.content.decode())
r = requests.get("http://instance-data/latest/meta-data/public-hostname")
if r.status_code == 200:
result.append(r.content.decode())
for url in urls:
r = requests.get(url)
if r.status_code == 200:
result.append(r.content.decode())
return ' '.join(result)
except ConnectionError:
pass
Expand Down

0 comments on commit 88509d1

Please sign in to comment.