Instance Metadata Service (IMDS)
Obtaining an IMDS JWT
To obtain the JWT, you’ll use our Token endpoint. You can access this with either our SDK, or via a JSON request.
SDK
In this example, we’ll use our Python SDK to retrieve and store the JWT in a text file for later.
Python
from salad_cloud_imds_sdk import SaladCloudImdsSdk, Environment
sdk = SaladCloudImdsSdk( base_url=Environment.DEFAULT.value, timeout=10000 )
result = sdk.metadata.get_container_token()
with open('jwt.txt', 'w+') as token:
token.write(result)
print("Saved JWT to file...")
SDK Examples
JSON Request
You can request the token directly from the endpoint at http://169.254.169.254/v1/token
. In this example, we’ll do the same as before but with a JSON post request via Python.
Python
import requests
r = requests.get('http://169.254.169.254:80/v1/token')
token =r.json()['jwt']
with open('jwt.txt', 'w+') as token:
token.write(result)
print("Saved JWT to file...")
JSON Request Examples
Was this page helpful?