{"id":3885,"date":"2021-01-03T01:27:20","date_gmt":"2021-01-02T16:27:20","guid":{"rendered":"https:\/\/tech.akat.info\/?p=3885"},"modified":"2021-01-03T01:27:20","modified_gmt":"2021-01-02T16:27:20","slug":"aws-cloudshell%e3%81%a7fargatecli%e3%82%92%e4%bd%bf%e3%81%a3%e3%81%a6%e3%82%b3%e3%83%b3%e3%83%86%e3%83%8a%e3%82%92%e6%a7%8b%e7%af%89%e3%81%99%e3%82%8b","status":"publish","type":"post","link":"https:\/\/tech.akat.info\/?p=3885","title":{"rendered":"AWS CloudShell\u3067fargatecli\u3092\u4f7f\u3063\u3066\u30b3\u30f3\u30c6\u30ca\u3092\u69cb\u7bc9\u3059\u308b"},"content":{"rendered":"<p><a href=\"https:\/\/zenn.dev\/sasasin\/articles\/b43cea2ffe8813\">fargatecli \u3067\u30b3\u30f3\u30c6\u30ca\u3092\u7acb\u3066\u308b<\/a>\u3092\u53c2\u8003\u306b\u3001AWS CloudShell\u306b\u3066fargatecli\u3092\u4f7f\u3063\u3066\u30b3\u30f3\u30c6\u30ca\u3092\u69cb\u7bc9\u3057\u3066\u307f\u305f\u3002<\/p>\n<h2>VPC\u306e\u4f5c\u6210<\/h2>\n<p><a href=\"https:\/\/dev.classmethod.jp\/articles\/create_nat_gateway\/\">\u5fc5\u8981\u306a\u6642\u3060\u3051NAT Gateway\u3092\u4f5c\u6210\u3059\u308b\u65b9\u6cd5<\/a>\u3092\u53c2\u8003\u306bVPC\u3092\u7528\u610f\u3059\u308b\u3002<br \/>\n\u203bNAT Gateway\u3092\u6709\u52b9\u306b\u3057\u3066\u304a\u304f\u3053\u3068\u3002\u6709\u52b9\u306b\u3057\u306a\u3051\u308c\u3070\u3001\u30b3\u30f3\u30c6\u30ca\u69cb\u7bc9\u6642\u306b<a href=\"https:\/\/aws.amazon.com\/jp\/premiumsupport\/knowledge-center\/ecs-pull-container-error\/\">CannotPullContainerError<\/a>\u3068\u3044\u3046\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3059\u308b\u3002<\/p>\n<p>\u203b\u4ee5\u4e0b\u3092\u30e1\u30e2\u3059\u308b\u3053\u3068\u3002<br \/>\n FrontendSubnet1\uff1asubnet-08e497065e5f7eca2<br \/>\n FrontendSubnet2\uff1asubnet-0c438bd446091cb37<br \/>\n ApplicationSubnet1\uff1asubnet-0cbd4e4f7d2b01d25<br \/>\n ApplicationSubnet2\uff1asubnet-05bedb7310ebaadb4<\/p>\n<p>ALB,\u30b3\u30f3\u30c6\u30ca\u7528\u306b\u81ea\u5b85\u3068 10.0.0.0\/8 \u304b\u308980\u756a\u30dd\u30fc\u30c8\u306b\u30a2\u30af\u30bb\u30b9\u3067\u304d\u308b\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u30b0\u30eb\u30fc\u30d7\u3092\u4f5c\u6210\u3059\u308b\u3002<br \/>\n \u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u30b0\u30eb\u30fc\u30d7\u540d\uff1asg-0f6bb0bd6402c613a<\/p>\n<h2>AWS CloudShell\u306bfargatecli\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b<\/h2>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n$ amazon-linux-extras list | grep golang\r\n 29  golang1.11               available\r\n$ sudo amazon-linux-extras install golang1.11\r\n...\r\n$ go version\r\ngo version go1.15.3 linux\/amd64\r\n$ go get github.com\/awslabs\/fargatecli\r\n...\r\n$ cd go\/bin\/\r\n$ .\/fargatecli --version\r\nfargate version 0.3.2\r\n<\/pre>\n<h2>ECS\u30af\u30e9\u30b9\u30bf\u30fc\u306e\u4f5c\u6210<\/h2>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n$ aws ecs create-cluster --cluster-name nginx-cluster\r\n{\r\n    &quot;cluster&quot;: {\r\n        &quot;clusterArn&quot;: &quot;arn:aws:ecs:ap-northeast-1:377343199566:cluster\/nginx-cluster&quot;,\r\n        &quot;clusterName&quot;: &quot;nginx-cluster&quot;,\r\n        &quot;status&quot;: &quot;ACTIVE&quot;,\r\n        &quot;registeredContainerInstancesCount&quot;: 0,\r\n        &quot;runningTasksCount&quot;: 0,\r\n        &quot;pendingTasksCount&quot;: 0,\r\n        &quot;activeServicesCount&quot;: 0,\r\n        &quot;statistics&quot;: &#x5B;],\r\n        &quot;tags&quot;: &#x5B;],\r\n        &quot;settings&quot;: &#x5B;\r\n            {\r\n                &quot;name&quot;: &quot;containerInsights&quot;,\r\n                &quot;value&quot;: &quot;disabled&quot;\r\n            }\r\n        ],\r\n        &quot;capacityProviders&quot;: &#x5B;],\r\n        &quot;defaultCapacityProviderStrategy&quot;: &#x5B;]\r\n    }\r\n}\r\n<\/pre>\n<h2>ALB\u306e\u4f5c\u6210<\/h2>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n$ .\/fargatecli lb create nginx-lb --port 80 --scheme internet-facing --subnet-id subnet-08e497065e5f7eca2,subnet-0c438bd446091cb37 --security-group-id sg-0f6bb0bd6402c613a\r\n&#x5B;i] Created load balancer nginx-lb\r\n$ .\/fargatecli lb list\r\nNAME            TYPE            STATUS  DNS NAME                                                PORTS\r\nnginx-lb        Application     Active  nginx-lb-558211939.ap-northeast-1.elb.amazonaws.com     HTTP:80\r\n<\/pre>\n<h2>\u30b3\u30f3\u30c6\u30ca\u3092\u69cb\u7bc9\u3059\u308b<\/h2>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n$ .\/fargatecli service create nginx-service --cluster nginx-cluster --subnet-id subnet-0cbd4e4f7d2b01d25,subnet-05bedb7310ebaadb4 --cpu 256 --memory 512 --num 2 --image nginx:latest --port 80 --security-group-id sg-0f6bb0bd6402c613a --lb nginx-lb\r\n&#x5B;i] Created service ngx-service\r\n$ .\/fargatecli service list --cluster nginx-cluster\r\nNAME            IMAGE           CPU     MEMORY  LOAD BALANCER   DESIRED RUNNING PENDING\r\nnginx-service   nginx:latest    256     512     nginx-lb        2       2       0\r\n<\/pre>\n<p>ALB\u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u3068\u30b3\u30f3\u30c6\u30ca\u306e\u30e1\u30c3\u30bb\u30fc\u30b8\u304c\u8868\u793a\u3055\u308c\u308b\u3002<br \/>\n<a href=\"https:\/\/tech.akat.info\/wp-content\/uploads\/2021\/01\/2021-01-03_001638.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/tech.akat.info\/wp-content\/uploads\/2021\/01\/2021-01-03_001638-300x113.jpg\" alt=\"\" width=\"300\" height=\"113\" class=\"alignnone size-medium wp-image-3886\" srcset=\"https:\/\/tech.akat.info\/wp-content\/uploads\/2021\/01\/2021-01-03_001638-300x113.jpg 300w, https:\/\/tech.akat.info\/wp-content\/uploads\/2021\/01\/2021-01-03_001638-1024x384.jpg 1024w, https:\/\/tech.akat.info\/wp-content\/uploads\/2021\/01\/2021-01-03_001638-768x288.jpg 768w, https:\/\/tech.akat.info\/wp-content\/uploads\/2021\/01\/2021-01-03_001638-1536x576.jpg 1536w, https:\/\/tech.akat.info\/wp-content\/uploads\/2021\/01\/2021-01-03_001638.jpg 1896w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><br \/>\n\u7c21\u5358\u306bfargatecli\u3067\u30b3\u30f3\u30c6\u30ca\u69cb\u7bc9\u3067\u304d\u305f\u3002<br \/>\n\u3057\u304b\u3057\u53c2\u8003\u8a18\u4e8b\u306b\u3082\u3042\u308b\u901a\u308a\u3001\u73fe\u6bb5\u968e\u3067fargatecli\u306e\u6700\u7d42\u66f4\u65b0\u65e5\u304c2020\u5e744\u670810\u65e5\u3068\u306a\u3063\u3066\u304a\u308a\u3001\u304c\u3063\u3064\u308a\u5229\u7528\u306f\u907f\u3051\u305f\u307b\u3046\u304c\u3088\u3044\u304b\u3082\u3002<\/p>\n<h2>\u304a\u307e\u3051\uff1a\u30b3\u30f3\u30c6\u30ca\u30a4\u30e1\u30fc\u30b8\u3092\u5909\u66f4\u3059\u308b<\/h2>\n<p>nginx:latest \u304b\u3089 nginx:stable \u306b\u5909\u66f4\u3057\u305f\u3068\u3053\u308d\u30012\u3064\u30b3\u30f3\u30c6\u30ca\u3092\u8ffd\u52a0\u3057\u305f\u306e\u3061\u306b\u65e2\u5b58\u306e2\u3064\u306e\u30b3\u30f3\u30c6\u30ca\u304c\u524a\u9664\u3055\u308c\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3057\u305f\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n$ .\/fargatecli service deploy nginx-service --cluster nginx-cluster --image nginx:stable\r\n&#x5B;i] Deployed nginx:latest to service nginx-service\r\n<\/pre>\n<p><a href=\"https:\/\/tech.akat.info\/wp-content\/uploads\/2021\/01\/2021-01-03_003318.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/tech.akat.info\/wp-content\/uploads\/2021\/01\/2021-01-03_003318-300x188.jpg\" alt=\"\" width=\"300\" height=\"188\" class=\"alignnone size-medium wp-image-3887\" srcset=\"https:\/\/tech.akat.info\/wp-content\/uploads\/2021\/01\/2021-01-03_003318-300x188.jpg 300w, https:\/\/tech.akat.info\/wp-content\/uploads\/2021\/01\/2021-01-03_003318-1024x642.jpg 1024w, https:\/\/tech.akat.info\/wp-content\/uploads\/2021\/01\/2021-01-03_003318-768x481.jpg 768w, https:\/\/tech.akat.info\/wp-content\/uploads\/2021\/01\/2021-01-03_003318-1536x963.jpg 1536w, https:\/\/tech.akat.info\/wp-content\/uploads\/2021\/01\/2021-01-03_003318-2048x1284.jpg 2048w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>fargatecli \u3067\u30b3\u30f3\u30c6\u30ca\u3092\u7acb\u3066\u308b\u3092\u53c2\u8003\u306b\u3001AWS CloudShell\u306b\u3066fargatecli\u3092\u4f7f\u3063\u3066\u30b3\u30f3\u30c6\u30ca\u3092\u69cb\u7bc9\u3057\u3066\u307f\u305f\u3002 VPC\u306e\u4f5c\u6210 \u5fc5\u8981\u306a\u6642\u3060\u3051NAT Gateway\u3092\u4f5c\u6210\u3059\u308b\u65b9\u6cd5\u3092\u53c2\u8003\u306bVPC\u3092\u7528\u610f\u3059 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[27,72],"tags":[],"_links":{"self":[{"href":"https:\/\/tech.akat.info\/index.php?rest_route=\/wp\/v2\/posts\/3885"}],"collection":[{"href":"https:\/\/tech.akat.info\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tech.akat.info\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tech.akat.info\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tech.akat.info\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3885"}],"version-history":[{"count":1,"href":"https:\/\/tech.akat.info\/index.php?rest_route=\/wp\/v2\/posts\/3885\/revisions"}],"predecessor-version":[{"id":3888,"href":"https:\/\/tech.akat.info\/index.php?rest_route=\/wp\/v2\/posts\/3885\/revisions\/3888"}],"wp:attachment":[{"href":"https:\/\/tech.akat.info\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3885"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tech.akat.info\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3885"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tech.akat.info\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3885"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}