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

AWSのAPIをカジュアルに

 AWSのAPIをカジュアルに

#jawsug #cloudgirl の資料です

B4afc7d853d7f1cb6a253d3c7183c05a?s=128

Naoya Ito

June 28, 2014
Tweet

Transcript

  1. "84ͷ"1*ΛΧδϡΞϧʹ /BPZB*UP ,"*;&/QMBUGPSN*OD  ୈճ+"846(Ϋϥ΢υঁࢠձ

  2. ࠓ೔ͷ࿩ •  "1*Λ͓΋͠Ζ͘࢖͓͏ •  ͦͷྫΛ͍͔ͭ͘

  3. "84ͱ͍͑͹"1* •  "84͕طଘͷαʔόʔΠϯϑϥͱҧ͏ͱ͜Ζ –  "1*ɺϓϩάϥϚϒϧ •  ϓϩάϥϚϒϧͳΠϯϑϥ –  *OGSBTUSVDUVSFBT$PEF – 

    ŋŋŋͱ͍͏࿩΋͍͍͚Ͳɺࠓ೔͸΋ͬͱΧδϡΞϧʹɺݸਓ༻్ Ͱ"84Λ͓΋͠Ζ͘࢖͓͏ɺͱ͍͏࿩  େن໛Πϯϑϥʙɺͱ͔͡Ό ͳͯ͘೔ৗͷͪΐͬͱͨ͠ಓ ۩ʹ"84Λɺ"1*Λ͏·͘ ࢖ͬͯ
  4. ,BJ[FO[P (ZB[PΈ͍ͨͳ6* ͰࡱӨͨ͠εΫγϣΛ 4ʹ্͛Δ

  5. σϞ

  6. ͜Μͳ͜ͱʹ࢖ΘΕͯ·͢ 2JJUB5FBN )JQ$IBU (JU)VC

  7. ,BJ[FO[Pͷத਎ •  ਺ेߦͷSVCZεΫϦϓτ •  049ͷTDSFFODBQUVSFίϚϯυ •  "844%,GPS3VCZ – "NB[PO4 •  X4UBUJD8FC)PTUJOH

  8. $  screencapture  –i  /tmp/capture.png TDSFFODBQUVSFίϚϯυ

  9. "844%,GPS3VCZ s3  =  AWS::S3.new(      :access_key_id      

       =>  ENV['AWS_ACCESS_KEY'],      :secret_access_key  =>  ENV['AWS_SECRET_ACCESS_KEY'],      :s3_endpoint              =>  's3-­‐ap-­‐northeast-­‐1.amazonaws.com'   )     bucket  =  s3.buckets['kaizenzo.kaizenplatform.in']     bucket.objects['images/12345.png'].write(      :file  =>  '/tmp/capture.png',        :content_type  =>  'image/png'   )         "1*ͱ͔4%,ͱ͍͏ͱ೉ͦ͠ ͏ʹฉ͑͜Δ͚Ͳɺ࣮ࡍ͸؆୯ɻ HFNJOTUBMMBXTTELͯ͠࢖͏
  10. ΍ͬͯΔ͜ͱ •  4UBUJD8FC)PTUJOHΛ༗ޮʹͨ͠CVDLFU Λ4ʹ༻ҙ •  3VCZεΫϦϓτͰҎԼΛ΍Δ –  TDSFFODBQUVSFίϚϯυΛ࣮ߦ •  TZTUFNTDSFFODBQUVSFrJUNQDBQUVSFQOH

    •  ௥ՃͰTJQTίϚϯυͰϓϩϑΝΠϧΛ࡟আͨ͠Γ  –  औͬͨϑΝΠϧΛ"1*Ͱ4ʹΞοϓϩʔυ
  11. εΫϦϓτͷ#VOEMFԽ •  3VCZεΫϦϓτΛBQQʹ͢Δ •  ී௨ͷΞϓϦΈ͍ͨʹ࣮ߦͰ͖Δ •  IUUQXXXHMBNFOWTFQU[FOOFUWJFX͜ͷลࢀߟ Kaizenzo.app/    

     Contents/          Info.plist      MacOS/      Resources/          kaizenzo.rb          appIcon.icns ܾΊΒΕͨσΟϨΫτϦ ϨΠΞ΢τͰϑΝΠϧΛ ஔ͍ͯɺ*OGPQMJTU 9.-  Λॻ͚ͩ͘
  12. ͪͳΈʹࣗ෼ઐ༻ͷ΋͋Δ •  ແବʹ$MPVE'SPOUڬΜͰΔ •  CMPHʹը૾షΓ͍ͨͱ͖ɺ5XJUUFSʹྲྀ͍ͨ࣌͠ͱ͔ ʹ࢖ͬͯΔ

  13. .JEEMFNBO

  14. ྫ͑͹ J04ΞϓϦͷࠂ஌ϖʔδɻ .JEEMFNBOͰͰ͖ͯΔ

  15. .JEEMFNBOͬͯ  •  αΠτΞηϯϒϥ –  ੩తαΠτ੍࡞ͨΊͷϑϨʔϜϫʔΫ –  ੩తαΠτΛ8FCΞϓϦέʔγϣϯͷΑ͏ʹ࡞ΕΔ •  $44ϓϦϓϩηοα

    4BTT$PNQBTT  •  ςϯϓϨʔτΤϯδϯ &3#ɺTMJN  •  ΞηοτύΠϓϥΠϯ •  -JWF3FMPBE
  16. NJEEMFNBOJOJUͰα ΠτͷͻͳܗΛੜ੒ TMJNͱ͔TBTTͱ͔ DP⒎FFTDSJQUͱ͔ .BSLEPXOͱ͔ͰαΠτΛ ࡞ΕΔ

  17. NJEEMFNBOTFSWFSͰಈ࡞֬ ೝ༻ͷ)551αʔόʔ͕ىಈɻ -JWF3FMPBE࿈ܞ΋͋ΔΑ

  18. NJEEMFNBOCVJMEͰΞηο τ͔Β੒Ռ෺Λ·ͱΊͯϏϧ υ

  19. NJEEMFNBOTZOD 4UBUJD8FC)PTUJOHͱ૊Έ߹ΘͤΔͱ٢ ίϚϯυͻͱͭͰ "NB[PO4ʹ .JEEMFNBOͰ࡞ͬͨαΠ τΛసૹ

  20. σϞ

  21. activate  :sync  do  |sync|      sync.fog_provider    =  'AWS'

         sync.fog_directory  =  'cloudgirl.bloghackers.net'      sync.fog_region        =  'ap-­‐northeast-­‐1'      sync.aws_access_key_id          =  ENV['AWS_ACCESS_KEY_ID']      sync.aws_secret_access_key  =  ENV['AWS_SECRET_ACCESS_KEY']      sync.existing_remote_files  =  'keep'      sync.gzip_compression  =  false      sync.after_build  =  false   end     Fog.credentials  =  {  :path_style  =>  true  }  #  Work  around   NJEEMFNBOTZODͷઃఆ
  22. NJEEMFNBOCMPH -­‐-­‐-­‐   title:  ࠓ೔͸Ϋϥ΢υঁࢠձͰ͢   -­‐-­‐-­‐     -­‐

     Hello,  JAWS   -­‐  ͜Μʹͪ͸ɺՄѪ͍ݘͰ͢Ͷ   -­‐  Markdown  Ͱॻ͘ΜͰ͢Α   NJEEMFNBOTZODͱ૊Έ߹Θͤͯ 4Ͱެ։͢ΔCMPH͕࡞Ε·͢ ςΩετΛॻ͍ͯ NJEEMFNBOCVJMEͰCMPH هࣄʹͳΔ
  23. None
  24. 6OJYతͳখಓ۩Λ࡞Δ

  25. σϞ

  26. ΍ͬͯΔ͜ͱ •  FDMJTU – &$Πϯελϯε৘ใΛ"1*ͰҾ͍ͯ͘Δ – ϩʔΧϧʹ݁ՌΛΩϟογϡ͠ͱ͘ •  QFSDPM

  27. $  ec2list  |  percol  |  cut  -­‐f  4  |  xargs

     -­‐o  -­‐n  1  ssh   ύΠϓͰͭͳ͛Δ ࡞ͬͨͷ͸&$Πϯελ ϯεͷҰཡΛग़ྗ͢Δͱ ͜ FDMJTU ͚ͩ
  28. "1*ʹΑΔ&$Ұཡͷऔಘ ec2  =  AWS::EC2.new(      :access_key_id      

       =>  ENV['AWS_ACCESS_KEY_ID'],      :secret_access_key  =>  ENV['AWS_SECRET_ACCESS_KEY'],      :region                        =>  ENV['AWS_REGION']  ||  "us-­‐west-­‐1"   )     AWS.memoize  do      instances  =  ec2.instances.map  do  |i|          puts  [i.status,  i.tags[:Name],  i.tags[:Role]].join("\t")      end   end  
  29. 5*14"84NFNPJ[F AWS.memoize  do      instances  =  ec2.instances.map  do  |i|

             ...      end   end   "1*ίʔϧ͕ଟ͔͔͗ͯ࣌ؒ͢Δͱ͖͸ NFNPJ[FͰ͖ͳ͍͔ࢼͯ͠ΈΑ͏ "84NFNPJ[F͕"1*ͷ Ԡ౴Λྑ͍ײ͡ʹΩϟο γϡͯ͘͠Εͯɺߴ଎ʹ
  30. ·ͱΊ •  "84ͷ"1*Λ͓΋͠Ζ͘࢖͓͏ •  ࢥͬͯΔΑΓͣͬͱ؆୯ •  "84ΛʮΠϯϑϥʯͰ͸ͳ͘ʮϓϩάϥϜͷ ෦඼ʯͰ͋Δͱଊ͑ͯΈΔͱྑ͍͔΋

  31. ͝ਗ਼ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠