So I have a requirement to work out all of the RightSizing details for organisations, and really struggled to find anything on the web, so thought i would share my experience, as there was a couple of gotcha's that i had to resolve.
I created a Lambda function, which may be of use for others below - it basically takes the API token from a os.environment variable and then returns the data for me with 5 max responses. There was a lot of confusion for doing this in the API side as the API key is meant to be the username, and the password is non-existent, so you will notice that the response request has been double quoted which enabled this to work, all other attempts failed like using headers etc....
Here is the code:
import requests
import os
import json
def lamdba_handler(event, context):
token = os.environ['CLOUDABILITY_API_TOKEN']
url = "https://api.cloudability.com/v3/rightsizing/aws/recommendations/ec2?limit=5&maxRecsPerResource=1&offset=0&duration=ten-day"
response = requests.get(url, auth=(token, ""))
data = json.loads(response.text)
return {
'message': data
}
#Cloudability