{"id":18835,"date":"2022-05-13T18:30:09","date_gmt":"2022-05-13T09:30:09","guid":{"rendered":"https:\/\/itport.cloud\/?p=18835"},"modified":"2022-05-13T18:30:10","modified_gmt":"2022-05-13T09:30:10","slug":"post-18835","status":"publish","type":"post","link":"https:\/\/itport.cloud\/?p=18835","title":{"rendered":"\uff08\u7b2c1\u56de\uff09Terraform\u3067AWS\u4e0a\u306bWeb\u30b5\u30fc\u30d0\u30fc\u3092\u69cb\u7bc9\u3059\u308b"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\" id=\"0\">\u76ee\u6b21<\/h2>\n\n\n\n<p><a href=\"#1\" data-type=\"internal\" data-id=\"#1\">\u306f\u3058\u3081\u306b<\/a><br><a href=\"#2\" data-type=\"internal\" data-id=\"#2\">\u69cb\u6210\u56f3<\/a><br><a href=\"#3\" data-type=\"internal\" data-id=\"#3\">Terraform\u30d5\u30a1\u30a4\u30eb\u69cb\u6210<\/a><br>\u3000- <a href=\"#3-1\" data-type=\"internal\" data-id=\"#3-1\">terraform.tf<\/a><br>\u3000- <a href=\"#3-2\" data-type=\"internal\" data-id=\"#3-2\">provider.tf<\/a><br><a href=\"#4\" data-type=\"internal\" data-id=\"#4\">VPC\u95a2\u9023\u306e\u5b9a\u7fa9<\/a><br>\u3000- <a href=\"#4-1\" data-type=\"internal\" data-id=\"#4-1\">variables.tf<\/a><br>\u3000- <a href=\"#4-2\" data-type=\"internal\" data-id=\"#4-2\">vpc.tf<\/a><br><a href=\"#5\" data-type=\"internal\" data-id=\"#5\">AWS\u30de\u30cd\u30b8\u30e1\u30f3\u30c8\u30b3\u30f3\u30bd\u30fc\u30eb\u4e0a\u3067\u306e\u4f5c\u696d<\/a><br><a href=\"#6\" data-type=\"internal\" data-id=\"#6\">\u6b21\u56de\u4e88\u544a<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"1\">\u306f\u3058\u3081\u306b<\/h2>\n\n\n\n<p>\u4ee5\u524d\u306bAWS CloudFormation\u3092\u4f7f\u7528\u3057\u3066VPC\u306e\u69cb\u7bc9\u3084Amazon EC2\u3001Amazon S3\u306e\u69cb\u7bc9\u691c\u8a3c\u3092\u3054\u7d39\u4ecb\u3044\u305f\u3057\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-wp-embed is-provider-it-port wp-block-embed-it-port\"><div class=\"wp-block-embed__wrapper\">\n<blockquote class=\"wp-embedded-content\" data-secret=\"2o1EYUzJ7t\"><a href=\"https:\/\/itport.cloud\/?p=13493\">(\u7b2c1\u56de)CloudFormation\u3067\u74b0\u5883\u69cb\u7bc9\u3092\u52b9\u7387\u5316<\/a><\/blockquote><iframe loading=\"lazy\" class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; visibility: hidden;\" title=\"&#8220;(\u7b2c1\u56de)CloudFormation\u3067\u74b0\u5883\u69cb\u7bc9\u3092\u52b9\u7387\u5316&#8221; &#8212; IT PORT\" src=\"https:\/\/itport.cloud\/?p=13493&#038;embed=true#?secret=wQSUnOjzq3#?secret=2o1EYUzJ7t\" data-secret=\"2o1EYUzJ7t\" width=\"600\" height=\"338\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe>\n<\/div><\/figure>\n\n\n\n<p>\u4eca\u56de\u306fTerraform\u3092\u4f7f\u7528\u3057\u3066AWS\u4e0a\u306bWeb\u30b5\u30fc\u30d0\u30fc\u306e\u69cb\u7bc9\u307e\u3067\u884c\u3044\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<br>Terraform\u3067\u69cb\u7bc9\u3059\u308bAWS\u306e\u69cb\u6210\u3092\u8a18\u8f09\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"2\">\u69cb\u6210\u56f3<\/h2>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"603\" src=\"https:\/\/itport.cloud\/wp-content\/uploads\/2022\/05\/itport_aws-all.drawio-1024x603.png\" alt=\"\" class=\"wp-image-18943\" srcset=\"https:\/\/itport.cloud\/wp-content\/uploads\/2022\/05\/itport_aws-all.drawio-1024x603.png 1024w, https:\/\/itport.cloud\/wp-content\/uploads\/2022\/05\/itport_aws-all.drawio-300x177.png 300w, https:\/\/itport.cloud\/wp-content\/uploads\/2022\/05\/itport_aws-all.drawio-768x452.png 768w, https:\/\/itport.cloud\/wp-content\/uploads\/2022\/05\/itport_aws-all.drawio-1536x904.png 1536w, https:\/\/itport.cloud\/wp-content\/uploads\/2022\/05\/itport_aws-all.drawio-2048x1206.png 2048w, https:\/\/itport.cloud\/wp-content\/uploads\/2022\/05\/itport_aws-all.drawio-450x265.png 450w, https:\/\/itport.cloud\/wp-content\/uploads\/2022\/05\/itport_aws-all.drawio-900x530.png 900w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure><\/div>\n\n\n\n<p>Application Load Balancer\u3092\u4f7f\u7528\u3057\u3066\u3001Web\u30b5\u30fc\u30d0\u30fc\u306f\u30d7\u30e9\u30a4\u30d9\u30fc\u30c8\u30b5\u30d6\u30cd\u30c3\u30c8\u306b\u914d\u7f6e\u3057\u307e\u3059\u3002<br>VPN\u7b49\u306e\u7528\u610f\u304c\u7121\u3044\u3068\u901a\u5e38\u306f\u30d7\u30e9\u30a4\u30d9\u30fc\u30c8\u30b5\u30d6\u30cd\u30c3\u30c8\u306b\u914d\u7f6e\u3057\u305fEC2\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3078\u306fssh\u63a5\u7d9a\u304c\u51fa\u6765\u306a\u3044\u306e\u3067\u3059\u304c\u3001\u5b9f\u7528\u3092\u8003\u616e\u3057\u3066SSM\u306eSession Manager\u3067EC2\u3078\u30ed\u30fc\u30ab\u30eb\u304b\u3089\u63a5\u7d9a\u304c\u51fa\u6765\u308b\u3088\u3046\u306bIAM Policy\u306e\u8a2d\u5b9a\u3082Terraform\u3067\u5f8c\u307b\u3069\u66f8\u304f\u4e88\u5b9a\u3067\u3059\u3002\u305d\u308c\u3067\u306f\u3001Terraform\u306e\u30d5\u30a1\u30a4\u30eb\u69cb\u6210\u3092\u8a18\u8f09\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"3\">Terraform\u30d5\u30a1\u30a4\u30eb\u69cb\u6210<\/h2>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; gutter: false; title: ; notranslate\" title=\"\">\nterraform\/\n\u251c\u2500vars\/\n\u2502  \u2514\u2500terraform.tfvars\n\u251c\u2500acm.tf\n\u251c\u2500ec2.tf\n\u251c\u2500elb.tf\n\u251c\u2500iam.tf\n\u251c\u2500provider.tf\n\u251c\u2500route53.tf\n\u251c\u2500securitygroup.tf\n\u251c\u2500terraform.tf\n\u251c\u2500variables.tf\n\u2514\u2500vpc.tf\n<\/pre><\/div>\n\n\n<p>\u8907\u6570\u306eAWS\u30b5\u30fc\u30d3\u30b9\u3092Terraform\u3067\u69cb\u7bc9\u3092\u3057\u3066\u3044\u304d\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u306e\u3067\u3001\u4f55\u56de\u304b\u306b\u8a18\u4e8b\u3092\u5206\u3051\u3066\u8a18\u8f09\u3055\u305b\u3066\u3044\u305f\u3060\u304d\u307e\u3059\u306e\u3067\u3001\u4e88\u3081\u3054\u4e86\u627f\u304f\u3060\u3055\u3044\u3002\u307e\u305a\u306f\u57fa\u672c\u8a2d\u5b9a\u3068\u306a\u308b\u300cterraform.tf\u300d\u3092\u66f8\u3044\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<h5 class=\"wp-block-heading\" id=\"3-1\">terraform.tf<\/h5>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; auto-links: false; highlight: [6,8]; title: ; notranslate\" title=\"\">\nterraform {\n  required_version = \"~> 1.1\"\n\n  backend \"s3\" {\n    region  = \"ap-northeast-1\"\n    bucket  = \"itport-terraform-state\"\n    key     = \"terraform.tfstate\"\n    profile = \"itport\"\n  }\n}\n<\/pre><\/div>\n\n\n<p>Terraform\u3067\u306f\u30ea\u30bd\u30fc\u30b9\u306e\u4f5c\u6210\u3092\u3059\u308b\u3068\u30b9\u30c6\u30fc\u30bf\u30b9\u3092\u7ba1\u7406\u3059\u308b\u30d5\u30a1\u30a4\u30eb\u300c.tfstate\u300d\u30d5\u30a1\u30a4\u30eb\u304c\u751f\u6210\u3055\u308c\u307e\u3059\u304c\u3001Git\u7b49\u3067\u3053\u306e\u30d5\u30a1\u30a4\u30eb\u304c\u5206\u6563\u3055\u308c\u308b\u3068\u4e0d\u6574\u5408\u304c\u767a\u751f\u3059\u308b\u305f\u3081\u3001\u30d0\u30c3\u30af\u30a8\u30f3\u30c9\u3068\u3044\u3046\u4ed5\u7d44\u307f\u3067state\u30d5\u30a1\u30a4\u30eb\u3092\u4e00\u8cab\u3057\u305f\u5834\u6240\u3067\u7ba1\u7406\u3067\u304d\u308b\u3088\u3046\u306b\u4e0a\u8a18\u306e\u3088\u3046\u306a\u66f8\u304d\u65b9\u3067\u5b9a\u7fa9\u304c\u3067\u304d\u307e\u3059\u3002\u30d0\u30c3\u30af\u30a8\u30f3\u30c9\u306fAmazon S3\u3092\u30b5\u30dd\u30fc\u30c8\u3057\u3066\u3044\u308b\u306e\u3067\u3001\u4eca\u56de\u306fAmazon S3\u306bterraform.tfstate\u3092\u914d\u7f6e\u3059\u308b\u3088\u3046\u306b\u66f8\u3044\u3066\u304a\u308a\u307e\u3059\u30026\u884c\u76ee\u30688\u884c\u76ee\u306f\u9069\u5b9c\u5909\u66f4\u304f\u3060\u3055\u3044\u3002bucket\u306f\u30d0\u30b1\u30c3\u30c8\u540d\u3001profile\u306f\u81ea\u8eab\u306e\u30ed\u30fc\u30ab\u30eb\u306ecredentials\u306b\u8a2d\u5b9a\u3057\u305fprofile\u306e\u540d\u524d\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h5 class=\"wp-block-heading\" id=\"aws-credentialse381aee4be8b-1\"> ~\/.aws\/credentials\u306e\u4f8b<\/h5>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; gutter: false; title: ; notranslate\" title=\"\">\n&#x5B;itport]\naws_access_key_id = &lt;YOUR_AWS_ACCESS_KEY>\naws_secret_access_key = &lt;YOUR_AWS_SECRET_ACCESS_KEY>\n<\/pre><\/div>\n\n\n<p><br>\u30d0\u30c3\u30af\u30a8\u30f3\u30c9\u3068\u306a\u308bAmazon S3\u306e\u30d0\u30b1\u30c3\u30c8\u3092\u307e\u305a\u306f\u4e8b\u524d\u306b\u4f5c\u6210\u3057\u3066\u304a\u304f\u5fc5\u8981\u304c\u3042\u308b\u305f\u3081AWS-CLI\u3067\u30d0\u30b1\u30c3\u30c8\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; gutter: false; title: ; notranslate\" title=\"\">\naws s3api --profile itport create-bucket --acl private --bucket itport-terraform-state --create-bucket-configuration LocationConstraint=ap-northeast-1\n<\/pre><\/div>\n\n\n<p>\u6b21\u306bAWS\u3068\u3057\u3066Terraform\u3092\u5b9a\u7fa9\u3057\u3066\u3044\u304f\u305f\u3081\u306bprovider\u3092\u5b9a\u7fa9\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h5 class=\"wp-block-heading\" id=\"3-2\">provider.tf<\/h5>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; highlight: [2,5,6,7,8,9,10,11]; title: ; notranslate\" title=\"\">\nprovider \"aws\" {\n  profile = var.profile\n  region  = var.region\n  \n  default_tags {\n    tags = {\n      Terraform      = var.tag_terraform\n      Env            = var.env\n      SystemName     = var.tag_system_name\n    }\n  }\n}\n<\/pre><\/div>\n\n\n<p>\u4e0a\u8a18providier.tf\u5185\u306eprofile\u30d7\u30ed\u30d1\u30c6\u30a3\u306f\u5909\u6570\u304b\u3089profile\u540d\u3092\u53d6\u5f97\u3059\u308b\u3088\u3046\u306b\u3057\u3066\u3044\u307e\u3059\u3002\u305d\u3057\u3066default_tags\u306fTerraform\u3067\u4f5c\u6210\u3055\u308c\u308b\u30ea\u30bd\u30fc\u30b9\u5168\u3066\u306b\u30c7\u30d5\u30a9\u30eb\u30c8\u3067\u8a2d\u5b9a\u3059\u308b\u30bf\u30b0\u304c\u5b9a\u7fa9\u3067\u304d\u307e\u3059\u3002\u3053\u308c\u3082\u5909\u6570\u304b\u3089\u5024\u3092\u5165\u308c\u308b\u3088\u3046\u306b\u3057\u3066\u304a\u308a\u3001\u5909\u6570\u306e\u5024\u306fterraform apply\u6642\u306b\u76f4\u63a5\u6307\u5b9a\u3059\u308b\u304b\u3001.tfvars\u30d5\u30a1\u30a4\u30eb\u3067\u5909\u6570\u306e\u5024\u3092\u66f8\u3044\u3066\u3044\u304d\u307e\u3059\u3002apply\u6642\u306b\u6bce\u56de\u5909\u6570\u3092\u66f8\u304f\u306e\u306f\u5927\u5909\u306a\u306e\u3067\u5f8c\u307b\u3069\/vars\/terraform.tfvars\u306b\u3066\u5909\u6570\u306e\u5024\u3092\u66f8\u3044\u3066\u3044\u304f\u4e88\u5b9a\u3067\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"4\">VPC\u95a2\u9023\u306e\u5b9a\u7fa9<\/h2>\n\n\n\n<p>\u7d9a\u3044\u3066VPC\u306e\u5b9a\u7fa9\u3092\u4f5c\u6210\u3057\u3066\u3044\u304d\u307e\u3059\u304c\u3001\u5909\u6570\u3092\u4f7f\u3044\u305f\u3044\u306e\u3067\u5148\u306b\u300cvariables.tf\u300d\u306b\u5909\u6570\u3092\u7528\u610f\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h5 class=\"wp-block-heading\" id=\"4-1\">variables.tf<\/h5>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n# -------------------------------------- #\n# General\n# -------------------------------------- #\n# Prefix\nvariable \"name_prefix\" {\n  type        = string\n  description = \"system code prefix\"\n}\n\n# Environment\nvariable \"env\" {\n  type        = string\n  description = \"tag\"\n}\n\n# Tags\nvariable \"tag_terraform\" {\n  type        = string\n  default     = \"true\"\n  description = \"tag\"\n}\n\nvariable \"tag_system_name\" {\n  type        = string\n  description = \"tag\"\n}\n\n# Profile Name\nvariable \"profile\" {\n  type        = string\n  description = \"aws cli profile name\"\n}\n\nvariable \"region\" {\n  type        = string\n  default     = \"ap-northeast-1\"\n  description = \"AWS region in which resources will get deployed. Defaults to Tokyo.\"\n}\n\n# -------------------------------------- #\n# VPC\n# -------------------------------------- #\nvariable \"vpc_cidr\" {\n  type        = string\n  description = \"VPC CIDR\"\n}\n\nvariable \"private_subnet_cidr_a_1\" {\n  type        = string\n  description = \"Private Subnets CIDR\"\n}\n\nvariable \"private_subnet_cidr_c_1\" {\n  type        = string\n  description = \"Private Subnets CIDR\"\n}\n\nvariable \"public_subnet_cidr_a_1\" {\n  type        = string\n  description = \"Public Subnets CIDR\"\n}\n\nvariable \"public_subnet_cidr_c_1\" {\n  type        = string\n  description = \"Public Subnets CIDR\"\n}\n<\/pre><\/div>\n\n\n<p>\u7d9a\u3044\u3066VPC\u95a2\u9023\u306e\u30ea\u30bd\u30fc\u30b9\u3092\u5b9a\u7fa9\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h5 class=\"wp-block-heading\" id=\"4-2\">vpc.tf<\/h5>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n# ------------------------------------------------------ #\n# VPC\n# ------------------------------------------------------ #\nresource \"aws_vpc\" \"vpc\" {\n  cidr_block                       = var.vpc_cidr\n  enable_dns_support               = \"true\"\n  enable_dns_hostnames             = \"true\"\n  assign_generated_ipv6_cidr_block = \"false\"\n  tags = {\n    Name = \"${var.name_prefix}-vpc\"\n  }\n}\n\n# ------------------------------------------------------ #\n# Private Subnet\n# ------------------------------------------------------ #\nresource \"aws_subnet\" \"private_a_1\" {\n  vpc_id                          = aws_vpc.vpc.id\n  cidr_block                      = var.private_subnet_cidr_a_1\n  assign_ipv6_address_on_creation = \"false\"\n  map_public_ip_on_launch         = \"true\"\n  availability_zone               = \"ap-northeast-1a\"\n\n  tags = {\n    Name = \"${var.name_prefix}-private-subnet-a-1\"\n  }\n}\n\nresource \"aws_subnet\" \"private_c_1\" {\n  vpc_id                          = aws_vpc.vpc.id\n  cidr_block                      = var.private_subnet_cidr_c_1\n  assign_ipv6_address_on_creation = \"false\"\n  map_public_ip_on_launch         = \"true\"\n  availability_zone               = \"ap-northeast-1c\"\n\n  tags = {\n    Name = \"${var.name_prefix}-private-subnet-c-1\"\n  }\n}\n\n# ------------------------------------------------------ #\n# Public Subnet\n# ------------------------------------------------------ #\nresource \"aws_subnet\" \"public_a_1\" {\n  vpc_id                          = aws_vpc.vpc.id\n  cidr_block                      = var.public_subnet_cidr_a_1\n  assign_ipv6_address_on_creation = \"false\"\n  map_public_ip_on_launch         = \"true\"\n  availability_zone               = \"ap-northeast-1a\"\n\n  tags = {\n    Name = \"${var.name_prefix}-public-subnet-a-1\"\n  }\n}\n\nresource \"aws_subnet\" \"public_c_1\" {\n  vpc_id                          = aws_vpc.vpc.id\n  cidr_block                      = var.public_subnet_cidr_c_1\n  assign_ipv6_address_on_creation = \"false\"\n  map_public_ip_on_launch         = \"true\"\n  availability_zone               = \"ap-northeast-1c\"\n\n  tags = {\n    Name = \"${var.name_prefix}-public-subnet-c-1\"\n  }\n}\n\n# ------------------------------------------------------ #\n# Internet Gateway\n# ------------------------------------------------------ #\nresource \"aws_internet_gateway\" \"igw\" {\n  vpc_id = aws_vpc.vpc.id\n\n  tags = {\n    Name = \"${var.name_prefix}-igw\"\n  }\n}\n\n# ------------------------------------------------------ #\n# Elastic IP\n# ------------------------------------------------------ #\nresource \"aws_eip\" \"ngw\" {\n  vpc = true\n\n  tags = {\n    Name = \"${var.name_prefix}-eip-ngw\"\n  }\n}\n\n# ------------------------------------------------------ #\n# Nat Gateway\n# ------------------------------------------------------ #\nresource \"aws_nat_gateway\" \"ngw_a\" {\n  allocation_id = aws_eip.ngw.id\n  subnet_id     = aws_subnet.public_a_1.id\n\n  tags = {\n    Name = \"${var.name_prefix}-ngw-a\"\n  }\n\n  depends_on = &#x5B;aws_internet_gateway.igw]\n}\n\n# ------------------------------------------------------ #\n# Route Table\n# ------------------------------------------------------ #\n# Public\nresource \"aws_route_table\" \"public\" {\n  vpc_id = aws_vpc.vpc.id\n\n  tags = {\n    Name = \"${var.name_prefix}-rtb-public\"\n  }\n}\n\nresource \"aws_route\" \"igw\" {\n  destination_cidr_block = \"0.0.0.0\/0\"\n  route_table_id         = aws_route_table.public.id\n  gateway_id             = aws_internet_gateway.igw.id\n}\n\nresource \"aws_route_table_association\" \"public_a\" {\n  subnet_id      = aws_subnet.public_a_1.id\n  route_table_id = aws_route_table.public.id\n}\n\nresource \"aws_route_table_association\" \"public_c\" {\n  subnet_id      = aws_subnet.public_c_1.id\n  route_table_id = aws_route_table.public.id\n}\n\n# Private\nresource \"aws_route_table\" \"private\" {\n  vpc_id = aws_vpc.vpc.id\n\n  tags = {\n    Name = \"${var.name_prefix}-rtb-private\"\n  }\n}\n\nresource \"aws_route\" \"ngw\" {\n  destination_cidr_block = \"0.0.0.0\/0\"\n  route_table_id         = aws_route_table.private.id\n  nat_gateway_id         = aws_nat_gateway.ngw_a.id\n}\n\nresource \"aws_route_table_association\" \"private_a\" {\n  subnet_id      = aws_subnet.private_a_1.id\n  route_table_id = aws_route_table.private.id\n}\n\nresource \"aws_route_table_association\" \"private_c\" {\n  subnet_id      = aws_subnet.private_c_1.id\n  route_table_id = aws_route_table.private.id\n}\n<\/pre><\/div>\n\n\n<p>\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u7cfb\u306e\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3092\u307e\u3068\u3081\u3066\u66f8\u304d\u307e\u3057\u305f\u3002\u4e0a\u8a18\u306e\u5b9a\u7fa9\u3067\u4ee5\u4e0b\u306e\u3088\u3046\u306aVPC\u304c\u69cb\u7bc9\u3055\u308c\u307e\u3059\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"603\" src=\"https:\/\/itport.cloud\/wp-content\/uploads\/2022\/05\/itport_aws-01.drawio-1024x603.png\" alt=\"\" class=\"wp-image-18896\" srcset=\"https:\/\/itport.cloud\/wp-content\/uploads\/2022\/05\/itport_aws-01.drawio-1024x603.png 1024w, https:\/\/itport.cloud\/wp-content\/uploads\/2022\/05\/itport_aws-01.drawio-300x177.png 300w, https:\/\/itport.cloud\/wp-content\/uploads\/2022\/05\/itport_aws-01.drawio-768x452.png 768w, https:\/\/itport.cloud\/wp-content\/uploads\/2022\/05\/itport_aws-01.drawio-1536x904.png 1536w, https:\/\/itport.cloud\/wp-content\/uploads\/2022\/05\/itport_aws-01.drawio-2048x1206.png 2048w, https:\/\/itport.cloud\/wp-content\/uploads\/2022\/05\/itport_aws-01.drawio-450x265.png 450w, https:\/\/itport.cloud\/wp-content\/uploads\/2022\/05\/itport_aws-01.drawio-900x530.png 900w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption>vpc.tf\u306e\u69cb\u6210<\/figcaption><\/figure>\n\n\n\n<p class=\"has-vivid-red-color has-text-color has-background\" style=\"background-color:#fee2e9\">\u203b <strong>Nat Gateway\u3092\u914d\u7f6e\u3057\u306a\u3044\u5834\u5408\u306f\u3001\u30d7\u30e9\u30a4\u30d9\u30fc\u30c8\u30b5\u30d6\u30cd\u30c3\u30c8\u306b\u914d\u7f6e\u3059\u308bEC2\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u304cyum\u30ea\u30dd\u30b8\u30c8\u30ea\u306b\u30a2\u30af\u30bb\u30b9\u51fa\u6765\u306a\u304f\u306a\u308b\u305f\u3081\u3001\u305d\u306e\u5834\u5408\u306fAmazon S3\u306b\u30a2\u30af\u30bb\u30b9\u3067\u304d\u308b\u3088\u3046\u306b\u30b2\u30fc\u30c8\u30a6\u30a7\u30a4\u578b\u306eVPC\u30a8\u30f3\u30c9\u30dd\u30a4\u30f3\u30c8\u3092\u7528\u610f\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/strong><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"5\"> AWS\u30de\u30cd\u30b8\u30e1\u30f3\u30c8\u30b3\u30f3\u30bd\u30fc\u30eb\u4e0a\u3067\u306e\u4f5c\u696d <\/h2>\n\n\n\n<p>EC2\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092Terraform\u3067\u4f5c\u6210\u3059\u308b\u4e88\u5b9a\u306e\u305f\u3081\u3001\u4e8b\u524d\u306bAWS\u30de\u30cd\u30b8\u30e1\u30f3\u30c8\u30b3\u30f3\u30bd\u30fc\u30eb\u4e0a\u3067\u30ad\u30fc\u30da\u30a2\u3092\u4f5c\u6210\u3057\u3066\u304a\u304f\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002EC2 &gt; \u30ad\u30fc\u30da\u30a2\u3088\u308a\u30ad\u30fc\u30da\u30a2\u306e\u4f5c\u6210\u3092\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"828\" height=\"724\" src=\"https:\/\/itport.cloud\/wp-content\/uploads\/2022\/05\/itport_susaki_img_20220502_1.png\" alt=\"\" class=\"wp-image-18927\" srcset=\"https:\/\/itport.cloud\/wp-content\/uploads\/2022\/05\/itport_susaki_img_20220502_1.png 828w, https:\/\/itport.cloud\/wp-content\/uploads\/2022\/05\/itport_susaki_img_20220502_1-300x262.png 300w, https:\/\/itport.cloud\/wp-content\/uploads\/2022\/05\/itport_susaki_img_20220502_1-768x672.png 768w, https:\/\/itport.cloud\/wp-content\/uploads\/2022\/05\/itport_susaki_img_20220502_1-366x320.png 366w, https:\/\/itport.cloud\/wp-content\/uploads\/2022\/05\/itport_susaki_img_20220502_1-732x640.png 732w\" sizes=\"auto, (max-width: 828px) 100vw, 828px\" \/><\/figure><\/div>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"6\">\u6b21\u56de\u4e88\u544a<\/h2>\n\n\n\n<p>\u4eca\u56de\u306f\u3053\u3053\u307e\u3067\u3067\u3059\u3002\u7d50\u5c40AWS CloudFormation\u3068\u4f55\u304c\u9055\u3046\u306e\uff1f\u3068\u3044\u3046\u7591\u554f\u304c\u3042\u308b\u304b\u3068\u601d\u3044\u307e\u3059\u304c\u78ba\u304b\u306b\u5b9f\u73fe\u3067\u304d\u308b\u3053\u3068\u306f\u4f3c\u3066\u3044\u307e\u3059\u3002AWS CloudFormation\u306fYaml\u5f62\u5f0f\u3067\u66f8\u304d\u307e\u3057\u305f\u304c\u3001Terraform\u3067\u306f\u30e2\u30c7\u30eb\u3092\u5b9a\u7fa9\u3057\u3066\u3044\u304f\u3088\u3046\u306a\u66f8\u304d\u65b9\u306b\u306a\u308a\u307e\u3059\u3002\u958b\u767a\u8005\u306e\u65b9\u306fTerraform\u306e\u65b9\u304c\u99b4\u67d3\u307f\u304c\u3042\u308a\u66f8\u304d\u3084\u3059\u3044\u306e\u3067\u306f\u306a\u3044\u304b\u3068\u500b\u4eba\u7684\u306b\u306f\u611f\u3058\u307e\u3057\u305f\u3002\u305f\u3060\u3057AWS CloudFormation\u3082AWS Cloud Development Kit\uff08AWS CDK\uff09\u3092\u5229\u7528\u3059\u308b\u3053\u3068\u3067\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u3092\u3059\u308b\u3088\u3046\u306a\u611f\u899a\u3067\u4f5c\u6210\u3067\u304d\u308b\u3088\u3046\u3067\u3059\u3002<br><br>\u307e\u305f\u3001\u30a4\u30f3\u30d5\u30e9\u69cb\u6210\u3092\u66f4\u65b0\u3059\u308b\u969b\u306e\u5dee\u5206\u691c\u51fa\u65b9\u6cd5\u306b\u3082\u304b\u306a\u308a\u306e\u9055\u3044\u304c\u3042\u308a\u3001Terraform\u3067\u306fAWS\u30de\u30cd\u30b8\u30e1\u30f3\u30c8\u30b3\u30f3\u30bd\u30fc\u30eb\u7b49\u304b\u3089\u624b\u52d5\u3067\u5909\u66f4\u3057\u305f\u5185\u5bb9\u3082terraform apply\u6642\u306btf\u30d5\u30a1\u30a4\u30eb\u306b\u5b9a\u7fa9\u3057\u305f\u5185\u5bb9\u306b\u5408\u308f\u305b\u3066\u4fee\u6b63\u3092\u3057\u3066\u304f\u308c\u307e\u3059\u304c\u3001AWS CloudFormation\u306f\u300cDrift detect\u300d\u3067\u5dee\u5206\u306e\u691c\u77e5\u306f\u51fa\u6765\u308b\u3082\u306e\u306e\u3001\u30b9\u30bf\u30c3\u30af\u3092\u66f4\u65b0\u3057\u3066\u3082\u4fee\u6b63\u81ea\u4f53\u306f\u3057\u3066\u304f\u308c\u306a\u3044\u305f\u3081\u624b\u4f5c\u696d\u3067\u306e\u4fee\u6b63\u304c\u5fc5\u8981\u3067\u3059\u3002<br><br>\u305d\u3057\u3066\u3001Terraform\u306e\u4e00\u756a\u306e\u30e1\u30ea\u30c3\u30c8\u306fAWS\u306b\u9650\u3089\u306a\u3044\u3068\u3044\u3046\u70b9\u3067\u3059\u3002\u9006\u306b\u30c7\u30e1\u30ea\u30c3\u30c8\u3068\u3057\u3066\u306fTerraform\u81ea\u4f53\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u3092\u7ba1\u7406\u3059\u308b\u3053\u3068\u3082\u8003\u616e\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u306e\u3067\u3001\u305d\u308c\u3089\u306e\u30dd\u30a4\u30f3\u30c8\u3092\u52a0\u5473\u3057\u3066\u30c4\u30fc\u30eb\u9078\u5b9a\u3092\u3059\u308b\u306e\u304c\u826f\u3044\u304b\u3068\u601d\u3044\u307e\u3057\u305f\u3002<br><br>\u6b21\u56de\u306f\u3001ELB\u3084EC2\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306e\u5b9a\u7fa9\u3092\u4f5c\u6210\u3057\u3066\u3044\u304d\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n\n\n","protected":false},"excerpt":{"rendered":"\u76ee\u6b21 \u306f\u3058\u3081\u306b\u69cb\u6210\u56f3Terraform\u30d5\u30a1\u30a4\u30eb\u69cb\u6210\u3000- terraform.tf\u3000- provider.tfVPC\u95a2\u9023\u306e\u5b9a\u7fa9\u3000- variables.tf\u3000- vpc.tfAWS\u30de\u30cd\u30b8\u30e1\u30f3\u30c8\u30b3\u30f3\u30bd\u30fc\u30eb\u4e0a\u3067\u306e\u4f5c\u696d\u6b21\u56de\u4e88\u544a \u306f\u3058\u3081\u306b \u4ee5\u524d\u306bAWS CloudFormation\u3092\u4f7f\u7528\u3057\u3066VPC\u306e\u69cb\u7bc9\u3084Amazon EC2\u3001Amazon S3\u306e\u69cb\u7bc9\u691c\u8a3c\u3092\u3054\u7d39\u4ecb\u3044\u305f\u3057\u307e\u3057\u305f\u3002 https:\/\/itport.cloud\/?p=13493 \u4eca\u56de\u306fTerraform\u3092\u4f7f\u7528\u3057\u3066AWS\u4e0a\u306bWeb\u30b5\u30fc\u30d0\u30fc\u306e\u69cb\u7bc9\u307e\u3067\u884c\u3044\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002Terraform\u3067\u69cb\u7bc9\u3059\u308bAWS\u306e\u69cb\u6210\u3092\u8a18\u8f09\u3057\u307e\u3059\u3002 \u69cb\u6210\u56f3 Application Load Balancer\u3092\u4f7f\u7528\u3057&hellip;","protected":false},"author":3,"featured_media":18838,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[80],"tags":[139],"class_list":{"0":"post-18835","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-aws","8":"tag-season45"},"_links":{"self":[{"href":"https:\/\/itport.cloud\/index.php?rest_route=\/wp\/v2\/posts\/18835","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/itport.cloud\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/itport.cloud\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/itport.cloud\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/itport.cloud\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=18835"}],"version-history":[{"count":65,"href":"https:\/\/itport.cloud\/index.php?rest_route=\/wp\/v2\/posts\/18835\/revisions"}],"predecessor-version":[{"id":19388,"href":"https:\/\/itport.cloud\/index.php?rest_route=\/wp\/v2\/posts\/18835\/revisions\/19388"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/itport.cloud\/index.php?rest_route=\/wp\/v2\/media\/18838"}],"wp:attachment":[{"href":"https:\/\/itport.cloud\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=18835"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/itport.cloud\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=18835"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/itport.cloud\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=18835"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}