def get_used_s3_version(cfn_client, stack_name):
    """
    Returns the object version used by the CloudFormation stack.

    """

    response = cfn_client.describe_stacks(StackName=stack_name)
    stack = response["Stacks"][0]
    outputs = {}
    for output in stack["Outputs"]:
        key = output["OutputKey"]
        value = output["OutputValue"]
        outputs[key] = value
    return outputs["AppVersionId"]