$30 off During Our Annual Pro Sale. View Details »

AWSインフラ構築ツールとしてのTerraform / SpeeeKaigi

AWSインフラ構築ツールとしてのTerraform / SpeeeKaigi

SpeeeKaigiで話しました

yuma iwasaki

August 08, 2016
Tweet

More Decks by yuma iwasaki

Other Decks in Programming

Transcript

  1. AWSΠϯϑϥߏஙπʔϧͱͯ͠ͷTerraform

  2. resource "Profile" "Yuma Iwasaki" { company = "Speee Inc." division

    = "Web Marketing" development_product = "UZOU ~ Native Ad Network" age = 25 programming_language [ "Ruby", "Scala", "Golang" ] }
  3. agenda • Terraformͱ͸ʁ • AWSΠϯϑϥߏஙπʔϧൺֱ • Terraform࢖͍ํ • ๻Β͸Ͳ͏࢖͍ͬͯΔͷ͔

  4. None
  5. None
  6. Πϯϑϥߏ੒ΛίʔυԽ͢Δ͜ͱͷͰ͖Δπʔϧ

  7. ͲΜͳ͜ͱ͕Ͱ͖Δ͔ • IaaSͷαʔόʔߏஙͷίʔυԽ • Amazon Web Services • Google Cloud

    Platform • Microsoft Azure • Heroku SetupͷίʔυԽ
  8. ओʹAWSͷΠϯϑϥߏஙπʔϧͱͯ͠࢖ΘΕ͍ͯΔ

  9. ͜Μͳܦݧͳ͍Ͱ͔͢ʁ • VPCΛ࡞Δࡍɺςετ؀ڥͱຊ൪؀ڥ΋ಉ͡ૢ࡞Λͯ͠࡞੒ͨ͠ ͭ΋Γ͕ͩҰ෦ؒҧ͍͑ͯͨ • ϚωδϝϯτίϯιʔϧΛݟΔͱ͍ͭͷؒʹ͔ṖͷΠϯελϯ ε͕Ͱ͖ͯͯɺ͍ͭ୭͕࡞੒͔͕ͨ͠Θ͔Βͳ͍

  10. AWSͷΠϯϑϥߏஙΛίʔυԽ͢Δͱͳʹ͕͍͍ͷ͔ʁ

  11. AWSͷΠϯϑϥߏஙΛίʔυԽ͢Δͱͳʹ͕͍͍ͷ͔ʁ • ϛεΒͳ͍ • ਓͷख͸ϛε͠·͕͢ɺػց͸ϛε͠ͳ͍ • ίʔυԽ͢Δ͜ͱʹΑͬͯཤྺ؅ཧ͕Մೳ • Կճ΋ߏங͢Δ৔߹ʹ͸ޮ཰త •

    ίϐϖͰ؀ڥߏங͕Ͱ͖Δ
  12. Pull RequestϕʔεͰΠϯϑϥߏங͕Ͱ͖Δɻ

  13. AWSΠϯϑϥߏஙπʔϧ • CloudFormation • Terraform • Ansible

  14. Terraform VS CloudFormation VS Ansible

  15. AWSରԠ • CloudFormation • AWSެࣜαʔϏεͳͷͰ΄΅શͯͷAWSαʔϏε͕ରԠ • ৽͍͠αʔϏεʹରͯ͠΋ɺ͍ͪૣ͘ରԠ • Terraform •

    ଟ͘ͳਓ͕࢖͏Α͏ͳαʔϏε͸΄΅ରԠ • Ansible • ଟ͘ͷਓ͕࢖͏Α͏ͳαʔϏε͸΄΅ରԠ
  16. هड़ํࣜ • CloudFormation • JSON • Terraform • ಺෦DSL •

    Ansible • YAML
  17. DryRun • CloudFormation • None • Terraform • શͯͷ࣮ߦ͸terraform planͰ֬ೝՄೳ

    • Ansible • --dry-runΦϓγϣϯͰҰ෦ରԠ
  18. طଘ؀ڥͷίʔυԽ • CloudFormation • Cloudfomer • Terraform • Terraforming •

    Ansible • None
  19. None
  20. ิ଍

  21. TerraformͰCloudFormationɺAnsibleΛ࣮ߦ͢Δ͜ͱ͕Ͱ͖Δɻ

  22. Terraform࢖͍ํ

  23. provider "aws" { region = "ap-northeast-1" } resource "aws_instance" "web"

    { ami = "ami-408c7f28" instance_type = "t1.micro" tags { Name = "HogeHogeEC2Instance } }
  24. terraform plan

  25. + aws_instance.web ami: "" => "ami-408c7f28" availability_zone: "" => "<computed>"

    ebs_block_device.#: "" => "<computed>" ephemeral_block_device.#: "" => "<computed>" instance_state: "" => "<computed>" instance_type: "" => "t1.micro" key_name: "" => "<computed>" placement_group: "" => "<computed>" private_dns: "" => "<computed>" private_ip: "" => "<computed>" public_dns: "" => "<computed>" public_ip: "" => "<computed>" root_block_device.#: "" => "<computed>" security_groups.#: "" => "<computed>" source_dest_check: "" => "1" subnet_id: "" => "<computed>" tags.#: "" => "1" tags.Name: "" => "HogeHoge" tenancy: "" => "<computed>" vpc_security_group_ids.#: "" => "<computed>" Plan: 1 to add, 0 to change, 0 to destroy.
  26. terraform apply

  27. ޿ࠂ഑৴γεςϜͷ։ൃͰ͸Ͳ͏࢖͍ͬͯΔͷ͔

  28. None
  29. ൥ࡶʹͳΓ͕ͪͳΠϯϑϥΛίʔυԽͯ͠؅ཧ

  30. AWSͷαʔϏε͝ͱʹϑΝΠϧΛ෼͚ͯ؅ཧ͍ͯ͠Δɻ

  31. ଞͷ։ൃͰ΋༗ޮ׆༻Ͱ͖Δ • ֤αʔϏεͷAWS؀ڥΛඪ४Խͯ͠TerraformԽ͢Δ͜ͱͰɺ ߴ଎͔ͭ҆શʹΠϯϑϥߏஙΛߦ͏͜ͱ͕Ͱ͖ΔΑ͏ʹͳΔɻ • ༰қʹςετ؀ڥΛߏங͢Δ͜ͱ͕Ͱ͖ɺ MicroservicesԽͨ࣌͠ͷςετ͕΍Γ΍͘͢ͳΔ

  32. ͓·͚

  33. v0.7.0৽ػೳ • Data Resource • S3ͳͲ֎෦͔Β஋ΛಡΈࠐΜͰTerraform࣮ߦ͕Մೳ • Importػೳ • ݱࡏͷΠϯϑϥঢ়ଶ͔ΒTerraformͷίʔυΛੜ੒ʢtfϑ

    ΝΠϧͷΈʣ
  34. AWSͷΠϯϑϥߏங΋ίʔυԽ͠Α͏ʂ