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

Elixir and AWS Tutorial

Yohei Kawahara
December 22, 2017
470

Elixir and AWS Tutorial

12/22 の Fukuoka.ex #4 の LT で話す予定だった資料です。

Yohei Kawahara

December 22, 2017
Tweet

Transcript

  1. &MJYJSͱ"84
    ͱΓ͋͑ͣ4͔Β

    2017.12.22
    GVLVPLBFY
    ͔ͬͺ !JOPLBSB

    View full-size slide

  2. ઒ݪ༸ฏʢ͔ͬͺʣ
    JSFUגࣜձࣾDMPVEQBDLࣄۀ෦
    JOPLBSB
    JOPLBQQB
    JOPLBQQB
    ΪϣʔϜͰ͸ओʹγΣϧεΫϦϓτͱ
    ͔1ZUIPOΛগʑݟΑ͏Έ·ͶͰॻ
    ͘͜ͱ͕ଟ͍೔ৗͰ͢ͷͰ &MJYJS͸
    )FMMP8PSMEڃͰ͢ ॳ৺ऀͰ͢

    View full-size slide

  3. ࿩͢͜ͱ
    ‘ &MJYJSFY@BXTͰ"NB[PO4Λૢ࡞͢Δ
    ·ͰͷϝϞͰ͢
    ‘ -5<Ͱ΋>͕࣌ؒ͋Ε͹ σϞΓ·͢ʂ

    View full-size slide

  4. ࡉ͔͍͜ͱ͸ϒϩάʹॻ͖·ͨ͠
    ‘ &MJYJSͰ"84Λૢ࡞͢ΔνϡʔτϦΞϧ 4ฤ
    ˠIUUQ
    JOPLBSBIBUFCMPKQFOUSZ
    ‘ GBLFTΛ࢖ͬͯΈͨ &Y6OJU͔Βར༻ͯ͠ΈΔྫ
    ˠ
    IUUQJOPLBSBIBUFCMPKQFOUSZ

    View full-size slide

  5. &MJYJSͰ"84Λૢ࡞͢Δબ୒ࢶ Զௐ΂

    Package 名 GitHub URL GitHub Star
    ex_aws https://github.com/ex-aws/ex_aws 553
    aws https://github.com/jkakar/aws-elixir 165
    erlcloud https://github.com/erlcloud/erlcloud 523
    2017/12/17 俺調べ

    View full-size slide

  6. FY@BXT
    ‘ ͷ"84αʔϏεΛαϙʔτ
    ‘ αʔϏεຖʹ)FYύοέʔδ͕ఏڙ͞Ε͍ͯΔ
    ‘ )551ΫϥΠΞϯτ΍+40/$PEFDબ୒Մ
    ‘ &YQPOFOUJBM#BDLPGGΞϧΰϦζϜ
    ‘ ϦτϥΠॲཧͱϖʔδωʔτ

    View full-size slide

  7. NJYFYT
    defp deps do
    [
    {:ex_aws, "~> 2.0"},
    {:ex_aws_s3, "~> 2.0"},
    {:hackney, "~> 1.9"},
    {:sweet_xml, "~> 0.6"},
    {:configparser_ex, "~> 2.0"}
    ]
    end

    View full-size slide

  8. DPOpHFYT
    config :ex_aws,
    debug_requests: false,
    access_key_id: [{:awscli, "watashino-profile", 30},
    :instance_role],
    secret_access_key: [{:awscli, "watashino-profile",
    30}, :instance_role],
    region: "ap-northeast-1"

    View full-size slide

  9. 4όέοτҰཡΛऔಘ͢Δαϯϓϧ
    iex(4)> ExAws.S3.list_buckets |> ExAws.request!
    %{body: %{buckets: [%{creation_date: "2017-12-17T05:30:42.000Z",
    name: "oreno-bucket-1"},
    %{creation_date: "2017-12-17T05:30:43.000Z", name: "oreno-bucket-2"},
    %{creation_date: "2017-12-17T05:30:44.000Z", name: "oreno-bucket-3"},
    ...
    headers: [{"x-amz-id-2",
    "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"},
    {"x-amz-request-id", "0F9E0E78F451D1C1"},
    {"Date", "Sun, 17 Dec 2017 04:56:41 GMT"},
    {"Content-Type", "application/xml"}, {"Transfer-Encoding", "chunked"},
    {"Server", "AmazonS3"}], status_code: 200}

    View full-size slide

  10. ͕࣌ؒ͋ͬͨΒσϞʂ

    View full-size slide

  11. σϞ
    ‘ FY@BXT@TΛར༻ͯ͠4ͷόέοτҰཡ
    +40/Ͱऔಘ͢Δ

    View full-size slide

  12. ͱ͍͏ࣄͰʜ

    View full-size slide

  13. ͍͞͝ʹ
    ‘ &MJYJS͔Β"84Λૢ࡞͢Δ৔߹ FY@BXT͕
    ݱ࣌఺Ͱ͸σϑΝΫτͩͱࢥ͍·ͨ͠
    ‘ Ϗοάσʔλͷ࿩͸શ͘͠·ͤΜͰ͕ͨ͠ Ϗο
    Ϋσʔλͷ෼ੳج൫ͱͯ͠"84ͷར༻Λݕ౼
    ͢Δࡍͷ͖͔͚ͬʹͳΕ͹޾͍Ͱ͢

    View full-size slide

  14. ྑ͍͓೥Λ

    View full-size slide