{"id":7643,"date":"2022-12-27T12:06:39","date_gmt":"2022-12-27T03:06:39","guid":{"rendered":"https:\/\/www.clara.jp\/media\/?p=7643"},"modified":"2025-10-09T15:16:06","modified_gmt":"2025-10-09T06:16:06","slug":"aws-ec2%e3%81%ae%e3%83%87%e3%83%97%e3%83%ad%e3%82%a4%e3%82%92%e6%96%b9%e6%b3%95%e5%88%a5%e3%81%a7%e6%af%94%e8%bc%83%e3%80%82%e6%9c%80%e9%80%9f%e3%81%ae%e3%83%87%e3%83%97%e3%83%ad%e3%82%a4%e6%96%b9","status":"publish","type":"post","link":"https:\/\/ci.clara.jp\/media\/?p=7643","title":{"rendered":"AWS EC2\u306e\u30c7\u30d7\u30ed\u30a4\u3092\u65b9\u6cd5\u5225\u3067\u6bd4\u8f03\u3002\u6700\u901f\u306e\u30c7\u30d7\u30ed\u30a4\u65b9\u6cd5\u306f\u3069\u308c\uff1f"},"content":{"rendered":"\n<p>\u3053\u3093\u306b\u3061\u306f\u3001\u30af\u30e9\u30e9TAM\u306e\u77f3\u5ddd\u3067\u3059\uff01<\/p>\n\n\n\n<p>AWS\uff08Amazon Web Service\uff09\u306fElastic Compute Cloud\uff08EC2\uff09\u3068\u3044\u3046\u30b5\u30fc\u30d3\u30b9\u3067Virtual Machine\uff08VM\uff09\u3092\u63d0\u4f9b\u3057\u3066\u3044\u307e\u3059\u306d\u3002<\/p>\n\n\n\n<p>\u305d\u3057\u3066\u3001AWS\u3067\u306fEC2\u3092\u8907\u6570\u306e\u65b9\u6cd5\u3067\u30c7\u30d7\u30ed\u30a4\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u4eca\u56de\u306f\u3001\u3044\u304f\u3064\u304b\u3042\u308bEC2\u306e\u30c7\u30d7\u30ed\u30a4\u306b\u3064\u3044\u3066\u3001\u3069\u306e\u624b\u6bb5\u304c\u4e00\u756a\u65e9\u304fEC2\u3092\u69cb\u7bc9\u3067\u304d\u308b\u306e\u304b\u3001\u305d\u308c\u305e\u308c\u306e\u30e1\u30ea\u30c3\u30c8\u30fb\u30c7\u30e1\u30ea\u30c3\u30c8\u306f\u4f55\u304b\u3092\u6bd4\u8f03\u30fb\u7e8f\u3081\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n\n\n\n\n\n\n\n<h2 class=\"wp-block-heading\">\u4eca\u56de\u6bd4\u8f03\u3059\u308bEC2\u306e\u30c7\u30d7\u30ed\u30a4\u65b9\u6cd5\u3068\u8981\u4ef6<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">\u4eca\u56de\u5229\u7528\u3059\u308b\u30c7\u30d7\u30ed\u30a4\u65b9\u6cd5\u306f\u4ee5\u4e0b<\/h3>\n\n\n\n<p>\u30fb\u30b3\u30f3\u30c8\u30ed\u30fc\u30eb\u30d1\u30cd\u30eb\u3067\u306e\u64cd\u4f5c<br>\u30fbAWS CLI(CloudShell)\u3067\u306e\u64cd\u4f5c<br>\u30fbCloudFormation\u306e\u64cd\u4f5c<\/p>\n\n\n\n<p>\u307e\u305f\u3001\u5171\u901a\u306e\u7d50\u679c\u3068\u3057\u3066\u3001EIP\u3092\u4ed8\u4e0e\u3057\u3066\u3001Nginx\u306e\u30c7\u30d5\u30a9\u30eb\u30c8\u30da\u30fc\u30b8\u304c\u8868\u793a\u3055\u308c\u308b\u3053\u3068\u304c\u78ba\u8a8d\u3067\u304d\u308b\u72b6\u614b\u307e\u3067\u8a2d\u5b9a\u3001\u3068\u3057\u307e\u3059\u3002<\/p>\n\n\n\n\n\n\n\n<h3 class=\"wp-block-heading\">\u4eca\u56de\u306e\u8981\u4ef6\u306f\u3053\u3061\u3089<\/h3>\n\n\n\n<p>OS\uff1aAmazon Linux 2 AMI (HVM) &#8211; Kernel 5.10, SSD Volume Type<br>\u203bami-0f7691f59fd7c47af (64 \u30d3\u30c3\u30c8 Arm)<\/p>\n\n\n\n<p>\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u30bf\u30a4\u30d7\uff1at4g.micro(2vCPU\u30011GiB)<\/p>\n\n\n\n<p>\u30c7\u30a3\u30b9\u30af\u30b5\u30a4\u30ba\uff1a8GB(default)<\/p>\n\n\n\n<p>SecurityGroup\uff1a80<br>\uff08\u203b\u30e1\u30a4\u30f3\u8981\u4ef6\u3067\u306f\u306a\u3044\u306e\u3067\u2026\uff09<\/p>\n\n\n\n\n\n\n\n<h2 class=\"wp-block-heading\">GUI\u30c7\u30d7\u30ed\u30a4<\/h2>\n\n\n\n<p>AWS\u30de\u30cd\u30b8\u30e1\u30f3\u30c8\u30b3\u30f3\u30bd\u30fc\u30eb\u304b\u3089\u8a08\u6e2c\u30b9\u30bf\u30fc\u30c8<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Amazon\u30de\u30b7\u30f3\u30a4\u30e1\u30fc\u30b8\uff08AMI\uff09<\/li>\n\n\n\n<li>\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u30bf\u30a4\u30d7\u306e\u9078\u629e<\/li>\n\n\n\n<li>\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306e\u8a73\u7d30\u306e\u8a2d\u5b9a<\/li>\n\n\n\n<li>\u30b9\u30c8\u30ec\u30fc\u30b8\u306e\u8ffd\u52a0<\/li>\n\n\n\n<li>\u30bf\u30b0\u306e\u8ffd\u52a0<\/li>\n\n\n\n<li>\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u30b0\u30eb\u30fc\u30d7\u306e\u8a2d\u5b9a<\/li>\n\n\n\n<li>\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u4f5c\u6210\u306e\u78ba\u8a8d<\/li>\n\n\n\n<li>\u7d30\u304b\u3044\u3068\u3053\u308d\u306fSSH\u3067\u8abf\u6574<\/li>\n<\/ol>\n\n\n\n<p><iframe width=\"620\" height=\"405\" style=\"border: 1px solid #ccc; display: block; margin: 0px auto; padding: 0px; aspect-ratio: 620\/405;\" src=\"https:\/\/drive.google.com\/file\/d\/1m4GqCO3W1PCMH2jfM5QAG-GQt7L4V638\/preview\" allow=\"autoplay\"><span data-mce-type=\"bookmark\" style=\"display: inline-block; width: 0px; overflow: hidden; line-height: 0;\" class=\"mce_SELRES_start\">\ufeff<\/span><\/iframe><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">GUI\u30c7\u30d7\u30ed\u30a4\u306b\u304b\u304b\u3063\u305f\u6642\u9593<\/h3>\n\n\n\n<p><strong>\u5927\u4f53\u30fb\u30fb\u30fb30\u5206\u3050\u3089\u3044\u3002<\/strong><br>PC\u524d\u3067\u5f35\u3063\u3066\u308c\u307010\u5206\u3002<\/p>\n\n\n\n<p>GUI\u64cd\u4f5c\uff1a2\u5206<br>\u5f85\u3061\u3000\u3000\uff1a3\u5206<br>SSH\u64cd\u4f5c\uff1a5\u5206\u3000\u2192\u69cb\u7bc9\u6642\u306b\u30e6\u30fc\u30b6\u30c7\u30fc\u30bf\u3068\u3057\u3066\u8a18\u8f09\u53ef\u80fd\u3002\u305d\u306e\u5834\u5408\u306f0\u5206\u306b\u3002<\/p>\n\n\n\n\n\n\n\n<h2 class=\"wp-block-heading\">AWS \u30b3\u30de\u30f3\u30c9\u30e9\u30a4\u30f3\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30a4\u30b9\uff08CLI\uff09\u30c7\u30d7\u30ed\u30a4<\/h2>\n\n\n\n<pre class=\"wp-block-preformatted\">aws ec2 create-security-group \\\n--group-name deploy-cli \\\n--description \"My security group\" \\\n--vpc-id vpc-6a3b310e\naws ec2 authorize-security-group-ingress \\\n--group-id &lt;\u4e0a\u8a18\u306eSGID&gt; \\\n--protocol tcp \\\n--port 80 \\\n--cidr 0.0.0.0\/0\naws ec2 authorize-security-group-ingress \\\n--group-id &lt;\u4e0a\u8a18\u306eSGID&gt; \\\n--protocol tcp \\\n--port 22 \\\n--cidr 0.0.0.0\/0\naws ec2 create-key-pair \\\n--key-name ishikawa-deploy-cli \\\n--output text\naws ec2 run-instances \\\n--image-id ami-0f7691f59fd7c47af \\\n--count 1 \\\n--instance-type t4g.micro \\\n--key-name ishikawa-deploy-cli \\\n--security-group-ids &lt;\u4e0a\u8a18\u306eSGID&gt; \\\n--subnet-id subnet-989aecee<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">CLI\u30c7\u30d7\u30ed\u30a4\u306b\u304b\u304b\u3063\u305f\u6642\u9593<\/h3>\n\n\n\n<p><strong>\u5927\u4f53\u30fb\u30fb\u30fb30\u5206\u3050\u3089\u3044<\/strong><\/p>\n\n\n\n<p>CLI\u4f5c\u6210\uff1a10\u5206<br>CLI\u64cd\u4f5c\uff1a10\u5206<br>\u5f85\u3061\u3000\u3000\uff1a3\u5206<br>SSH\u64cd\u4f5c\uff1a5\u5206<\/p>\n\n\n\n\n\n\n\n<h2 class=\"wp-block-heading\">AWS CloudFormation\uff08CFn\uff09\u30c7\u30d7\u30ed\u30a4<\/h2>\n\n\n\n<pre class=\"wp-block-preformatted\">Parameters:\nKeyName:\nDescription: The EC2 Key Pair to allow SSH access to the instance\nType: \"AWS::EC2::KeyPair::KeyName\"\n\nVPCID:\nType: String\nDefault: \"vpc-6a3b310e\"\n\nSubnetID01:\nType: String\nDefault: \"subnet-989aecee\"\n\nResources:\nDEPLOYSG01:\nType: AWS::EC2::SecurityGroup\nProperties:\nGroupName: deploy-CFn\nGroupDescription: Allow SSH and HTTP access only MyIP\nVpcId: !Ref VPCID\nSecurityGroupIngress:\n# http\n- IpProtocol: tcp\nFromPort: 80\nToPort: 80\nCidrIp: \"0.0.0.0\/0\"\n# ssh\n- IpProtocol: tcp\nFromPort: 22\nToPort: 22\nCidrIp: \"0.0.0.0\/0\"\nDEPLOYEC2:\nType: AWS::EC2::Instance\nProperties:\nImageId: ami-0f7691f59fd7c47af\nKeyName: !Ref KeyName\nInstanceType: t4g.micro\nNetworkInterfaces:\n- AssociatePublicIpAddress: \"true\"\nDeviceIndex: \"0\"\nSubnetId: !Ref SubnetID01\nGroupSet:\n- !Ref DEPLOYSG01\nUserData: !Base64 |\n#!\/bin\/bash\nsudo yum update -y\nsudo amazon-linux-extras\nsudo amazon-linux-extras install nginx1 -y\nsudo systemctl enable nginx\nsudo systemctl start nginx\nTags:\n- Key: Name\nValue: deploy-CFn<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">CFn\u30c7\u30d7\u30ed\u30a4\u306b\u304b\u304b\u3063\u305f\u6642\u9593<\/h3>\n\n\n\n<p><strong>\u5927\u4f53\u30fb\u30fb\u30fb15\u5206\u3050\u3089\u3044<\/strong><\/p>\n\n\n\n<p>yaml\u4f5c\u6210\uff1a10\u5206<br>(AWS\u304c)\u69cb\u7bc9\uff1a2\u5206<br>\u5f85\u3061\u3000\u3000\uff1a3\u5206<br>SSH\u64cd\u4f5c\uff1a0\u5206<\/p>\n\n\n\n\n\n\n\n<h2 class=\"wp-block-heading\">\u307e\u3068\u3081\u30fb\u6bd4\u8f03\u8868<\/h2>\n\n\n\n\n\n\n\n<figure class=\"wp-block-table  aligncenter\"><table class=\"has-fixed-layout\"><tbody><tr><th><\/th><th><strong>GUI<\/strong><\/th><th><strong>CLI<\/strong><\/th><th><strong>CFn<\/strong><\/th><\/tr><tr><th><strong>\u4e8b\u524d\u6e96\u5099<\/strong><\/th><td><span style=\"font-weight: 400;\">\u7279\u306b\u306a\u3057\u25ce<\/span><\/td><td><span style=\"font-weight: 400;\">\u5341\u5206\u6642\u9593\u304c\u5fc5\u8981<\/span>\n<p><span style=\"font-weight: 400;\">\u30fb\u30b3\u30de\u30f3\u30c9\u30aa\u30d7\u30b7\u30e7\u30f3<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u30fb\u4e8b\u524d\u306b\u4f55\u304c\u5fc5\u8981\u306a\u306e\u304b<\/span><\/p>\n<\/td><td><span style=\"font-weight: 400;\">\u5341\u5206\u6642\u9593\u304c\u5fc5\u8981<\/span>\n<p><span style=\"font-weight: 400;\">\u30fbYaml\u4f5c\u6210<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u30fbCFn\u306b\u5bfe\u5fdc\u3057\u3066\u3044\u306a\u3044\u3082\u306e\u306e\u4f5c\u6210<\/span><\/p>\n<\/td><\/tr><tr><th><strong>\u69cb\u7bc9\u4e2d\u306e\u624b\u96e2\u308c<\/strong><\/th><td><span style=\"font-weight: 400;\">\u60aa\u3044&#x2716;<\/span>\n<p><span style=\"font-weight: 400;\">\u69cb\u7bc9\u4e2d\u306f\u9010\u4e00\u6c17\u306b\u304b\u3051\u308b<\/span><\/p>\n<\/td><td><span style=\"font-weight: 400;\">\u826f\u3044\u25ce<\/span>\n<p><span style=\"font-weight: 400;\">\u30b3\u30de\u30f3\u30c9\u3054\u3068\u306b\u78ba\u8a8d\u304c\u5fc5\u8981\u3060\u304c\u3001\u30b7\u30a7\u30eb\u5316\u7b49\u306b\u3088\u308a\u5bfe\u5fdc\u53ef\u80fd<\/span><\/p>\n<\/td><td><span style=\"font-weight: 400;\">\u826f\u3044\u25ce<\/span>\n<p><span style=\"font-weight: 400;\">yaml\u306b\u69cb\u7bc9\u60c5\u5831\u304c\u4e57\u3063\u3066\u3044\u308b\u306e\u3067\u3001\u5206\u5272\u306e\u7a0b\u5ea6\u306b\u3088\u308a\u653e\u7f6e\u3067\u3082\u3088\u3044<\/span><\/p>\n<\/td><\/tr><tr><th><strong>\u64cd\u4f5c\u306e\u3057\u3084\u3059\u3055<\/strong><\/th><td><span style=\"font-weight: 400;\">\u65ad\u7136\u826f\u3044\u25ce<\/span><\/td><td><span style=\"font-weight: 400;\">\u60aa\u3044&#x2716;<\/span>\n<p><span style=\"font-weight: 400;\">\u30aa\u30d7\u30b7\u30e7\u30f3\u3092\u8abf\u3079\u308b\u306e\u306b\u6642\u9593\u304c\u304b\u304b\u308b<\/span><\/p>\n<\/td><td><span style=\"font-weight: 400;\">\u304b\u306a\u308a\u60aa\u3044&#x2716;<\/span>\n<p><span style=\"font-weight: 400;\">yaml\u306b\u7279\u5316\u3057\u305f\u3082\u306e\u3092\u4f5c\u308b\u5fc5\u8981\u304c\u3042\u308b\u3002\u5bfe\u5fdc\u3057\u3066\u3044\u306a\u3044\u30b5\u30fc\u30d3\u30b9\u3082\u3042\u308b\u3002<\/span><\/p>\n<\/td><\/tr><tr><th><strong>\u74b0\u5883\u518d\u73fe\u6027<\/strong><\/th><td><span style=\"font-weight: 400;\">\u96e3\u3057\u3044&#x2716;<\/span>\n<p><span style=\"font-weight: 400;\">\u624b\u9806\u66f8\u304c\u7121\u3044\u3068\u53b3\u3057\u3044\u304c\u3001\u30e6\u30fc\u30b6IF\u306f\u983b\u7e41\u306b\u5909\u308f\u308b\u305f\u3081\u3001\u4f5c\u308a\u304d\u308a\u306e\u624b\u9806\u3067\u306f\u5f8c\u3005\u3067\u53b3\u3057\u305d\u3046<\/span><\/p>\n<\/td><td><span style=\"font-weight: 400;\">\u3042\u308a\u25ce<\/span>\n<p><span style=\"font-weight: 400;\">\u540c\u3058\u30b3\u30de\u30f3\u30c9\u3092\u6d41\u305b\u3070\u540c\u3058\u3082\u306e\u304c\u3067\u304d\u308b\u3002\u30b3\u30de\u30f3\u30c9\u306f\u983b\u7e41\u306b\u5909\u66f4\u304c\u5165\u3089\u306a\u3044\u3002<\/span><\/p>\n<\/td><td><span style=\"font-weight: 400;\">\u3042\u308a\u25ce<\/span><\/td><\/tr><tr><th><strong>\u524a\u9664<\/strong><\/th><td><span style=\"font-weight: 400;\">\u81ea\u52d5\u3067\u4f5c\u6210\u3055\u308c\u308b\u3082\u306e\u3082\u3042\u308a\u3001\u3069\u308c\u304c\u6d88\u3057\u3066\u3044\u3044\u3082\u306e\u304b\u304c\u308f\u304b\u3089\u306a\u304f\u306a\u308b\u3002<\/span><\/td><td><span style=\"font-weight: 400;\">\u4f5c\u3063\u305f\u3082\u306e\u304c\u3069\u308c\u304b\u308f\u304b\u3089\u306a\u3044\u3002\u304c\u3001\u4f5c\u6210\u6642\u306b\u30bf\u30b0\u3092\u4ed8\u4e0e\u3059\u308b\u7b49\u3067\u5bfe\u5fdc\u53ef\u80fd\u3002<\/span><\/td><td><span style=\"font-weight: 400;\">\u4f5c\u3063\u305f\u3082\u306e\u304c\u304d\u308c\u3044\u306b\u6d88\u3048\u308b\u3002\u25ce<\/span><\/td><\/tr><tr><th><strong>\u3053\u3093\u306a\u3068\u3053\u308d\u306b\u4f7f\u3046\u306e\u304c\u304a\u3059\u3059\u3081<\/strong><\/th><td><span style=\"font-weight: 400;\">\u8a66\u9a13\u7684\u69cb\u7bc9<\/span><\/td><td><span style=\"font-weight: 400;\">\u5909\u66f4\u304c\u983b\u7e41\u306b\u304b\u304b\u308b\u304c\u5c65\u6b74\u3092\u3068\u3063\u3066\u304a\u304d\u305f\u3044\u74b0\u5883<\/span><\/td><td><span style=\"font-weight: 400;\">\u30a4\u30f3\u30d5\u30e9\u69cb\u7bc9\u306e\u81ea\u52d5\u5316\u3082\u8996\u91ce\u306b\u5165\u308c\u305f\u74b0\u5883<\/span><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n\n\n\n\n\n\n\n\n<p>\u4ee5\u4e0a\u3001\u4eca\u56de\u306f\u65b9\u6cd5\u5225\u306eEC2\u30c7\u30d7\u30ed\u30a4\u6642\u9593\u30fb\u30e1\u30ea\u30c3\u30c8\u30fb\u30c7\u30e1\u30ea\u30c3\u30c8\u3092\u691c\u8a3c\u3057\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3053\u3093\u306b\u3061\u306f\u3001\u30af\u30e9\u30e9TAM\u306e\u77f3\u5ddd\u3067\u3059\uff01 AWS\uff08Amazon Web Service\uff09\u306fElastic Compute Cloud\uff08EC2\uff09\u3068\u3044\u3046\u30b5\u30fc\u30d3\u30b9\u3067Virtual Machine\uff08VM\uff09\u3092\u63d0\u4f9b\u3057\u3066\u3044\u307e\u3059\u306d\u3002 \u305d\u3057\u3066 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":7649,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"swell_btn_cv_data":"","footnotes":""},"categories":[63,21],"tags":[14,73,104,74,108,75],"class_list":["post-7643","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-aws","category-techblog","tag-aws","tag-ec2","tag-base","tag-74","tag-techblog","tag-75"],"_links":{"self":[{"href":"https:\/\/ci.clara.jp\/media\/index.php?rest_route=\/wp\/v2\/posts\/7643","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ci.clara.jp\/media\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ci.clara.jp\/media\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ci.clara.jp\/media\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ci.clara.jp\/media\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=7643"}],"version-history":[{"count":2,"href":"https:\/\/ci.clara.jp\/media\/index.php?rest_route=\/wp\/v2\/posts\/7643\/revisions"}],"predecessor-version":[{"id":11214,"href":"https:\/\/ci.clara.jp\/media\/index.php?rest_route=\/wp\/v2\/posts\/7643\/revisions\/11214"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ci.clara.jp\/media\/index.php?rest_route=\/wp\/v2\/media\/7649"}],"wp:attachment":[{"href":"https:\/\/ci.clara.jp\/media\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=7643"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ci.clara.jp\/media\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=7643"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ci.clara.jp\/media\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=7643"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}