dulao5 / dulao5.github.com

my github pages
0 stars 1 forks source link

aws hanson メモ #2

Open dulao5 opened 5 years ago

dulao5 commented 5 years ago

https://y-ohgi.com/2019-aws-handson/ecs/provisioning/

dulao5 commented 5 years ago

terraform plan

/templates # terraform plan
Refreshing Terraform state in-memory prior to plan...
The refreshed state will be used to calculate this plan, but will not be
persisted to local or remote state storage.

data.aws_iam_policy_document.monitoring_rds_assume_role: Refreshing state...
data.aws_caller_identity.self: Refreshing state...
data.aws_region.current: Refreshing state...
data.aws_region.current: Refreshing state...
data.aws_ssm_parameter.db_password: Refreshing state...
data.aws_caller_identity.current: Refreshing state...
data.aws_ssm_parameter.db_username: Refreshing state...
data.template_file.container_definitions: Refreshing state...

------------------------------------------------------------------------

An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  + aws_db_parameter_group.this
      id:                                             <computed>
      arn:                                            <computed>
      description:                                    "Managed by Terraform"
      family:                                         "aurora-mysql5.7"
      name:                                           "handson-aurora-mysql5-7"
      name_prefix:                                    <computed>

  + aws_ecs_cluster.this
      id:                                             <computed>
      arn:                                            <computed>
      name:                                           "handson"

  + aws_rds_cluster_parameter_group.this
      id:                                             <computed>
      arn:                                            <computed>
      description:                                    "Managed by Terraform"
      family:                                         "aurora-mysql5.7"
      name:                                           "handson-aurora-mysql5-7"
      name_prefix:                                    <computed>

  + aws_ssm_parameter.db_endpoint
      id:                                             <computed>
      arn:                                            <computed>
      key_id:                                         <computed>
      name:                                           "/handson/db/endpoint"
      type:                                           "String"
      value:                                          <sensitive>

  + module.alb.aws_lb.this
      id:                                             <computed>
      access_logs.#:                                  <computed>
      arn:                                            <computed>
      arn_suffix:                                     <computed>
      dns_name:                                       <computed>
      enable_deletion_protection:                     "false"
      enable_http2:                                   "true"
      idle_timeout:                                   "60"
      internal:                                       <computed>
      ip_address_type:                                <computed>
      load_balancer_type:                             "application"
      name:                                           "handson"
      security_groups.#:                              <computed>
      subnet_mapping.#:                               <computed>
      subnets.#:                                      <computed>
      vpc_id:                                         <computed>
      zone_id:                                        <computed>

  + module.alb.aws_lb_listener.http_listener
      id:                                             <computed>
      arn:                                            <computed>
      default_action.#:                               "1"
      default_action.0.fixed_response.#:              "1"
      default_action.0.fixed_response.0.content_type: "text/plain"
      default_action.0.fixed_response.0.message_body: "ng"
      default_action.0.fixed_response.0.status_code:  "503"
      default_action.0.order:                         <computed>
      default_action.0.type:                          "fixed-response"
      load_balancer_arn:                              "${aws_lb.this.arn}"
      port:                                           "80"
      protocol:                                       "HTTP"
      ssl_policy:                                     <computed>

  + module.db.aws_db_subnet_group.this
      id:                                             <computed>
      arn:                                            <computed>
      description:                                    "For Aurora cluster handson"
      name:                                           "handson"
      name_prefix:                                    <computed>
      subnet_ids.#:                                   <computed>
      tags.%:                                         "1"
      tags.Name:                                      "aurora-handson"

  + module.db.aws_rds_cluster.this
      id:                                             <computed>
      apply_immediately:                              "false"
      arn:                                            <computed>
      availability_zones.#:                           <computed>
      backup_retention_period:                        "7"
      cluster_identifier:                             "handson"
      cluster_identifier_prefix:                      <computed>
      cluster_members.#:                              <computed>
      cluster_resource_id:                            <computed>
      database_name:                                  "handson"
      db_cluster_parameter_group_name:                "handson-aurora-mysql5-7"
      db_subnet_group_name:                           "handson"
      deletion_protection:                            "false"
      endpoint:                                       <computed>
      engine:                                         "aurora-mysql"
      engine_mode:                                    "provisioned"
      engine_version:                                 "5.7.12"
      final_snapshot_identifier:                      "${var.final_snapshot_identifier_prefix}-${var.name}-${random_id.snapshot_identifier.hex}"
      hosted_zone_id:                                 <computed>
      iam_database_authentication_enabled:            "false"
      kms_key_id:                                     <computed>
      master_password:                                <sensitive>
      master_username:                                "myusername"
      port:                                           "3306"
      preferred_backup_window:                        "02:00-03:00"
      preferred_maintenance_window:                   "sun:05:00-sun:06:00"
      reader_endpoint:                                <computed>
      skip_final_snapshot:                            "false"
      storage_encrypted:                              "true"
      vpc_security_group_ids.#:                       <computed>

  + module.db.aws_rds_cluster_instance.this
      id:                                             <computed>
      apply_immediately:                              "false"
      arn:                                            <computed>
      auto_minor_version_upgrade:                     "true"
      availability_zone:                              <computed>
      cluster_identifier:                             "${aws_rds_cluster.this.id}"
      copy_tags_to_snapshot:                          "false"
      db_parameter_group_name:                        "handson-aurora-mysql5-7"
      db_subnet_group_name:                           "handson"
      dbi_resource_id:                                <computed>
      endpoint:                                       <computed>
      engine:                                         "aurora-mysql"
      engine_version:                                 "5.7.12"
      identifier:                                     "handson-1"
      identifier_prefix:                              <computed>
      instance_class:                                 "db.t3.small"
      kms_key_id:                                     <computed>
      monitoring_interval:                            "0"
      monitoring_role_arn:                            <computed>
      performance_insights_enabled:                   "false"
      performance_insights_kms_key_id:                <computed>
      port:                                           <computed>
      preferred_backup_window:                        <computed>
      preferred_maintenance_window:                   "sun:05:00-sun:06:00"
      promotion_tier:                                 "1"
      publicly_accessible:                            "false"
      storage_encrypted:                              <computed>
      writer:                                         <computed>

  + module.db.aws_security_group.this
      id:                                             <computed>
      arn:                                            <computed>
      description:                                    "Managed by Terraform"
      egress.#:                                       <computed>
      ingress.#:                                      <computed>
      name:                                           <computed>
      name_prefix:                                    "handson-"
      owner_id:                                       <computed>
      revoke_rules_on_delete:                         "false"
      vpc_id:                                         "${var.vpc_id}"

  + module.db.random_id.master_password
      id:                                             <computed>
      b64:                                            <computed>
      b64_std:                                        <computed>
      b64_url:                                        <computed>
      byte_length:                                    "10"
      dec:                                            <computed>
      hex:                                            <computed>

  + module.db.random_id.snapshot_identifier
      id:                                             <computed>
      b64:                                            <computed>
      b64_std:                                        <computed>
      b64_url:                                        <computed>
      byte_length:                                    "4"
      dec:                                            <computed>
      hex:                                            <computed>
      keepers.%:                                      "1"
      keepers.id:                                     "handson"

  + module.service.aws_alb_listener_rule.this
      id:                                             <computed>
      action.#:                                       "1"
      action.0.order:                                 <computed>
      action.0.target_group_arn:                      "${aws_lb_target_group.this.id}"
      action.0.type:                                  "forward"
      arn:                                            <computed>
      condition.#:                                    "1"
      condition.1746742835.field:                     "path-pattern"
      condition.1746742835.values.#:                  "1"
      condition.1746742835.values.0:                  "*"
      listener_arn:                                   "${var.alb_listener_arn}"
      priority:                                       <computed>

  + module.service.aws_cloudwatch_log_group.this
      id:                                             <computed>
      arn:                                            <computed>
      name:                                           "/handson/ecs"
      retention_in_days:                              "7"

  + module.service.aws_ecs_service.this
      id:                                             <computed>
      cluster:                                        "handson"
      deployment_controller.#:                        "1"
      deployment_controller.0.type:                   "ECS"
      deployment_maximum_percent:                     "200"
      deployment_minimum_healthy_percent:             "100"
      desired_count:                                  "1"
      enable_ecs_managed_tags:                        "false"
      health_check_grace_period_seconds:              "10"
      iam_role:                                       <computed>
      launch_type:                                    "FARGATE"
      load_balancer.#:                                "1"
      load_balancer.~3019512456.container_name:       "nginx"
      load_balancer.~3019512456.container_port:       "80"
      load_balancer.~3019512456.elb_name:             ""
      load_balancer.~3019512456.target_group_arn:     "${aws_lb_target_group.this.arn}"
      name:                                           "handson"
      network_configuration.#:                        "1"
      network_configuration.0.assign_public_ip:       "false"
      network_configuration.0.security_groups.#:      <computed>
      network_configuration.0.subnets.#:              <computed>
      placement_strategy.#:                           <computed>
      platform_version:                               <computed>
      scheduling_strategy:                            "REPLICA"
      task_definition:                                "${aws_ecs_task_definition.this.arn}"

  + module.service.aws_ecs_task_definition.this
      id:                                             <computed>
      arn:                                            <computed>
      container_definitions:                          "[{\"cpu\":0,\"image\":\"177657369922.dkr.ecr.ap-northeast-1.amazonaws.com/handson-nginx:latest\",\"logConfiguration\":{\"logDriver\":\"awslogs\",\"options\":{\"awslogs-group\":\"/handson/ecs\",\"awslogs-region\":\"ap-northeast-1\",\"awslogs-stream-prefix\":\"api\"}},\"memory\":128,\"name\":\"nginx\",\"portMappings\":[{\"containerPort\":80,\"hostPort\":80,\"protocol\":\"tcp\"}]}]"
      cpu:                                            "256"
      execution_role_arn:                             "${aws_iam_role.task_execution.arn}"
      family:                                         "handson"
      memory:                                         "512"
      network_mode:                                   "awsvpc"
      requires_compatibilities.#:                     "1"
      requires_compatibilities.3072437307:            "FARGATE"
      revision:                                       <computed>
      task_role_arn:                                  "${aws_iam_role.task_execution.arn}"

  + module.service.aws_iam_role.task_execution
      id:                                             <computed>
      arn:                                            <computed>
      assume_role_policy:                             "{\n  \"Version\": \"2012-10-17\",\n  \"Statement\": [\n    {\n      \"Action\": \"sts:AssumeRole\",\n      \"Principal\": {\n        \"Service\": \"ecs-tasks.amazonaws.com\"\n      },\n      \"Effect\": \"Allow\",\n      \"Sid\": \"\"\n    }\n  ]\n}\n"
      create_date:                                    <computed>
      force_detach_policies:                          "false"
      max_session_duration:                           "3600"
      name:                                           "handson-TaskExecution"
      path:                                           "/"
      unique_id:                                      <computed>

  + module.service.aws_iam_role_policy.task_execution
      id:                                             <computed>
      name:                                           <computed>
      policy:                                         "{\n  \"Version\": \"2012-10-17\",\n  \"Statement\": [\n    {\n      \"Action\": [\n        \"logs:CreateLogGroup\",\n        \"logs:CreateLogStream\",\n        \"logs:PutLogEvents\",\n        \"logs:DescribeLogGroups\",\n        \"logs:DescribeLogStreams\"\n      ],\n      \"Effect\": \"Allow\",\n      \"Resource\": \"*\"\n    },\n    {\n      \"Effect\": \"Allow\",\n      \"Action\": [\n        \"ssm:GetParameters\",\n        \"secretsmanager:GetSecretValue\",\n        \"kms:Decrypt\"\n      ],\n      \"Resource\": [\n        \"arn:aws:ssm:ap-northeast-1:177657369922:parameter/*\",\n        \"arn:aws:secretsmanager:ap-northeast-1:177657369922:secret:*\",\n        \"arn:aws:kms:ap-northeast-1:177657369922:key/*\"\n      ]\n    }\n  ]\n}\n"
      role:                                           "${aws_iam_role.task_execution.id}"

  + module.service.aws_iam_role_policy_attachment.task_execution
      id:                                             <computed>
      policy_arn:                                     "arn:aws:iam::aws:policy/service-role/AmazonECSTaskExecutionRolePolicy"
      role:                                           "handson-TaskExecution"

  + module.service.aws_lb_target_group.this
      id:                                             <computed>
      arn:                                            <computed>
      arn_suffix:                                     <computed>
      deregistration_delay:                           "300"
      health_check.#:                                 "1"
      health_check.0.healthy_threshold:               "5"
      health_check.0.interval:                        "30"
      health_check.0.matcher:                         "200-399"
      health_check.0.path:                            "/"
      health_check.0.port:                            "80"
      health_check.0.protocol:                        "HTTP"
      health_check.0.timeout:                         "5"
      health_check.0.unhealthy_threshold:             "2"
      lambda_multi_value_headers_enabled:             "false"
      name:                                           <computed>
      port:                                           "80"
      protocol:                                       "HTTP"
      proxy_protocol_v2:                              "false"
      slow_start:                                     "0"
      stickiness.#:                                   <computed>
      target_type:                                    "ip"
      vpc_id:                                         "${var.vpc_id}"

  + module.sg_alb.aws_security_group.this
      id:                                             <computed>
      arn:                                            <computed>
      description:                                    "handson_alb"
      egress.#:                                       <computed>
      ingress.#:                                      <computed>
      name:                                           <computed>
      owner_id:                                       <computed>
      revoke_rules_on_delete:                         "false"
      tags.%:                                         "1"
      tags.Name:                                      "handson_alb"
      vpc_id:                                         "${var.vpc_id}"

  + module.sg_alb.aws_security_group_rule.egress
      id:                                             <computed>
      cidr_blocks.#:                                  "1"
      cidr_blocks.0:                                  "0.0.0.0/0"
      from_port:                                      "0"
      protocol:                                       "-1"
      security_group_id:                              "${aws_security_group.this.id}"
      self:                                           "false"
      source_security_group_id:                       <computed>
      to_port:                                        "0"
      type:                                           "egress"

  + module.sg_alb.aws_security_group_rule.ingress_with_cidr_block
      id:                                             <computed>
      cidr_blocks.#:                                  "1"
      cidr_blocks.0:                                  "0.0.0.0/0"
      description:                                    "handson_alb"
      from_port:                                      "80"
      protocol:                                       "tcp"
      security_group_id:                              "${aws_security_group.this.id}"
      self:                                           "false"
      source_security_group_id:                       <computed>
      to_port:                                        "80"
      type:                                           "ingress"

  + module.sg_db.aws_security_group.this
      id:                                             <computed>
      arn:                                            <computed>
      description:                                    "handson_db"
      egress.#:                                       <computed>
      ingress.#:                                      <computed>
      name:                                           <computed>
      owner_id:                                       <computed>
      revoke_rules_on_delete:                         "false"
      tags.%:                                         "1"
      tags.Name:                                      "handson_db"
      vpc_id:                                         "${var.vpc_id}"

  + module.sg_db.aws_security_group_rule.egress
      id:                                             <computed>
      cidr_blocks.#:                                  "1"
      cidr_blocks.0:                                  "0.0.0.0/0"
      from_port:                                      "0"
      protocol:                                       "-1"
      security_group_id:                              "${aws_security_group.this.id}"
      self:                                           "false"
      source_security_group_id:                       <computed>
      to_port:                                        "0"
      type:                                           "egress"

  + module.sg_db.aws_security_group_rule.ingress_with_cidr_block
      id:                                             <computed>
      cidr_blocks.#:                                  "1"
      cidr_blocks.0:                                  "10.0.0.0/16"
      description:                                    "handson_db"
      from_port:                                      "3306"
      protocol:                                       "tcp"
      security_group_id:                              "${aws_security_group.this.id}"
      self:                                           "false"
      source_security_group_id:                       <computed>
      to_port:                                        "3306"
      type:                                           "ingress"

  + module.sg_ecs_service.aws_security_group.this
      id:                                             <computed>
      arn:                                            <computed>
      description:                                    "handson_ecs_service"
      egress.#:                                       <computed>
      ingress.#:                                      <computed>
      name:                                           <computed>
      owner_id:                                       <computed>
      revoke_rules_on_delete:                         "false"
      tags.%:                                         "1"
      tags.Name:                                      "handson_ecs_service"
      vpc_id:                                         "${var.vpc_id}"

  + module.sg_ecs_service.aws_security_group_rule.egress
      id:                                             <computed>
      cidr_blocks.#:                                  "1"
      cidr_blocks.0:                                  "0.0.0.0/0"
      from_port:                                      "0"
      protocol:                                       "-1"
      security_group_id:                              "${aws_security_group.this.id}"
      self:                                           "false"
      source_security_group_id:                       <computed>
      to_port:                                        "0"
      type:                                           "egress"

  + module.sg_ecs_service.aws_security_group_rule.ingress_with_cidr_block
      id:                                             <computed>
      cidr_blocks.#:                                  "1"
      cidr_blocks.0:                                  "10.0.0.0/16"
      description:                                    "handson_ecs_service"
      from_port:                                      "80"
      protocol:                                       "tcp"
      security_group_id:                              "${aws_security_group.this.id}"
      self:                                           "false"
      source_security_group_id:                       <computed>
      to_port:                                        "80"
      type:                                           "ingress"

  + module.vpc.aws_eip.nat[0]
      id:                                             <computed>
      allocation_id:                                  <computed>
      association_id:                                 <computed>
      domain:                                         <computed>
      instance:                                       <computed>
      network_interface:                              <computed>
      private_dns:                                    <computed>
      private_ip:                                     <computed>
      public_dns:                                     <computed>
      public_ip:                                      <computed>
      public_ipv4_pool:                               <computed>
      tags.%:                                         "2"
      tags.Name:                                      "handson-ap-northeast-1a"
      tags.Terraform:                                 "true"
      vpc:                                            "true"

  + module.vpc.aws_eip.nat[1]
      id:                                             <computed>
      allocation_id:                                  <computed>
      association_id:                                 <computed>
      domain:                                         <computed>
      instance:                                       <computed>
      network_interface:                              <computed>
      private_dns:                                    <computed>
      private_ip:                                     <computed>
      public_dns:                                     <computed>
      public_ip:                                      <computed>
      public_ipv4_pool:                               <computed>
      tags.%:                                         "2"
      tags.Name:                                      "handson-ap-northeast-1c"
      tags.Terraform:                                 "true"
      vpc:                                            "true"

  + module.vpc.aws_eip.nat[2]
      id:                                             <computed>
      allocation_id:                                  <computed>
      association_id:                                 <computed>
      domain:                                         <computed>
      instance:                                       <computed>
      network_interface:                              <computed>
      private_dns:                                    <computed>
      private_ip:                                     <computed>
      public_dns:                                     <computed>
      public_ip:                                      <computed>
      public_ipv4_pool:                               <computed>
      tags.%:                                         "2"
      tags.Name:                                      "handson-ap-northeast-1d"
      tags.Terraform:                                 "true"
      vpc:                                            "true"

  + module.vpc.aws_internet_gateway.this
      id:                                             <computed>
      owner_id:                                       <computed>
      tags.%:                                         "2"
      tags.Name:                                      "handson"
      tags.Terraform:                                 "true"
      vpc_id:                                         "${local.vpc_id}"

  + module.vpc.aws_nat_gateway.this[0]
      id:                                             <computed>
      allocation_id:                                  "${element(local.nat_gateway_ips, (var.single_nat_gateway ? 0 : count.index))}"
      network_interface_id:                           <computed>
      private_ip:                                     <computed>
      public_ip:                                      <computed>
      subnet_id:                                      "${element(aws_subnet.public.*.id, (var.single_nat_gateway ? 0 : count.index))}"
      tags.%:                                         "2"
      tags.Name:                                      "handson-ap-northeast-1a"
      tags.Terraform:                                 "true"

  + module.vpc.aws_nat_gateway.this[1]
      id:                                             <computed>
      allocation_id:                                  "${element(local.nat_gateway_ips, (var.single_nat_gateway ? 0 : count.index))}"
      network_interface_id:                           <computed>
      private_ip:                                     <computed>
      public_ip:                                      <computed>
      subnet_id:                                      "${element(aws_subnet.public.*.id, (var.single_nat_gateway ? 0 : count.index))}"
      tags.%:                                         "2"
      tags.Name:                                      "handson-ap-northeast-1c"
      tags.Terraform:                                 "true"

  + module.vpc.aws_nat_gateway.this[2]
      id:                                             <computed>
      allocation_id:                                  "${element(local.nat_gateway_ips, (var.single_nat_gateway ? 0 : count.index))}"
      network_interface_id:                           <computed>
      private_ip:                                     <computed>
      public_ip:                                      <computed>
      subnet_id:                                      "${element(aws_subnet.public.*.id, (var.single_nat_gateway ? 0 : count.index))}"
      tags.%:                                         "2"
      tags.Name:                                      "handson-ap-northeast-1d"
      tags.Terraform:                                 "true"

  + module.vpc.aws_route.private_nat_gateway[0]
      id:                                             <computed>
      destination_cidr_block:                         "0.0.0.0/0"
      destination_prefix_list_id:                     <computed>
      egress_only_gateway_id:                         <computed>
      gateway_id:                                     <computed>
      instance_id:                                    <computed>
      instance_owner_id:                              <computed>
      nat_gateway_id:                                 "${element(aws_nat_gateway.this.*.id, count.index)}"
      network_interface_id:                           <computed>
      origin:                                         <computed>
      route_table_id:                                 "${element(aws_route_table.private.*.id, count.index)}"
      state:                                          <computed>

  + module.vpc.aws_route.private_nat_gateway[1]
      id:                                             <computed>
      destination_cidr_block:                         "0.0.0.0/0"
      destination_prefix_list_id:                     <computed>
      egress_only_gateway_id:                         <computed>
      gateway_id:                                     <computed>
      instance_id:                                    <computed>
      instance_owner_id:                              <computed>
      nat_gateway_id:                                 "${element(aws_nat_gateway.this.*.id, count.index)}"
      network_interface_id:                           <computed>
      origin:                                         <computed>
      route_table_id:                                 "${element(aws_route_table.private.*.id, count.index)}"
      state:                                          <computed>

  + module.vpc.aws_route.private_nat_gateway[2]
      id:                                             <computed>
      destination_cidr_block:                         "0.0.0.0/0"
      destination_prefix_list_id:                     <computed>
      egress_only_gateway_id:                         <computed>
      gateway_id:                                     <computed>
      instance_id:                                    <computed>
      instance_owner_id:                              <computed>
      nat_gateway_id:                                 "${element(aws_nat_gateway.this.*.id, count.index)}"
      network_interface_id:                           <computed>
      origin:                                         <computed>
      route_table_id:                                 "${element(aws_route_table.private.*.id, count.index)}"
      state:                                          <computed>

  + module.vpc.aws_route.public_internet_gateway
      id:                                             <computed>
      destination_cidr_block:                         "0.0.0.0/0"
      destination_prefix_list_id:                     <computed>
      egress_only_gateway_id:                         <computed>
      gateway_id:                                     "${aws_internet_gateway.this.id}"
      instance_id:                                    <computed>
      instance_owner_id:                              <computed>
      nat_gateway_id:                                 <computed>
      network_interface_id:                           <computed>
      origin:                                         <computed>
      route_table_id:                                 "${aws_route_table.public.id}"
      state:                                          <computed>

  + module.vpc.aws_route_table.private[0]
      id:                                             <computed>
      owner_id:                                       <computed>
      propagating_vgws.#:                             <computed>
      route.#:                                        <computed>
      tags.%:                                         "2"
      tags.Name:                                      "handson-private-ap-northeast-1a"
      tags.Terraform:                                 "true"
      vpc_id:                                         "${local.vpc_id}"

  + module.vpc.aws_route_table.private[1]
      id:                                             <computed>
      owner_id:                                       <computed>
      propagating_vgws.#:                             <computed>
      route.#:                                        <computed>
      tags.%:                                         "2"
      tags.Name:                                      "handson-private-ap-northeast-1c"
      tags.Terraform:                                 "true"
      vpc_id:                                         "${local.vpc_id}"

  + module.vpc.aws_route_table.private[2]
      id:                                             <computed>
      owner_id:                                       <computed>
      propagating_vgws.#:                             <computed>
      route.#:                                        <computed>
      tags.%:                                         "2"
      tags.Name:                                      "handson-private-ap-northeast-1d"
      tags.Terraform:                                 "true"
      vpc_id:                                         "${local.vpc_id}"

  + module.vpc.aws_route_table.public
      id:                                             <computed>
      owner_id:                                       <computed>
      propagating_vgws.#:                             <computed>
      route.#:                                        <computed>
      tags.%:                                         "2"
      tags.Name:                                      "handson-public"
      tags.Terraform:                                 "true"
      vpc_id:                                         "${local.vpc_id}"

  + module.vpc.aws_route_table_association.private[0]
      id:                                             <computed>
      route_table_id:                                 "${element(aws_route_table.private.*.id, (var.single_nat_gateway ? 0 : count.index))}"
      subnet_id:                                      "${element(aws_subnet.private.*.id, count.index)}"

  + module.vpc.aws_route_table_association.private[1]
      id:                                             <computed>
      route_table_id:                                 "${element(aws_route_table.private.*.id, (var.single_nat_gateway ? 0 : count.index))}"
      subnet_id:                                      "${element(aws_subnet.private.*.id, count.index)}"

  + module.vpc.aws_route_table_association.private[2]
      id:                                             <computed>
      route_table_id:                                 "${element(aws_route_table.private.*.id, (var.single_nat_gateway ? 0 : count.index))}"
      subnet_id:                                      "${element(aws_subnet.private.*.id, count.index)}"

  + module.vpc.aws_route_table_association.public[0]
      id:                                             <computed>
      route_table_id:                                 "${aws_route_table.public.id}"
      subnet_id:                                      "${element(aws_subnet.public.*.id, count.index)}"

  + module.vpc.aws_route_table_association.public[1]
      id:                                             <computed>
      route_table_id:                                 "${aws_route_table.public.id}"
      subnet_id:                                      "${element(aws_subnet.public.*.id, count.index)}"

  + module.vpc.aws_route_table_association.public[2]
      id:                                             <computed>
      route_table_id:                                 "${aws_route_table.public.id}"
      subnet_id:                                      "${element(aws_subnet.public.*.id, count.index)}"

  + module.vpc.aws_subnet.private[0]
      id:                                             <computed>
      arn:                                            <computed>
      assign_ipv6_address_on_creation:                "false"
      availability_zone:                              "ap-northeast-1a"
      availability_zone_id:                           <computed>
      cidr_block:                                     "10.0.1.0/24"
      ipv6_cidr_block:                                <computed>
      ipv6_cidr_block_association_id:                 <computed>
      map_public_ip_on_launch:                        "false"
      owner_id:                                       <computed>
      tags.%:                                         "2"
      tags.Name:                                      "handson-private-ap-northeast-1a"
      tags.Terraform:                                 "true"
      vpc_id:                                         "${local.vpc_id}"

  + module.vpc.aws_subnet.private[1]
      id:                                             <computed>
      arn:                                            <computed>
      assign_ipv6_address_on_creation:                "false"
      availability_zone:                              "ap-northeast-1c"
      availability_zone_id:                           <computed>
      cidr_block:                                     "10.0.2.0/24"
      ipv6_cidr_block:                                <computed>
      ipv6_cidr_block_association_id:                 <computed>
      map_public_ip_on_launch:                        "false"
      owner_id:                                       <computed>
      tags.%:                                         "2"
      tags.Name:                                      "handson-private-ap-northeast-1c"
      tags.Terraform:                                 "true"
      vpc_id:                                         "${local.vpc_id}"

  + module.vpc.aws_subnet.private[2]
      id:                                             <computed>
      arn:                                            <computed>
      assign_ipv6_address_on_creation:                "false"
      availability_zone:                              "ap-northeast-1d"
      availability_zone_id:                           <computed>
      cidr_block:                                     "10.0.3.0/24"
      ipv6_cidr_block:                                <computed>
      ipv6_cidr_block_association_id:                 <computed>
      map_public_ip_on_launch:                        "false"
      owner_id:                                       <computed>
      tags.%:                                         "2"
      tags.Name:                                      "handson-private-ap-northeast-1d"
      tags.Terraform:                                 "true"
      vpc_id:                                         "${local.vpc_id}"

  + module.vpc.aws_subnet.public[0]
      id:                                             <computed>
      arn:                                            <computed>
      assign_ipv6_address_on_creation:                "false"
      availability_zone:                              "ap-northeast-1a"
      availability_zone_id:                           <computed>
      cidr_block:                                     "10.0.101.0/24"
      ipv6_cidr_block:                                <computed>
      ipv6_cidr_block_association_id:                 <computed>
      map_public_ip_on_launch:                        "true"
      owner_id:                                       <computed>
      tags.%:                                         "2"
      tags.Name:                                      "handson-public-ap-northeast-1a"
      tags.Terraform:                                 "true"
      vpc_id:                                         "${local.vpc_id}"

  + module.vpc.aws_subnet.public[1]
      id:                                             <computed>
      arn:                                            <computed>
      assign_ipv6_address_on_creation:                "false"
      availability_zone:                              "ap-northeast-1c"
      availability_zone_id:                           <computed>
      cidr_block:                                     "10.0.102.0/24"
      ipv6_cidr_block:                                <computed>
      ipv6_cidr_block_association_id:                 <computed>
      map_public_ip_on_launch:                        "true"
      owner_id:                                       <computed>
      tags.%:                                         "2"
      tags.Name:                                      "handson-public-ap-northeast-1c"
      tags.Terraform:                                 "true"
      vpc_id:                                         "${local.vpc_id}"

  + module.vpc.aws_subnet.public[2]
      id:                                             <computed>
      arn:                                            <computed>
      assign_ipv6_address_on_creation:                "false"
      availability_zone:                              "ap-northeast-1d"
      availability_zone_id:                           <computed>
      cidr_block:                                     "10.0.103.0/24"
      ipv6_cidr_block:                                <computed>
      ipv6_cidr_block_association_id:                 <computed>
      map_public_ip_on_launch:                        "true"
      owner_id:                                       <computed>
      tags.%:                                         "2"
      tags.Name:                                      "handson-public-ap-northeast-1d"
      tags.Terraform:                                 "true"
      vpc_id:                                         "${local.vpc_id}"

  + module.vpc.aws_vpc.this
      id:                                             <computed>
      arn:                                            <computed>
      assign_generated_ipv6_cidr_block:               "false"
      cidr_block:                                     "10.0.0.0/16"
      default_network_acl_id:                         <computed>
      default_route_table_id:                         <computed>
      default_security_group_id:                      <computed>
      dhcp_options_id:                                <computed>
      enable_classiclink:                             <computed>
      enable_classiclink_dns_support:                 <computed>
      enable_dns_hostnames:                           "false"
      enable_dns_support:                             "true"
      instance_tenancy:                               "default"
      ipv6_association_id:                            <computed>
      ipv6_cidr_block:                                <computed>
      main_route_table_id:                            <computed>
      owner_id:                                       <computed>
      tags.%:                                         "2"
      tags.Name:                                      "handson"
      tags.Terraform:                                 "true"

Plan: 57 to add, 0 to change, 0 to destroy.

------------------------------------------------------------------------

Note: You didn't specify an "-out" parameter to save this plan, so Terraform
can't guarantee that exactly these actions will be performed if
"terraform apply" is subsequently run.

/templates #
dulao5 commented 5 years ago
Error: Error applying plan:

1 error(s) occurred:

* module.service.aws_ecs_service.this: 1 error(s) occurred:

* aws_ecs_service.this: InvalidParameterException: The target group with targetGroupArn arn:aws:elasticloadbalancing:ap-northeast-1:177657369922:targetgroup/tf-20190320081700300900000003/0090cf3a02926c68 does not have an associated load balancer.
    status code: 400, request id: d24f970b-4ae8-11e9-ae5d-878aa584abdc "handson"
dulao5 commented 5 years ago

もう一回実行するとできました

Plan: 1 to add, 0 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

module.service.aws_ecs_service.this: Creating...
  cluster:                                            "" => "handson"
  deployment_controller.#:                            "" => "1"
  deployment_controller.0.type:                       "" => "ECS"
  deployment_maximum_percent:                         "" => "200"
  deployment_minimum_healthy_percent:                 "" => "100"
  desired_count:                                      "" => "1"
  enable_ecs_managed_tags:                            "" => "false"
  health_check_grace_period_seconds:                  "" => "10"
  iam_role:                                           "" => "<computed>"
  launch_type:                                        "" => "FARGATE"
  load_balancer.#:                                    "" => "1"
  load_balancer.3287315381.container_name:            "" => "nginx"
  load_balancer.3287315381.container_port:            "" => "80"
  load_balancer.3287315381.elb_name:                  "" => ""
  load_balancer.3287315381.target_group_arn:          "" => "arn:aws:elasticloadbalancing:ap-northeast-1:177657369922:targetgroup/tf-20190320081700300900000003/0090cf3a02926c68"
  name:                                               "" => "handson"
  network_configuration.#:                            "" => "1"
  network_configuration.0.assign_public_ip:           "" => "false"
  network_configuration.0.security_groups.#:          "" => "1"
  network_configuration.0.security_groups.1881212185: "" => "sg-06d043aed1851e68d"
  network_configuration.0.subnets.#:                  "" => "3"
  network_configuration.0.subnets.2845561120:         "" => "subnet-092c1836ff84153ed"
  network_configuration.0.subnets.3289614374:         "" => "subnet-0572a46b9747a1bce"
  network_configuration.0.subnets.3777114416:         "" => "subnet-079518bb1bdf98b7a"
  placement_strategy.#:                               "" => "<computed>"
  platform_version:                                   "" => "<computed>"
  scheduling_strategy:                                "" => "REPLICA"
  task_definition:                                    "" => "arn:aws:ecs:ap-northeast-1:177657369922:task-definition/handson:1"
module.service.aws_ecs_service.this: Creation complete after 1s (ID: arn:aws:ecs:ap-northeast-1:177657369922:service/handson)

Apply complete! Resources: 1 added, 0 changed, 0 destroyed.

Outputs:

dns_name = handson-659967882.ap-northeast-1.elb.amazonaws.com