📝日常

Day 21

Tony Duong

Tony Duong

4月 13, 2026 · 2

他の言語:🇫🇷🇬🇧
#engineering#ddia#reading#transactions#youtube#video#concurrency#testing#distributed-systems#aws#iam-identity-center#sandbox#ai
Day 21

今日やったこと:

汎用 Ruby/Rails RSpec スニペット

# spec/models/job_concurrency_spec.rb
it "keeps both updates without lost update" do
  job = Job.create!(state: { "a" => { "status" => "pending" }, "b" => { "status" => "pending" } })
  ready = Queue.new
  go = Queue.new

  threads = %w[a b].map do |key|
    Thread.new do
      ActiveRecord::Base.connection_pool.with_connection do
        local = Job.find(job.id)
        ready << true
        go.pop
        local.update_node_status!(key, "succeeded")
      end
    end
  end

  2.times { ready.pop }
  2.times { go << true }
  threads.each(&:join) # wait for both threads to finish

  result = Job.find(job.id)
  expect(result.state.dig("a", "status")).to eq("succeeded")
  expect(result.state.dig("b", "status")).to eq("succeeded")
end
# app/models/job.rb
def update_node_status!(key, status)
  with_lock do
    data = state.deep_dup
    data[key]["status"] = status
    update!(state: data)
  end
end

AWS Innovation Sandbox on AWS(クイック要約)

  • IAM Identity Center を使い、管理者/マネージャー/サンドボックス利用者が集中管理された authn/authz で sandbox アカウントへアクセスできる
  • web ui は CloudFront + S3 で配信し、API トラフィックは WAF で保護して API Gateway 経由でルーティングする
  • アカウントライフサイクルと自動化のワークフローロジックは LambdaEventBridgeStep Functions で実行する
  • 状態/設定は DynamoDBAppConfig に保存し、control plane と管理対象 sandbox アカウントを明確に分離している

AWS Innovation Sandbox architecture


Claudeによる翻訳

Tony Duong

著者: Tony Duong

デジタル日記。思考、経験、そして人生についての考え。