import json


def parse_credentials(sts_output):
    """Parse the credentials contained in the output of `aws sts` commands."""
    sts_output_dict = json.loads(sts_output)
    creds_dict = sts_output_dict["Credentials"]
    expected_keys = [
        "AccessKeyId",
        "SecretAccessKey",
        "SessionToken",
        "Expiration",
    ]
    for key in expected_keys:
        assert key in creds_dict
    return creds_dict