2013-12-19 2 views
1

페이지의 Amazon의 Programmatic Billing Access 페이지는 Ruby SDK에 링크 된 샘플 코드 및 라이브러리에 대한 링크입니다. 그러나 Ruby SDK를 통해 결제 정보에 액세스하는 언급은 없습니다. 현재 가능합니까? 그렇지 않다면 결제 정보를 얻기 위해 AWS SDK를 사용하는 몇 가지 예가 있습니까?Ruby를 사용한 AWS 프로그래밍 방식의 청구 액세스

편집 :this question처럼 보입니다. 나는 this Ruby gem을 찾았지만 you do the calculation yourself처럼 보입니다. 그래서 여전히 견적입니다. 특정 서버의 정확한 비용을 원하므로 Amazon의 가격 결정에 영향을 미치는 요인을 추적 할 필요가 없습니다.

답변

1

프로그래밍 방식 청구는 사용자가 지정한 S3 버킷에 파일을 저장하는 것처럼 보입니다. 올바른 형식의 첫 번째 파일이 일부 결제 데이터와 함께 표시되기를 기다리고 있지만 안개 보석을 사용하여 다음을 작성했습니다.

# Returns contents of the billing data file for the given year and month. 
# 
# Example: 
# csv_str = read_billing_file 2011, 1 
# csv_str = read_billing_file 2013, 12 
# 
def read_billing_file year, month 
    connection = Fog::Storage.new(provider: 'AWS') # credentials in fog.yml 
    month = "0#{month}" if month.to_s.size == 1 
    regex = /aws-cost-allocation-#{year}-#{month}\.csv$/ 
    cost_file = connection.directories.get(S3_BUCKET).files.detect {|file| 
    file.key =~ regex 
    } 
    return nil unless cost_file 
    cost_file.body 
end 
관련 문제