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

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

    View full-size slide

  2. resource "Profile" "Yuma Iwasaki" {
    company = "Speee Inc."
    division = "Web Marketing"
    development_product = "UZOU ~ Native Ad Network"
    age = 25
    programming_language [
    "Ruby",
    "Scala",
    "Golang"
    ]
    }

    View full-size slide

  3. agenda
    • Terraformͱ͸ʁ
    • AWSΠϯϑϥߏஙπʔϧൺֱ
    • Terraform࢖͍ํ
    • ๻Β͸Ͳ͏࢖͍ͬͯΔͷ͔

    View full-size slide

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

    View full-size slide

  5. ͲΜͳ͜ͱ͕Ͱ͖Δ͔
    • IaaSͷαʔόʔߏஙͷίʔυԽ
    • Amazon Web Services
    • Google Cloud Platform
    • Microsoft Azure
    • Heroku SetupͷίʔυԽ

    View full-size slide

  6. ओʹAWSͷΠϯϑϥߏஙπʔϧͱͯ͠࢖ΘΕ͍ͯΔ

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  10. Pull RequestϕʔεͰΠϯϑϥߏங͕Ͱ͖Δɻ

    View full-size slide

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

    View full-size slide

  12. Terraform VS CloudFormation VS Ansible

    View full-size slide

  13. AWSରԠ
    • CloudFormation
    • AWSެࣜαʔϏεͳͷͰ΄΅શͯͷAWSαʔϏε͕ରԠ
    • ৽͍͠αʔϏεʹରͯ͠΋ɺ͍ͪૣ͘ରԠ
    • Terraform
    • ଟ͘ͳਓ͕࢖͏Α͏ͳαʔϏε͸΄΅ରԠ
    • Ansible
    • ଟ͘ͷਓ͕࢖͏Α͏ͳαʔϏε͸΄΅ରԠ

    View full-size slide

  14. هड़ํࣜ
    • CloudFormation
    • JSON
    • Terraform
    • ಺෦DSL
    • Ansible
    • YAML

    View full-size slide

  15. DryRun
    • CloudFormation
    • None
    • Terraform
    • શͯͷ࣮ߦ͸terraform planͰ֬ೝՄೳ
    • Ansible
    • --dry-runΦϓγϣϯͰҰ෦ରԠ

    View full-size slide

  16. طଘ؀ڥͷίʔυԽ
    • CloudFormation
    • Cloudfomer
    • Terraform
    • Terraforming
    • Ansible
    • None

    View full-size slide

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

    View full-size slide

  18. Terraform࢖͍ํ

    View full-size slide

  19. provider "aws" {
    region = "ap-northeast-1"
    }
    resource "aws_instance" "web" {
    ami = "ami-408c7f28"
    instance_type = "t1.micro"
    tags {
    Name = "HogeHogeEC2Instance
    }
    }

    View full-size slide

  20. terraform plan

    View full-size slide

  21. + aws_instance.web
    ami: "" => "ami-408c7f28"
    availability_zone: "" => ""
    ebs_block_device.#: "" => ""
    ephemeral_block_device.#: "" => ""
    instance_state: "" => ""
    instance_type: "" => "t1.micro"
    key_name: "" => ""
    placement_group: "" => ""
    private_dns: "" => ""
    private_ip: "" => ""
    public_dns: "" => ""
    public_ip: "" => ""
    root_block_device.#: "" => ""
    security_groups.#: "" => ""
    source_dest_check: "" => "1"
    subnet_id: "" => ""
    tags.#: "" => "1"
    tags.Name: "" => "HogeHoge"
    tenancy: "" => ""
    vpc_security_group_ids.#: "" => ""
    Plan: 1 to add, 0 to change, 0 to destroy.

    View full-size slide

  22. terraform apply

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  28. AWSͷΠϯϑϥߏங΋ίʔυԽ͠Α͏ʂ

    View full-size slide