LoginSignup
1
1

More than 5 years have passed since last update.

AWS SDK for Ruby のElastiCacheなどWaiterが実装されていないサービスで雑に待つ

Posted at

AWS SDK for Rubyのv2は残念ながらまだ開発途上のようでちょいちょい足りない機能がある。

なぜかElastiCacheの構築スクリプトを書いていたらWaiterが実装されていないことに気づいた。
Monkey PatchingできないかSDKのコードを確認したがJSONからAPIなどを生成するようなことをしていて、ちょい面倒そうだったので素直に雑なコードを書いた。

# "client" is instance of AWS::ElastiCache::Client

def wait_available(client, id)
  loop do
    status = client.describe_cache_clusters(cache_cluster_id: id)
      .cache_clusters
      .first
      .cache_cluster_status
    break if status == 'available'
    sleep 10
  end
end
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1