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

terraform,ECS,ALBで作るお気軽デプロイinfrastructure

C6a8cb5e13aa716521d522471ec4e4cd?s=47 ma2k8
September 29, 2016

 terraform,ECS,ALBで作るお気軽デプロイinfrastructure

サンプルコードは後ほど掲載します。

C6a8cb5e13aa716521d522471ec4e4cd?s=128

ma2k8

September 29, 2016
Tweet

Transcript

  1. terraform,ECS,ALBͰ࡞Δ ͓ؾܰσϓϩΠ infrastructure Recruit Marketing Partners দ઒ ཌྷ

  2. ࣗݾ঺հ 2016年3月入社。 “スタディサプリ English”の サーバーサイド、インフラ周りを担当してい ます。 前職は広告やってました。 @wing_007 松川 翼

    @ma2k8
  3. ৽نҊ͕݅࢝·ͬͨͷͰ

  4. DeployपΓ੔උͨ͠ ࡢ೔ͬ͞ͱ࡞ͬͨͷͰ ͓͔͠ͳ఺͕͋Ε͹͝༰͍ࣻͩ͘͞

  5. terraform HashiCorp੡ͷΦʔέετϨʔγϣϯπʔϧɻ AWSҎ֎ʹ΋GCP,Heroku,Atlas౳ ༷ʑͳϓϥοτϑΥʔϜʹରԠ͍ͯ͠Δɻ ͘͢͝ศར 参考: https://www.terraform.io/

  6. ECS (Amazon EC2 Container Service) AWSͷDockerίϯςφ؅ཧαʔϏεɻ Ϋϥελ΁ͷΞϓϦέʔγϣϯ୯ҐͷσϓϩΠɺ Ϧιʔε഑෼ͷ؅ཧ౳͕Ͱ͖Δɻ ͘͢͝ศར 参考:

    https://aws.amazon.com/jp/ecs/details/
  7. ALB (Application Load Balancer) AWS଴๬ͷL7ϩʔυόϥϯαʔɻ URLύεͰͷϧʔςΟϯά΍ HTTP/2ͷαϙʔτɺ ECSͷμΠφϛοΫϙʔτϚοϐϯάͳͲʹରԠɻ ͘͢͝ศར 参考:

    https://aws.amazon.com/jp/blogs/aws/new-aws-application-load-balancer/
  8. terraformͷ ߏ੒ϑΝΠϧ ͘͢͝Θ͔Γ΍͍͢

  9. ݟͤΔ

  10. Ͱ͖ͨߏ੒

  11. Deploy

  12. resource "aws_ecs_task_definition" “test_task_definition” { family = “test-nginx" container_definitions = <<DEFINITION

    [ { "name": “test-nginx", "image": "registry.eitangosapuri.jp/test-nginx:b848744", "cpu": 128, "memory": 512, "essential": true, "portMappings": [ { "containerPort": 80, "hostPort": 80 } ] } ] DEFINITION } ͔͑͜͜Δ͚ͩ↑
  13. ਺ඵఔɺ৽چ؀ڥ͕ࠞࡏ͢Δ

  14. Ͱ΋ɺμ΢ϯλΠϜ 0 23࣌53෼50ඵ | blue env 23࣌53෼51ඵ | blue env

    23࣌53෼52ඵ | blue env 23࣌53෼53ඵ | blue env 23࣌53෼54ඵ | green env 23࣌53෼55ඵ | blue env 23࣌53෼57ඵ | green env 23࣌53෼58ඵ | blue env 23࣌53෼59ඵ | green env 23࣌54෼00ඵ | blue env 23࣌54෼01ඵ | green env 23࣌54෼05ඵ | blue env 23࣌54෼06ඵ | green env 23࣌54෼07ඵ | blue env 23࣌54෼08ඵ | green env 23࣌54෼09ඵ | blue env 23࣌54෼10ඵ | green env 23࣌54෼12ඵ | blue env 23࣌54෼13ඵ | green env 23࣌54෼14ඵ | blue env 23࣌54෼15ඵ | green env 23࣌54෼16ඵ | green env 23࣌54෼20ඵ | green env
  15. ࠓޙ

  16. dev؀ڥ ᶄjenkins͓͡͞Μ͕ docker build&push ᶃfutureϒϥϯνΛdevelopϒϥϯν΁Ϛʔδ WebHook ᶆslackʹ௨஌ ᶅdeploy

  17. stg؀ڥ ᶄjenkins͓͡͞Μ͕ docker build&push ᶃdevelopϒϥϯνΛreleaseϒϥϯν΁Ϛʔδ WebHook ᶆslackʹ௨஌ ᶅdeploy

  18. prod؀ڥ ᶄjenkins͓͡͞Μ͕ docker build&push ᶃreleaseϒϥϯνΛmasterϒϥϯν΁Ϛʔδ WebHook ᶅslackʹ DeployϘλϯ ᶉdeploy ᶇDeployϘλϯԡͨ͠Β

    Deploy։࢝
  19. ͋Γ͕ͱ͏͍͟͝·ͨ͠