Upgrade to Pro — share decks privately, control downloads, hide ads and more …

kix_009_20190429

Yohei Kawahara
April 24, 2019
810

 kix_009_20190429

九州インフラ交流勉強会(Kixs) Vol.009 でお話させて頂く予定の資料でございます.

Yohei Kawahara

April 24, 2019
Tweet

Transcript

  1. ͜Ε͸ͷّ ͱ͋ΔαʔϏεͷچαΠτ͔Β৽αΠτʹϦμΠϨΫτઃఆΛ ߦͬͨࡍͷ͓࿩Ͱ͢. ग़དྷΔ͚ͩ Infrastructure as Code ͢Δ͜ ͱͰ, ΄΅଺Γͳ͘Ҡߦ͕ऴΘͬͨͷͰ,

    ฏ੒ΛৼΓฦΔͱڞʹ, ͦͷҰ෦Λ͝঺հͤͯ͞௖͖·͢. ۝भΠϯϑϥަྲྀษڧձ(Kixs) Vol.009 ʙ ฏ੒࠷ޙͷྱ ʙ 2
  2. Θͨ͘͠͸ͷّ • ͔ͬͺ (@inokappa) • גࣜձࣾ YAMAP (2019 ೥ 1

    ݄ೖࣾ, ·ͩࢼ༻ظؒத) • ΠϯϑϥΤϯδχΞͰ͢ • ޷͖ͳ͏ͲΜ͸͝΅ఱ͏ͲΜͰ͢ ۝भΠϯϑϥަྲྀษڧձ(Kixs) Vol.009 ʙ ฏ੒࠷ޙͷྱ ʙ 3
  3. ΍ͬͨ͜ͱͷّ 1. ϦμΠϨΫτର৅ͷચ͍ग़͠ 2. Infrataster ͰςετΛॻ͘ 3. ςετΛ࣮ߦ -> ϦμΠϨΫτઃఆΛॻ͘

    (Ϧϐʔτ) 4. ϦμΠϨΫτઃఆΛద༻ͨ͠ޙ, Infrataster Ͱςετ͢Δ ۝भΠϯϑϥަྲྀษڧձ(Kixs) Vol.009 ʙ ฏ੒࠷ޙͷྱ ʙ 7
  4. 1. ϦμΠϨΫτର৅ͷચ͍ग़͠ͷّ ϦμΠϨΫτର৅ͷ URL Λચ͍ग़͢͜ͱ͸େมͳ࡞ۀͷҰͭͰ ͕ͨ͠, Google Spread Sheet Λ࢖͏ͱ,

    ҰॠͰ͋Δఔ౓ͷ URL Λநग़͢Δ͜ͱ͕ग़དྷ·ͨ͠ʂ =IMPORTXML("https://example.co.jp/", "//a/@href") ۝भΠϯϑϥަྲྀษڧձ(Kixs) Vol.009 ʙ ฏ੒࠷ޙͷྱ ʙ 8
  5. 2. ςετΛॻ͘ͷّ (1) ϦμΠϨΫτର৅ϦετΛચ͍ग़ͨ͠Β, ϦετΛݩʹ infrataster Λ༻͍ͯςετίʔυΛॻ͖·ͨ͠. require 'spec_helper' #

    ϦμΠϨΫτআ֎ΛνΣοΫ describe "Errors Check #{path}" do describe server(properties['server'].to_sym) do describe http('https://' + server(properties['server'].to_sym).server.address + path, headers: headers) do it "responds as #{code}" do expect(response.status).to eq(code) end end end end ۝भΠϯϑϥަྲྀษڧձ(Kixs) Vol.009 ʙ ฏ੒࠷ޙͷྱ ʙ 9
  6. 2. ςετΛॻ͘ͷّ (2) ςετ݅਺ = ର৅ϦμΠϨΫτ਺ͱͳΓ, ࠷ऴతʹ͸ 111 ݅΄Ͳ ͷϦμΠϨΫτ਺ͱͳΓ·ͨ͠.

    Finished in 27.11 seconds (files took 0.73366 seconds to load) 111 examples, 0 failures ۝भΠϯϑϥަྲྀษڧձ(Kixs) Vol.009 ʙ ฏ੒࠷ޙͷྱ ʙ 10
  7. 3. ϦμΠϨΫτઃఆΛॻ͘ͷّ (2) ࢒೦ͳ͕Β, ALB ͷϦμΠϨΫτઃఆͰ͸ରԠग़དྷͳ͍෦෼͸ EC2 ্ͷ Nginx ʹ͓ئ͍͢Δҝ,

    ϦμΠϨΫτͰ͸ͳ͘సૹͷఆ ٛΛ࣮૷͍͖ͯ͠·ͨ͠. ۝भΠϯϑϥަྲྀษڧձ(Kixs) Vol.009 ʙ ฏ੒࠷ޙͷྱ ʙ 12
  8. 4. ϦμΠϨΫτઃఆద༻ͱಈ࡞֬ೝͷّ • terraform apply Ұൃ • Nginx ͷ࠶ىಈ͸ AWS

    System Manager ͷ Run Command Λར༻ • ಈ࡞֬ೝͷಈ࡞֬ೝ͸ REDIRECT_YML=production.yml bundle exec rspec spec ۝भΠϯϑϥަྲྀษڧձ(Kixs) Vol.009 ʙ ฏ੒࠷ޙͷྱ ʙ 13
  9. ͓·͚ͷّ (1) ຊࢿྉͰग़͖ͯͨϓϩμΫτ. • https://github.com/ryotarai/infrataster • https://github.com/rspec/rspec • https://github.com/hashicorp/terraform •

    https://github.com/nginx/nginx • AWS System Manager ۝भΠϯϑϥަྲྀษڧձ(Kixs) Vol.009 ʙ ฏ੒࠷ޙͷྱ ʙ 16