5
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

AWS SDK for Ruby を LocalStack で利用する際の設定について

Posted at

先程ハマって解決できたのでメモを残しておきます。

開発時等で LocalStack を利用する際に aws sdk を使って s3 upload/download などをすると TCP エラーになるかと思います。この問題を解決するための設定が以下になります。(以下は rails 環境で s3 のみ設定する例です。)

endpoint = ENV['AWS_S3_ENDPOINT'].to_s
if endpoint.present? && endpoint =~ /(localstack|localhost|127\.0\.0\.1)/
  Aws.config[:s3] = {
    endpoint: ENV['AWS_S3_ENDPOINT'].to_s,
    force_path_style: true,
  }
end

force_path_styletrue にすることで endpoint に bucket 名が含まれなくなり意図した endpoint に接続できるようになります。

5
3
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
5
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?