Last active
October 25, 2017 11:51
-
-
Save akira345/3a8053879ad73a0a8bdd59be145cd3e7 to your computer and use it in GitHub Desktop.
AWS SDK fro Ruby V3でACMに登録した証明書一覧を取得するサンプル
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
# | |
# ACMに登録された証明書を出力するサンプルスクリプトです。 | |
# 要 AWS SDK for Ruby V3 | |
require 'aws-sdk-core' | |
require 'aws-sdk-acm' # V3になって個別ロードになった。 | |
require 'yaml' | |
require 'pp' | |
config = YAML.load(File.read('config.yml')) | |
Aws.config[:credentials] = Aws::Credentials.new(config['access_key_id'], config['secret_access_key']) | |
acm = Aws::ACM::Client.new(region: config['region']) | |
next_token = nil | |
next_data = true | |
while next_data do | |
resp = acm.list_certificates({ | |
certificate_statuses:["ISSUED"], #発行済みのもの | |
next_token: next_token, | |
max_items: 1, | |
}) | |
# 証明書の情報表示 | |
pp resp | |
# 次の証明書があると、next_tokenにトークンがセットされる。 | |
# なければnilが入る | |
if resp.next_token.nil? | |
next_data = false | |
else | |
next_token = resp.next_token | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment