Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add launch template and the auto scaling group to the stack #15

Merged
merged 41 commits into from
Sep 8, 2023
Merged

Conversation

kunduso
Copy link
Owner

@kunduso kunduso commented Sep 8, 2023

This PR closes #12 and #14

@kunduso kunduso self-assigned this Sep 8, 2023
@kunduso kunduso temporarily deployed to production September 8, 2023 21:47 — with GitHub Actions Inactive
@infracost
Copy link

infracost bot commented Sep 8, 2023

💰 Infracost estimate: monthly cost will increase by $206 📈

Project Cost change New monthly cost
kunduso/add-asg-elb-terraform +$206 $206
Infracost output
──────────────────────────────────
Project: kunduso/add-asg-elb-terraform

+ aws_autoscaling_group.application
  +$91

    + aws_launch_template.application
    
        + Instance usage (Linux/UNIX, on-demand, t3.medium)
          +$91
    
        + CPU credits
          $0.00

- aws_cloudwatch_log_group.cw_loggroup
  Monthly cost depends on usage

    - Data ingested
      Monthly cost depends on usage
        -$0.50 per GB

    - Archival Storage
      Monthly cost depends on usage
        -$0.03 per GB

    - Insights queries data scanned
      Monthly cost depends on usage
        -$0.005 per GB

+ aws_cloudwatch_metric_alarm.asg_cpu_alarm_down
  +$0.10

    + Standard resolution
      +$0.10

+ aws_cloudwatch_metric_alarm.asg_cpu_alarm_up
  +$0.10

    + Standard resolution
      +$0.10

+ aws_lb.front
  +$16

    + Application load balancer
      +$16

    + Load balancer capacity units
      Monthly cost depends on usage
        +$5.84 per LCU

+ aws_nat_gateway.public[0]
  +$33

    + NAT gateway
      +$33

    + Data processed
      Monthly cost depends on usage
        +$0.045 per GB

+ aws_nat_gateway.public[1]
  +$33

    + NAT gateway
      +$33

    + Data processed
      Monthly cost depends on usage
        +$0.045 per GB

+ aws_nat_gateway.public[2]
  +$33

    + NAT gateway
      +$33

    + Data processed
      Monthly cost depends on usage
        +$0.045 per GB

Monthly cost change for kunduso/add-asg-elb-terraform
Amount:  +$206 ($0.00 → $206)

──────────────────────────────────
Key: ~ changed, + added, - removed

44 cloud resources were detected:
∙ 7 were estimated, 5 of which include usage-based costs, see https://infracost.io/usage-file
∙ 37 were free, rerun with --show-skipped to see details

Infracost estimate: monthly cost will increase by $206 ↑
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━┓
┃ Project                                            ┃ Cost change ┃ New monthly cost ┃
┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╋━━━━━━━━━━━━━╋━━━━━━━━━━━━━━━━━━┫
┃ kunduso/add-asg-elb-terraform                      ┃       +$206 ┃ $206             ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┻━━━━━━━━━━━━━┻━━━━━━━━━━━━━━━━━━┛
This comment will be updated when the cost estimate changes.

@github-actions
Copy link

github-actions bot commented Sep 8, 2023

💰 Infracost estimate: monthly cost will increase by $206 📈

Project Cost change New monthly cost
kunduso/add-asg-elb-terraform/TFplan.JSON +$206 $206
Infracost output
──────────────────────────────────
Project: kunduso/add-asg-elb-terraform/TFplan.JSON

+ aws_autoscaling_group.application
  +$91

    + aws_launch_template.application
    
        + Instance usage (Linux/UNIX, on-demand, t3.medium)
          +$91
    
        + CPU credits
          $0.00

+ aws_cloudwatch_metric_alarm.asg_cpu_alarm_down
  +$0.10

    + Standard resolution
      +$0.10

+ aws_cloudwatch_metric_alarm.asg_cpu_alarm_up
  +$0.10

    + Standard resolution
      +$0.10

+ aws_lb.front
  +$16

    + Application load balancer
      +$16

    + Load balancer capacity units
      Monthly cost depends on usage
        +$5.84 per LCU

+ aws_nat_gateway.public[0]
  +$33

    + NAT gateway
      +$33

    + Data processed
      Monthly cost depends on usage
        +$0.045 per GB

+ aws_nat_gateway.public[1]
  +$33

    + NAT gateway
      +$33

    + Data processed
      Monthly cost depends on usage
        +$0.045 per GB

+ aws_nat_gateway.public[2]
  +$33

    + NAT gateway
      +$33

    + Data processed
      Monthly cost depends on usage
        +$0.045 per GB

Monthly cost change for kunduso/add-asg-elb-terraform/TFplan.JSON
Amount:  +$206 ($0.00 → $206)

──────────────────────────────────
Key: ~ changed, + added, - removed

44 cloud resources were detected:
∙ 7 were estimated, 5 of which include usage-based costs, see https://infracost.io/usage-file
∙ 37 were free:
  ∙ 6 x aws_route_table_association
  ∙ 6 x aws_subnet
  ∙ 4 x aws_route
  ∙ 4 x aws_route_table
  ∙ 3 x aws_eip
  ∙ 2 x aws_autoscaling_policy
  ∙ 2 x aws_security_group
  ∙ 1 x aws_autoscaling_attachment
  ∙ 1 x aws_default_security_group
  ∙ 1 x aws_iam_instance_profile
  ∙ 1 x aws_iam_role
  ∙ 1 x aws_iam_role_policy_attachment
  ∙ 1 x aws_internet_gateway
  ∙ 1 x aws_launch_template
  ∙ 1 x aws_lb_listener
  ∙ 1 x aws_lb_target_group
  ∙ 1 x aws_vpc

Infracost estimate: monthly cost will increase by $206 ↑
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━┓
┃ Project                                            ┃ Cost change ┃ New monthly cost ┃
┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╋━━━━━━━━━━━━━╋━━━━━━━━━━━━━━━━━━┫
┃ kunduso/add-asg-elb-terraform/TFplan.JSON          ┃       +$206 ┃ $206             ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┻━━━━━━━━━━━━━┻━━━━━━━━━━━━━━━━━━┛
This comment will be updated when the cost estimate changes.

@github-actions
Copy link

github-actions bot commented Sep 8, 2023

Terraform Format and Style 🖌success

Terraform Initialization ⚙️success

Terraform Plan 📖success

Terraform Validation 🤖success

Show Plan

terraform
data.aws_ami.amazon_ami: Reading...
data.aws_availability_zones.available: Reading...
data.aws_availability_zones.available: Read complete after 1s [id=us-east-2]
data.aws_ami.amazon_ami: Read complete after 1s [id=ami-0ec5c7d8262c1f6b2]

Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # aws_autoscaling_attachment.attach-app will be created
  + resource "aws_autoscaling_attachment" "attach-app" {
      + autoscaling_group_name = (known after apply)
      + id                     = (known after apply)
      + lb_target_group_arn    = (known after apply)
    }

  # aws_autoscaling_group.application will be created
  + resource "aws_autoscaling_group" "application" {
      + arn                       = (known after apply)
      + availability_zones        = (known after apply)
      + default_cooldown          = (known after apply)
      + desired_capacity          = 3
      + force_delete              = false
      + force_delete_warm_pool    = false
      + health_check_grace_period = 480
      + health_check_type         = "ELB"
      + id                        = (known after apply)
      + max_size                  = 6
      + metrics_granularity       = "1Minute"
      + min_size                  = 3
      + name                      = "app-3"
      + name_prefix               = (known after apply)
      + predicted_capacity        = (known after apply)
      + protect_from_scale_in     = false
      + service_linked_role_arn   = (known after apply)
      + vpc_zone_identifier       = (known after apply)
      + wait_for_capacity_timeout = "10m"
      + warm_pool_size            = (known after apply)

      + instance_refresh {
          + strategy = "Rolling"
          + triggers = [
              + "launch_template",
            ]

          + preferences {
              + min_healthy_percentage = 50
              + skip_matching          = true
            }
        }

      + launch_template {
          + id      = (known after apply)
          + name    = (known after apply)
          + version = (known after apply)
        }

      + tag {
          + key                 = "Name"
          + propagate_at_launch = true
          + value               = "app-3"
        }
    }

  # aws_autoscaling_policy.asg_policy_down will be created
  + resource "aws_autoscaling_policy" "asg_policy_down" {
      + adjustment_type         = "ChangeInCapacity"
      + arn                     = (known after apply)
      + autoscaling_group_name  = "app-3"
      + cooldown                = 300
      + enabled                 = true
      + id                      = (known after apply)
      + metric_aggregation_type = (known after apply)
      + name                    = "asg_policy_down"
      + policy_type             = "SimpleScaling"
      + scaling_adjustment      = -1
    }

  # aws_autoscaling_policy.asg_policy_up will be created
  + resource "aws_autoscaling_policy" "asg_policy_up" {
      + adjustment_type         = "ChangeInCapacity"
      + arn                     = (known after apply)
      + autoscaling_group_name  = "app-3"
      + cooldown                = 300
      + enabled                 = true
      + id                      = (known after apply)
      + metric_aggregation_type = (known after apply)
      + name                    = "asg_policy_up"
      + policy_type             = "SimpleScaling"
      + scaling_adjustment      = 1
    }

  # aws_cloudwatch_metric_alarm.asg_cpu_alarm_down will be created
  + resource "aws_cloudwatch_metric_alarm" "asg_cpu_alarm_down" {
      + actions_enabled                       = true
      + alarm_actions                         = (known after apply)
      + alarm_description                     = "This metric monitors ec2 cpu utilization"
      + alarm_name                            = "asg_cpu_alarm_down"
      + arn                                   = (known after apply)
      + comparison_operator                   = "GreaterThanOrEqualToThreshold"
      + dimensions                            = {
          + "AutoScalingGroupName" = "app-3"
        }
      + evaluate_low_sample_count_percentiles = (known after apply)
      + evaluation_periods                    = 2
      + id                                    = (known after apply)
      + metric_name                           = "CPUUtilization"
      + namespace                             = "AWS/EC2"
      + period                                = 60
      + statistic                             = "Average"
      + tags_all                              = {
          + "Source" = "https://github.com/kunduso/add-asg-elb-terraform"
        }
      + threshold                             = 30
      + treat_missing_data                    = "missing"
    }

  # aws_cloudwatch_metric_alarm.asg_cpu_alarm_up will be created
  + resource "aws_cloudwatch_metric_alarm" "asg_cpu_alarm_up" {
      + actions_enabled                       = true
      + alarm_actions                         = (known after apply)
      + alarm_description                     = "This metric monitors ec2 cpu utilization"
      + alarm_name                            = "asg_cpu_alarm_up"
      + arn                                   = (known after apply)
      + comparison_operator                   = "GreaterThanOrEqualToThreshold"
      + dimensions                            = {
          + "AutoScalingGroupName" = "app-3"
        }
      + evaluate_low_sample_count_percentiles = (known after apply)
      + evaluation_periods                    = 2
      + id                                    = (known after apply)
      + metric_name                           = "CPUUtilization"
      + namespace                             = "AWS/EC2"
      + period                                = 60
      + statistic                             = "Average"
      + tags_all                              = {
          + "Source" = "https://github.com/kunduso/add-asg-elb-terraform"
        }
      + threshold                             = 70
      + treat_missing_data                    = "missing"
    }

  # aws_default_security_group.default will be created
  + resource "aws_default_security_group" "default" {
      + arn                    = (known after apply)
      + description            = (known after apply)
      + egress                 = [
          + {
              + cidr_blocks      = [
                  + "0.0.0.0/0",
                ]
              + description      = ""
              + from_port        = 0
              + ipv6_cidr_blocks = []
              + prefix_list_ids  = []
              + protocol         = "-1"
              + security_groups  = []
              + self             = false
              + to_port          = 0
            },
        ]
      + id                     = (known after apply)
      + ingress                = [
          + {
              + cidr_blocks      = []
              + description      = ""
              + from_port        = 0
              + ipv6_cidr_blocks = []
              + prefix_list_ids  = []
              + protocol         = "-1"
              + security_groups  = []
              + self             = true
              + to_port          = 0
            },
        ]
      + name                   = (known after apply)
      + name_prefix            = (known after apply)
      + owner_id               = (known after apply)
      + revoke_rules_on_delete = false
      + tags_all               = {
          + "Source" = "https://github.com/kunduso/add-asg-elb-terraform"
        }
      + vpc_id                 = (known after apply)
    }

  # aws_eip.nat_gateway[0] will be created
  + resource "aws_eip" "nat_gateway" {
      + allocation_id        = (known after apply)
      + association_id       = (known after apply)
      + carrier_ip           = (known after apply)
      + customer_owned_ip    = (known after apply)
      + domain               = "vpc"
      + id                   = (known after apply)
      + instance             = (known after apply)
      + network_border_group = (known after apply)
      + network_interface    = (known after apply)
      + private_dns          = (known after apply)
      + private_ip           = (known after apply)
      + public_dns           = (known after apply)
      + public_ip            = (known after apply)
      + public_ipv4_pool     = (known after apply)
      + tags_all             = {
          + "Source" = "https://github.com/kunduso/add-asg-elb-terraform"
        }
      + vpc                  = (known after apply)
    }

  # aws_eip.nat_gateway[1] will be created
  + resource "aws_eip" "nat_gateway" {
      + allocation_id        = (known after apply)
      + association_id       = (known after apply)
      + carrier_ip           = (known after apply)
      + customer_owned_ip    = (known after apply)
      + domain               = "vpc"
      + id                   = (known after apply)
      + instance             = (known after apply)
      + network_border_group = (known after apply)
      + network_interface    = (known after apply)
      + private_dns          = (known after apply)
      + private_ip           = (known after apply)
      + public_dns           = (known after apply)
      + public_ip            = (known after apply)
      + public_ipv4_pool     = (known after apply)
      + tags_all             = {
          + "Source" = "https://github.com/kunduso/add-asg-elb-terraform"
        }
      + vpc                  = (known after apply)
    }

  # aws_eip.nat_gateway[2] will be created
  + resource "aws_eip" "nat_gateway" {
      + allocation_id        = (known after apply)
      + association_id       = (known after apply)
      + carrier_ip           = (known after apply)
      + customer_owned_ip    = (known after apply)
      + domain               = "vpc"
      + id                   = (known after apply)
      + instance             = (known after apply)
      + network_border_group = (known after apply)
      + network_interface    = (known after apply)
      + private_dns          = (known after apply)
      + private_ip           = (known after apply)
      + public_dns           = (known after apply)
      + public_ip            = (known after apply)
      + public_ipv4_pool     = (known after apply)
      + tags_all             = {
          + "Source" = "https://github.com/kunduso/add-asg-elb-terraform"
        }
      + vpc                  = (known after apply)
    }

  # aws_iam_instance_profile.ec2_profile will be created
  + resource "aws_iam_instance_profile" "ec2_profile" {
      + arn         = (known after apply)
      + create_date = (known after apply)
      + id          = (known after apply)
      + name        = "ec2_profile"
      + name_prefix = (known after apply)
      + path        = "/"
      + role        = "ec2_role"
      + tags_all    = {
          + "Source" = "https://github.com/kunduso/add-asg-elb-terraform"
        }
      + unique_id   = (known after apply)
    }

  # aws_iam_role.ec2_role will be created
  + resource "aws_iam_role" "ec2_role" {
      + arn                   = (known after apply)
      + assume_role_policy    = jsonencode(
            {
              + Statement = [
                  + {
                      + Action    = "sts:AssumeRole"
                      + Effect    = "Allow"
                      + Principal = {
                          + Service = "ec2.amazonaws.com"
                        }
                      + Sid       = ""
                    },
                ]
              + Version   = "2012-10-17"
            }
        )
      + create_date           = (known after apply)
      + force_detach_policies = false
      + id                    = (known after apply)
      + managed_policy_arns   = (known after apply)
      + max_session_duration  = 3600
      + name                  = "ec2_role"
      + name_prefix           = (known after apply)
      + path                  = "/"
      + role_last_used        = (known after apply)
      + tags_all              = {
          + "Source" = "https://github.com/kunduso/add-asg-elb-terraform"
        }
      + unique_id             = (known after apply)
    }

  # aws_iam_role_policy_attachment.custom will be created
  + resource "aws_iam_role_policy_attachment" "custom" {
      + id         = (known after apply)
      + policy_arn = "arn:aws:iam::aws:policy/AmazonSSMManagedInstanceCore"
      + role       = "ec2_role"
    }

  # aws_internet_gateway.this-igw will be created
  + resource "aws_internet_gateway" "this-igw" {
      + arn      = (known after apply)
      + id       = (known after apply)
      + owner_id = (known after apply)
      + tags     = {
          + "Name" = "app-3-gateway"
        }
      + tags_all = {
          + "Name"   = "app-3-gateway"
          + "Source" = "https://github.com/kunduso/add-asg-elb-terraform"
        }
      + vpc_id   = (known after apply)
    }

  # aws_launch_template.application will be created
  + resource "aws_launch_template" "application" {
      + arn             = (known after apply)
      + default_version = (known after apply)
      + id              = (known after apply)
      + image_id        = "ami-0ec5c7d8262c1f6b2"
      + instance_type   = "t3.medium"
      + latest_version  = (known after apply)
      + name            = (known after apply)
      + name_prefix     = (known after apply)
      + tags_all        = {
          + "Source" = "https://github.com/kunduso/add-asg-elb-terraform"
        }
      + user_data       = "IyEvYmluL2Jhc2gKeXVtIHVwZGF0ZSAteQp5dW0gaW5zdGFsbCAteSBodHRwZC54ODZfNjQKeXVtIGluc3RhbGwgLXkganEKUkVHSU9OX0FWX1pPTkU9YGN1cmwgLXMgaHR0cDovLzE2OS4yNTQuMTY5LjI1NC9sYXRlc3QvZHluYW1pYy9pbnN0YW5jZS1pZGVudGl0eS9kb2N1bWVudCB8IGpxIC5hdmFpbGFiaWxpdHlab25lIC1yYApzeXN0ZW1jdGwgc3RhcnQgaHR0cGQuc2VydmljZQpzeXN0ZW1jdGwgZW5hYmxlIGh0dHBkLnNlcnZpY2UKZWNobyAiSGVsbG8gV29ybGQgZnJvbSAkKGhvc3RuYW1lIC1mKSBmcm9tIHRoZSBhdmFpbGFiaWxpdHkgem9uZTogJFJFR0lPTl9BVl9aT05FIiA+IC92YXIvd3d3L2h0bWwvaW5kZXguaHRtbA=="

      + iam_instance_profile {
          + name = "ec2_profile"
        }

      + network_interfaces {
          + security_groups = (known after apply)
        }
    }

  # aws_lb.front will be created
  + resource "aws_lb" "front" {
      + arn                                         = (known after apply)
      + arn_suffix                                  = (known after apply)
      + desync_mitigation_mode                      = "defensive"
      + dns_name                                    = (known after apply)
      + drop_invalid_header_fields                  = false
      + enable_deletion_protection                  = false
      + enable_http2                                = true
      + enable_tls_version_and_cipher_suite_headers = false
      + enable_waf_fail_open                        = false
      + enable_xff_client_port                      = false
      + id                                          = (known after apply)
      + idle_timeout                                = 60
      + internal                                    = false
      + ip_address_type                             = (known after apply)
      + load_balancer_type                          = "application"
      + name                                        = "app-3"
      + preserve_host_header                        = false
      + security_groups                             = (known after apply)
      + subnets                                     = (known after apply)
      + tags                                        = {
          + "Environment" = "Development"
        }
      + tags_all                                    = {
          + "Environment" = "Development"
          + "Source"      = "https://github.com/kunduso/add-asg-elb-terraform"
        }
      + vpc_id                                      = (known after apply)
      + xff_header_processing_mode                  = "append"
      + zone_id                                     = (known after apply)
    }

  # aws_lb_listener.front_end will be created
  + resource "aws_lb_listener" "front_end" {
      + arn               = (known after apply)
      + id                = (known after apply)
      + load_balancer_arn = (known after apply)
      + port              = 80
      + protocol          = "HTTP"
      + ssl_policy        = (known after apply)
      + tags_all          = {
          + "Source" = "https://github.com/kunduso/add-asg-elb-terraform"
        }

      + default_action {
          + order            = (known after apply)
          + target_group_arn = (known after apply)
          + type             = "forward"
        }
    }

  # aws_lb_target_group.front will be created
  + resource "aws_lb_target_group" "front" {
      + arn                                = (known after apply)
      + arn_suffix                         = (known after apply)
      + connection_termination             = false
      + deregistration_delay               = "300"
      + id                                 = (known after apply)
      + ip_address_type                    = (known after apply)
      + lambda_multi_value_headers_enabled = false
      + load_balancing_algorithm_type      = (known after apply)
      + load_balancing_cross_zone_enabled  = (known after apply)
      + name                               = "app-3-front"
      + port                               = 80
      + preserve_client_ip                 = (known after apply)
      + protocol                           = "HTTP"
      + protocol_version                   = (known after apply)
      + proxy_protocol_v2                  = false
      + slow_start                         = 0
      + tags_all                           = {
          + "Source" = "https://github.com/kunduso/add-asg-elb-terraform"
        }
      + target_type                        = "instance"
      + vpc_id                             = (known after apply)

      + health_check {
          + enabled             = true
          + healthy_threshold   = 3
          + interval            = 10
          + matcher             = "200"
          + path                = "/"
          + port                = "traffic-port"
          + protocol            = "HTTP"
          + timeout             = 3
          + unhealthy_threshold = 2
        }
    }

  # aws_nat_gateway.public[0] will be created
  + resource "aws_nat_gateway" "public" {
      + allocation_id        = (known after apply)
      + association_id       = (known after apply)
      + connectivity_type    = "public"
      + id                   = (known after apply)
      + network_interface_id = (known after apply)
      + private_ip           = (known after apply)
      + public_ip            = (known after apply)
      + subnet_id            = (known after apply)
      + tags                 = {
          + "Name" = "app-3-NAT-1"
        }
      + tags_all             = {
          + "Name"   = "app-3-NAT-1"
          + "Source" = "https://github.com/kunduso/add-asg-elb-terraform"
        }
    }

  # aws_nat_gateway.public[1] will be created
  + resource "aws_nat_gateway" "public" {
      + allocation_id        = (known after apply)
      + association_id       = (known after apply)
      + connectivity_type    = "public"
      + id                   = (known after apply)
      + network_interface_id = (known after apply)
      + private_ip           = (known after apply)
      + public_ip            = (known after apply)
      + subnet_id            = (known after apply)
      + tags                 = {
          + "Name" = "app-3-NAT-2"
        }
      + tags_all             = {
          + "Name"   = "app-3-NAT-2"
          + "Source" = "https://github.com/kunduso/add-asg-elb-terraform"
        }
    }

  # aws_nat_gateway.public[2] will be created
  + resource "aws_nat_gateway" "public" {
      + allocation_id        = (known after apply)
      + association_id       = (known after apply)
      + connectivity_type    = "public"
      + id                   = (known after apply)
      + network_interface_id = (known after apply)
      + private_ip           = (known after apply)
      + public_ip            = (known after apply)
      + subnet_id            = (known after apply)
      + tags                 = {
          + "Name" = "app-3-NAT-3"
        }
      + tags_all             = {
          + "Name"   = "app-3-NAT-3"
          + "Source" = "https://github.com/kunduso/add-asg-elb-terraform"
        }
    }

  # aws_route.internet-route will be created
  + resource "aws_route" "internet-route" {
      + destination_cidr_block = "0.0.0.0/0"
      + gateway_id             = (known after apply)
      + id                     = (known after apply)
      + instance_id            = (known after apply)
      + instance_owner_id      = (known after apply)
      + network_interface_id   = (known after apply)
      + origin                 = (known after apply)
      + route_table_id         = (known after apply)
      + state                  = (known after apply)
    }

  # aws_route.private-route[0] will be created
  + resource "aws_route" "private-route" {
      + destination_cidr_block = "0.0.0.0/0"
      + gateway_id             = (known after apply)
      + id                     = (known after apply)
      + instance_id            = (known after apply)
      + instance_owner_id      = (known after apply)
      + network_interface_id   = (known after apply)
      + origin                 = (known after apply)
      + route_table_id         = (known after apply)
      + state                  = (known after apply)
    }

  # aws_route.private-route[1] will be created
  + resource "aws_route" "private-route" {
      + destination_cidr_block = "0.0.0.0/0"
      + gateway_id             = (known after apply)
      + id                     = (known after apply)
      + instance_id            = (known after apply)
      + instance_owner_id      = (known after apply)
      + network_interface_id   = (known after apply)
      + origin                 = (known after apply)
      + route_table_id         = (known after apply)
      + state                  = (known after apply)
    }

  # aws_route.private-route[2] will be created
  + resource "aws_route" "private-route" {
      + destination_cidr_block = "0.0.0.0/0"
      + gateway_id             = (known after apply)
      + id                     = (known after apply)
      + instance_id            = (known after apply)
      + instance_owner_id      = (known after apply)
      + network_interface_id   = (known after apply)
      + origin                 = (known after apply)
      + route_table_id         = (known after apply)
      + state                  = (known after apply)
    }

  # aws_route_table.private[0] will be created
  + resource "aws_route_table" "private" {
      + arn              = (known after apply)
      + id               = (known after apply)
      + owner_id         = (known after apply)
      + propagating_vgws = (known after apply)
      + route            = (known after apply)
      + tags             = {
          + "Name" = "app-3-route-table-1"
        }
      + tags_all         = {
          + "Name"   = "app-3-route-table-1"
          + "Source" = "https://github.com/kunduso/add-asg-elb-terraform"
        }
      + vpc_id           = (known after apply)
    }

  # aws_route_table.private[1] will be created
  + resource "aws_route_table" "private" {
      + arn              = (known after apply)
      + id               = (known after apply)
      + owner_id         = (known after apply)
      + propagating_vgws = (known after apply)
      + route            = (known after apply)
      + tags             = {
          + "Name" = "app-3-route-table-2"
        }
      + tags_all         = {
          + "Name"   = "app-3-route-table-2"
          + "Source" = "https://github.com/kunduso/add-asg-elb-terraform"
        }
      + vpc_id           = (known after apply)
    }

  # aws_route_table.private[2] will be created
  + resource "aws_route_table" "private" {
      + arn              = (known after apply)
      + id               = (known after apply)
      + owner_id         = (known after apply)
      + propagating_vgws = (known after apply)
      + route            = (known after apply)
      + tags             = {
          + "Name" = "app-3-route-table-3"
        }
      + tags_all         = {
          + "Name"   = "app-3-route-table-3"
          + "Source" = "https://github.com/kunduso/add-asg-elb-terraform"
        }
      + vpc_id           = (known after apply)
    }

  # aws_route_table.public will be created
  + resource "aws_route_table" "public" {
      + arn              = (known after apply)
      + id               = (known after apply)
      + owner_id         = (known after apply)
      + propagating_vgws = (known after apply)
      + route            = (known after apply)
      + tags             = {
          + "Name" = "app-3-public"
        }
      + tags_all         = {
          + "Name"   = "app-3-public"
          + "Source" = "https://github.com/kunduso/add-asg-elb-terraform"
        }
      + vpc_id           = (known after apply)
    }

  # aws_route_table_association.private[0] will be created
  + resource "aws_route_table_association" "private" {
      + id             = (known after apply)
      + route_table_id = (known after apply)
      + subnet_id      = (known after apply)
    }

  # aws_route_table_association.private[1] will be created
  + resource "aws_route_table_association" "private" {
      + id             = (known after apply)
      + route_table_id = (known after apply)
      + subnet_id      = (known after apply)
    }

  # aws_route_table_association.private[2] will be created
  + resource "aws_route_table_association" "private" {
      + id             = (known after apply)
      + route_table_id = (known after apply)
      + subnet_id      = (known after apply)
    }

  # aws_route_table_association.public[0] will be created
  + resource "aws_route_table_association" "public" {
      + id             = (known after apply)
      + route_table_id = (known after apply)
      + subnet_id      = (known after apply)
    }

  # aws_route_table_association.public[1] will be created
  + resource "aws_route_table_association" "public" {
      + id             = (known after apply)
      + route_table_id = (known after apply)
      + subnet_id      = (known after apply)
    }

  # aws_route_table_association.public[2] will be created
  + resource "aws_route_table_association" "public" {
      + id             = (known after apply)
      + route_table_id = (known after apply)
      + subnet_id      = (known after apply)
    }

  # aws_security_group.asg_lb_security_group will be created
  + resource "aws_security_group" "asg_lb_security_group" {
      + arn                    = (known after apply)
      + description            = "Allow inbound and outbound traffic to load balancer from the internet."
      + egress                 = [
          + {
              + cidr_blocks      = [
                  + "0.0.0.0/0",
                ]
              + description      = ""
              + from_port        = 0
              + ipv6_cidr_blocks = []
              + prefix_list_ids  = []
              + protocol         = "-1"
              + security_groups  = []
              + self             = false
              + to_port          = 0
            },
        ]
      + id                     = (known after apply)
      + ingress                = [
          + {
              + cidr_blocks      = [
                  + "0.0.0.0/0",
                ]
              + description      = ""
              + from_port        = 80
              + ipv6_cidr_blocks = []
              + prefix_list_ids  = []
              + protocol         = "tcp"
              + security_groups  = []
              + self             = false
              + to_port          = 80
            },
        ]
      + name                   = "App-3-ASG-LB-SG-IN"
      + name_prefix            = (known after apply)
      + owner_id               = (known after apply)
      + revoke_rules_on_delete = false
      + tags                   = {
          + "Name" = "app-3-asg-lb-sg"
        }
      + tags_all               = {
          + "Name"   = "app-3-asg-lb-sg"
          + "Source" = "https://github.com/kunduso/add-asg-elb-terraform"
        }
      + vpc_id                 = (known after apply)
    }

  # aws_security_group.ec2_security_group will be created
  + resource "aws_security_group" "ec2_security_group" {
      + arn                    = (known after apply)
      + description            = "Allow inbound and outbound traffic to EC2 instances from load balancer security group"
      + egress                 = [
          + {
              + cidr_blocks      = [
                  + "0.0.0.0/0",
                ]
              + description      = ""
              + from_port        = 0
              + ipv6_cidr_blocks = []
              + prefix_list_ids  = []
              + protocol         = "-1"
              + security_groups  = []
              + self             = false
              + to_port          = 0
            },
        ]
      + id                     = (known after apply)
      + ingress                = [
          + {
              + cidr_blocks      = []
              + description      = ""
              + from_port        = 80
              + ipv6_cidr_blocks = []
              + prefix_list_ids  = []
              + protocol         = "tcp"
              + security_groups  = (known after apply)
              + self             = false
              + to_port          = 80
            },
        ]
      + name                   = "App-3-Instance-SG"
      + name_prefix            = (known after apply)
      + owner_id               = (known after apply)
      + revoke_rules_on_delete = false
      + tags                   = {
          + "Name" = "app-3-instance-sg"
        }
      + tags_all               = {
          + "Name"   = "app-3-instance-sg"
          + "Source" = "https://github.com/kunduso/add-asg-elb-terraform"
        }
      + vpc_id                 = (known after apply)
    }

  # aws_subnet.private[0] will be created
  + resource "aws_subnet" "private" {
      + arn                                            = (known after apply)
      + assign_ipv6_address_on_creation                = false
      + availability_zone                              = "us-east-2a"
      + availability_zone_id                           = (known after apply)
      + cidr_block                                     = "10.20.30.0/27"
      + enable_dns64                                   = false
      + enable_resource_name_dns_a_record_on_launch    = false
      + enable_resource_name_dns_aaaa_record_on_launch = false
      + id                                             = (known after apply)
      + ipv6_cidr_block_association_id                 = (known after apply)
      + ipv6_native                                    = false
      + map_public_ip_on_launch                        = false
      + owner_id                                       = (known after apply)
      + private_dns_hostname_type_on_launch            = (known after apply)
      + tags                                           = {
          + "Name" = "app-3-private-1"
        }
      + tags_all                                       = {
          + "Name"   = "app-3-private-1"
          + "Source" = "https://github.com/kunduso/add-asg-elb-terraform"
        }
      + vpc_id                                         = (known after apply)
    }

  # aws_subnet.private[1] will be created
  + resource "aws_subnet" "private" {
      + arn                                            = (known after apply)
      + assign_ipv6_address_on_creation                = false
      + availability_zone                              = "us-east-2b"
      + availability_zone_id                           = (known after apply)
      + cidr_block                                     = "10.20.30.32/27"
      + enable_dns64                                   = false
      + enable_resource_name_dns_a_record_on_launch    = false
      + enable_resource_name_dns_aaaa_record_on_launch = false
      + id                                             = (known after apply)
      + ipv6_cidr_block_association_id                 = (known after apply)
      + ipv6_native                                    = false
      + map_public_ip_on_launch                        = false
      + owner_id                                       = (known after apply)
      + private_dns_hostname_type_on_launch            = (known after apply)
      + tags                                           = {
          + "Name" = "app-3-private-2"
        }
      + tags_all                                       = {
          + "Name"   = "app-3-private-2"
          + "Source" = "https://github.com/kunduso/add-asg-elb-terraform"
        }
      + vpc_id                                         = (known after apply)
    }

  # aws_subnet.private[2] will be created
  + resource "aws_subnet" "private" {
      + arn                                            = (known after apply)
      + assign_ipv6_address_on_creation                = false
      + availability_zone                              = "us-east-2c"
      + availability_zone_id                           = (known after apply)
      + cidr_block                                     = "10.20.30.64/27"
      + enable_dns64                                   = false
      + enable_resource_name_dns_a_record_on_launch    = false
      + enable_resource_name_dns_aaaa_record_on_launch = false
      + id                                             = (known after apply)
      + ipv6_cidr_block_association_id                 = (known after apply)
      + ipv6_native                                    = false
      + map_public_ip_on_launch                        = false
      + owner_id                                       = (known after apply)
      + private_dns_hostname_type_on_launch            = (known after apply)
      + tags                                           = {
          + "Name" = "app-3-private-3"
        }
      + tags_all                                       = {
          + "Name"   = "app-3-private-3"
          + "Source" = "https://github.com/kunduso/add-asg-elb-terraform"
        }
      + vpc_id                                         = (known after apply)
    }

  # aws_subnet.public[0] will be created
  + resource "aws_subnet" "public" {
      + arn                                            = (known after apply)
      + assign_ipv6_address_on_creation                = false
      + availability_zone                              = "us-east-2a"
      + availability_zone_id                           = (known after apply)
      + cidr_block                                     = "10.20.30.96/27"
      + enable_dns64                                   = false
      + enable_resource_name_dns_a_record_on_launch    = false
      + enable_resource_name_dns_aaaa_record_on_launch = false
      + id                                             = (known after apply)
      + ipv6_cidr_block_association_id                 = (known after apply)
      + ipv6_native                                    = false
      + map_public_ip_on_launch                        = false
      + owner_id                                       = (known after apply)
      + private_dns_hostname_type_on_launch            = (known after apply)
      + tags                                           = {
          + "Name" = "app-3-public-1"
        }
      + tags_all                                       = {
          + "Name"   = "app-3-public-1"
          + "Source" = "https://github.com/kunduso/add-asg-elb-terraform"
        }
      + vpc_id                                         = (known after apply)
    }

  # aws_subnet.public[1] will be created
  + resource "aws_subnet" "public" {
      + arn                                            = (known after apply)
      + assign_ipv6_address_on_creation                = false
      + availability_zone                              = "us-east-2b"
      + availability_zone_id                           = (known after apply)
      + cidr_block                                     = "10.20.30.128/27"
      + enable_dns64                                   = false
      + enable_resource_name_dns_a_record_on_launch    = false
      + enable_resource_name_dns_aaaa_record_on_launch = false
      + id                                             = (known after apply)
      + ipv6_cidr_block_association_id                 = (known after apply)
      + ipv6_native                                    = false
      + map_public_ip_on_launch                        = false
      + owner_id                                       = (known after apply)
      + private_dns_hostname_type_on_launch            = (known after apply)
      + tags                                           = {
          + "Name" = "app-3-public-2"
        }
      + tags_all                                       = {
          + "Name"   = "app-3-public-2"
          + "Source" = "https://github.com/kunduso/add-asg-elb-terraform"
        }
      + vpc_id                                         = (known after apply)
    }

  # aws_subnet.public[2] will be created
  + resource "aws_subnet" "public" {
      + arn                                            = (known after apply)
      + assign_ipv6_address_on_creation                = false
      + availability_zone                              = "us-east-2c"
      + availability_zone_id                           = (known after apply)
      + cidr_block                                     = "10.20.30.160/27"
      + enable_dns64                                   = false
      + enable_resource_name_dns_a_record_on_launch    = false
      + enable_resource_name_dns_aaaa_record_on_launch = false
      + id                                             = (known after apply)
      + ipv6_cidr_block_association_id                 = (known after apply)
      + ipv6_native                                    = false
      + map_public_ip_on_launch                        = false
      + owner_id                                       = (known after apply)
      + private_dns_hostname_type_on_launch            = (known after apply)
      + tags                                           = {
          + "Name" = "app-3-public-3"
        }
      + tags_all                                       = {
          + "Name"   = "app-3-public-3"
          + "Source" = "https://github.com/kunduso/add-asg-elb-terraform"
        }
      + vpc_id                                         = (known after apply)
    }

  # aws_vpc.this will be created
  + resource "aws_vpc" "this" {
      + arn                                  = (known after apply)
      + cidr_block                           = "10.20.30.0/24"
      + default_network_acl_id               = (known after apply)
      + default_route_table_id               = (known after apply)
      + default_security_group_id            = (known after apply)
      + dhcp_options_id                      = (known after apply)
      + enable_dns_hostnames                 = true
      + enable_dns_support                   = true
      + enable_network_address_usage_metrics = (known after apply)
      + id                                   = (known after apply)
      + instance_tenancy                     = "default"
      + ipv6_association_id                  = (known after apply)
      + ipv6_cidr_block                      = (known after apply)
      + ipv6_cidr_block_network_border_group = (known after apply)
      + main_route_table_id                  = (known after apply)
      + owner_id                             = (known after apply)
      + tags                                 = {
          + "Name" = "app-3"
        }
      + tags_all                             = {
          + "Name"   = "app-3"
          + "Source" = "https://github.com/kunduso/add-asg-elb-terraform"
        }
    }

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

Changes to Outputs:
  + lb_endpoint = (known after apply)

Warning: 'launch_template' always triggers an instance refresh and can be removed

  with aws_autoscaling_group.application,
  on autoscaling.tf line 46, in resource "aws_autoscaling_group" "application":
  46:     triggers = ["launch_template"]

(and one more similar warning elsewhere)

─────────────────────────────────────────────────────────────────────────────

Saved the plan to: TFplan.JSON

To perform exactly these actions, run the following command to apply:
    terraform apply "TFplan.JSON"

Pushed by: @kunduso, Action: pull_request

@kunduso kunduso temporarily deployed to production September 8, 2023 21:51 — with GitHub Actions Inactive
@kunduso kunduso temporarily deployed to production September 8, 2023 21:51 — with GitHub Actions Inactive
Copy link

@github-advanced-security github-advanced-security bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

checkov found more than 10 potential problems in the proposed changes. Check the Files changed tab for more details.

@github-actions
Copy link

github-actions bot commented Sep 8, 2023

Terraform Format and Style 🖌success

Terraform Initialization ⚙️success

Terraform Plan 📖success

Terraform Validation 🤖success

Show Plan

terraform
data.aws_availability_zones.available: Reading...
data.aws_ami.amazon_ami: Reading...
data.aws_availability_zones.available: Read complete after 0s [id=us-east-2]
data.aws_ami.amazon_ami: Read complete after 0s [id=ami-0ec5c7d8262c1f6b2]

Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # aws_autoscaling_attachment.attach-app will be created
  + resource "aws_autoscaling_attachment" "attach-app" {
      + autoscaling_group_name = (known after apply)
      + id                     = (known after apply)
      + lb_target_group_arn    = (known after apply)
    }

  # aws_autoscaling_group.application will be created
  + resource "aws_autoscaling_group" "application" {
      + arn                       = (known after apply)
      + availability_zones        = (known after apply)
      + default_cooldown          = (known after apply)
      + desired_capacity          = 3
      + force_delete              = false
      + force_delete_warm_pool    = false
      + health_check_grace_period = 480
      + health_check_type         = "ELB"
      + id                        = (known after apply)
      + max_size                  = 6
      + metrics_granularity       = "1Minute"
      + min_size                  = 3
      + name                      = "app-3"
      + name_prefix               = (known after apply)
      + predicted_capacity        = (known after apply)
      + protect_from_scale_in     = false
      + service_linked_role_arn   = (known after apply)
      + vpc_zone_identifier       = (known after apply)
      + wait_for_capacity_timeout = "10m"
      + warm_pool_size            = (known after apply)

      + instance_refresh {
          + strategy = "Rolling"
          + triggers = [
              + "launch_template",
            ]

          + preferences {
              + min_healthy_percentage = 50
              + skip_matching          = true
            }
        }

      + launch_template {
          + id      = (known after apply)
          + name    = (known after apply)
          + version = (known after apply)
        }

      + tag {
          + key                 = "Name"
          + propagate_at_launch = true
          + value               = "app-3"
        }
    }

  # aws_autoscaling_policy.asg_policy_down will be created
  + resource "aws_autoscaling_policy" "asg_policy_down" {
      + adjustment_type         = "ChangeInCapacity"
      + arn                     = (known after apply)
      + autoscaling_group_name  = "app-3"
      + cooldown                = 300
      + enabled                 = true
      + id                      = (known after apply)
      + metric_aggregation_type = (known after apply)
      + name                    = "asg_policy_down"
      + policy_type             = "SimpleScaling"
      + scaling_adjustment      = -1
    }

  # aws_autoscaling_policy.asg_policy_up will be created
  + resource "aws_autoscaling_policy" "asg_policy_up" {
      + adjustment_type         = "ChangeInCapacity"
      + arn                     = (known after apply)
      + autoscaling_group_name  = "app-3"
      + cooldown                = 300
      + enabled                 = true
      + id                      = (known after apply)
      + metric_aggregation_type = (known after apply)
      + name                    = "asg_policy_up"
      + policy_type             = "SimpleScaling"
      + scaling_adjustment      = 1
    }

  # aws_cloudwatch_metric_alarm.asg_cpu_alarm_down will be created
  + resource "aws_cloudwatch_metric_alarm" "asg_cpu_alarm_down" {
      + actions_enabled                       = true
      + alarm_actions                         = (known after apply)
      + alarm_description                     = "This metric monitors ec2 cpu utilization"
      + alarm_name                            = "asg_cpu_alarm_down"
      + arn                                   = (known after apply)
      + comparison_operator                   = "GreaterThanOrEqualToThreshold"
      + dimensions                            = {
          + "AutoScalingGroupName" = "app-3"
        }
      + evaluate_low_sample_count_percentiles = (known after apply)
      + evaluation_periods                    = 2
      + id                                    = (known after apply)
      + metric_name                           = "CPUUtilization"
      + namespace                             = "AWS/EC2"
      + period                                = 60
      + statistic                             = "Average"
      + tags_all                              = {
          + "Source" = "https://github.com/kunduso/add-asg-elb-terraform"
        }
      + threshold                             = 30
      + treat_missing_data                    = "missing"
    }

  # aws_cloudwatch_metric_alarm.asg_cpu_alarm_up will be created
  + resource "aws_cloudwatch_metric_alarm" "asg_cpu_alarm_up" {
      + actions_enabled                       = true
      + alarm_actions                         = (known after apply)
      + alarm_description                     = "This metric monitors ec2 cpu utilization"
      + alarm_name                            = "asg_cpu_alarm_up"
      + arn                                   = (known after apply)
      + comparison_operator                   = "GreaterThanOrEqualToThreshold"
      + dimensions                            = {
          + "AutoScalingGroupName" = "app-3"
        }
      + evaluate_low_sample_count_percentiles = (known after apply)
      + evaluation_periods                    = 2
      + id                                    = (known after apply)
      + metric_name                           = "CPUUtilization"
      + namespace                             = "AWS/EC2"
      + period                                = 60
      + statistic                             = "Average"
      + tags_all                              = {
          + "Source" = "https://github.com/kunduso/add-asg-elb-terraform"
        }
      + threshold                             = 70
      + treat_missing_data                    = "missing"
    }

  # aws_default_security_group.default will be created
  + resource "aws_default_security_group" "default" {
      + arn                    = (known after apply)
      + description            = (known after apply)
      + egress                 = [
          + {
              + cidr_blocks      = [
                  + "0.0.0.0/0",
                ]
              + description      = ""
              + from_port        = 0
              + ipv6_cidr_blocks = []
              + prefix_list_ids  = []
              + protocol         = "-1"
              + security_groups  = []
              + self             = false
              + to_port          = 0
            },
        ]
      + id                     = (known after apply)
      + ingress                = [
          + {
              + cidr_blocks      = []
              + description      = ""
              + from_port        = 0
              + ipv6_cidr_blocks = []
              + prefix_list_ids  = []
              + protocol         = "-1"
              + security_groups  = []
              + self             = true
              + to_port          = 0
            },
        ]
      + name                   = (known after apply)
      + name_prefix            = (known after apply)
      + owner_id               = (known after apply)
      + revoke_rules_on_delete = false
      + tags_all               = {
          + "Source" = "https://github.com/kunduso/add-asg-elb-terraform"
        }
      + vpc_id                 = (known after apply)
    }

  # aws_eip.nat_gateway[0] will be created
  + resource "aws_eip" "nat_gateway" {
      + allocation_id        = (known after apply)
      + association_id       = (known after apply)
      + carrier_ip           = (known after apply)
      + customer_owned_ip    = (known after apply)
      + domain               = "vpc"
      + id                   = (known after apply)
      + instance             = (known after apply)
      + network_border_group = (known after apply)
      + network_interface    = (known after apply)
      + private_dns          = (known after apply)
      + private_ip           = (known after apply)
      + public_dns           = (known after apply)
      + public_ip            = (known after apply)
      + public_ipv4_pool     = (known after apply)
      + tags_all             = {
          + "Source" = "https://github.com/kunduso/add-asg-elb-terraform"
        }
      + vpc                  = (known after apply)
    }

  # aws_eip.nat_gateway[1] will be created
  + resource "aws_eip" "nat_gateway" {
      + allocation_id        = (known after apply)
      + association_id       = (known after apply)
      + carrier_ip           = (known after apply)
      + customer_owned_ip    = (known after apply)
      + domain               = "vpc"
      + id                   = (known after apply)
      + instance             = (known after apply)
      + network_border_group = (known after apply)
      + network_interface    = (known after apply)
      + private_dns          = (known after apply)
      + private_ip           = (known after apply)
      + public_dns           = (known after apply)
      + public_ip            = (known after apply)
      + public_ipv4_pool     = (known after apply)
      + tags_all             = {
          + "Source" = "https://github.com/kunduso/add-asg-elb-terraform"
        }
      + vpc                  = (known after apply)
    }

  # aws_eip.nat_gateway[2] will be created
  + resource "aws_eip" "nat_gateway" {
      + allocation_id        = (known after apply)
      + association_id       = (known after apply)
      + carrier_ip           = (known after apply)
      + customer_owned_ip    = (known after apply)
      + domain               = "vpc"
      + id                   = (known after apply)
      + instance             = (known after apply)
      + network_border_group = (known after apply)
      + network_interface    = (known after apply)
      + private_dns          = (known after apply)
      + private_ip           = (known after apply)
      + public_dns           = (known after apply)
      + public_ip            = (known after apply)
      + public_ipv4_pool     = (known after apply)
      + tags_all             = {
          + "Source" = "https://github.com/kunduso/add-asg-elb-terraform"
        }
      + vpc                  = (known after apply)
    }

  # aws_iam_instance_profile.ec2_profile will be created
  + resource "aws_iam_instance_profile" "ec2_profile" {
      + arn         = (known after apply)
      + create_date = (known after apply)
      + id          = (known after apply)
      + name        = "ec2_profile"
      + name_prefix = (known after apply)
      + path        = "/"
      + role        = "ec2_role"
      + tags_all    = {
          + "Source" = "https://github.com/kunduso/add-asg-elb-terraform"
        }
      + unique_id   = (known after apply)
    }

  # aws_iam_role.ec2_role will be created
  + resource "aws_iam_role" "ec2_role" {
      + arn                   = (known after apply)
      + assume_role_policy    = jsonencode(
            {
              + Statement = [
                  + {
                      + Action    = "sts:AssumeRole"
                      + Effect    = "Allow"
                      + Principal = {
                          + Service = "ec2.amazonaws.com"
                        }
                      + Sid       = ""
                    },
                ]
              + Version   = "2012-10-17"
            }
        )
      + create_date           = (known after apply)
      + force_detach_policies = false
      + id                    = (known after apply)
      + managed_policy_arns   = (known after apply)
      + max_session_duration  = 3600
      + name                  = "ec2_role"
      + name_prefix           = (known after apply)
      + path                  = "/"
      + role_last_used        = (known after apply)
      + tags_all              = {
          + "Source" = "https://github.com/kunduso/add-asg-elb-terraform"
        }
      + unique_id             = (known after apply)
    }

  # aws_iam_role_policy_attachment.custom will be created
  + resource "aws_iam_role_policy_attachment" "custom" {
      + id         = (known after apply)
      + policy_arn = "arn:aws:iam::aws:policy/AmazonSSMManagedInstanceCore"
      + role       = "ec2_role"
    }

  # aws_internet_gateway.this-igw will be created
  + resource "aws_internet_gateway" "this-igw" {
      + arn      = (known after apply)
      + id       = (known after apply)
      + owner_id = (known after apply)
      + tags     = {
          + "Name" = "app-3-gateway"
        }
      + tags_all = {
          + "Name"   = "app-3-gateway"
          + "Source" = "https://github.com/kunduso/add-asg-elb-terraform"
        }
      + vpc_id   = (known after apply)
    }

  # aws_launch_template.application will be created
  + resource "aws_launch_template" "application" {
      + arn             = (known after apply)
      + default_version = (known after apply)
      + id              = (known after apply)
      + image_id        = "ami-0ec5c7d8262c1f6b2"
      + instance_type   = "t3.medium"
      + latest_version  = (known after apply)
      + name            = (known after apply)
      + name_prefix     = (known after apply)
      + tags_all        = {
          + "Source" = "https://github.com/kunduso/add-asg-elb-terraform"
        }
      + user_data       = "IyEvYmluL2Jhc2gKeXVtIHVwZGF0ZSAteQp5dW0gaW5zdGFsbCAteSBodHRwZC54ODZfNjQKeXVtIGluc3RhbGwgLXkganEKUkVHSU9OX0FWX1pPTkU9YGN1cmwgLXMgaHR0cDovLzE2OS4yNTQuMTY5LjI1NC9sYXRlc3QvZHluYW1pYy9pbnN0YW5jZS1pZGVudGl0eS9kb2N1bWVudCB8IGpxIC5hdmFpbGFiaWxpdHlab25lIC1yYApzeXN0ZW1jdGwgc3RhcnQgaHR0cGQuc2VydmljZQpzeXN0ZW1jdGwgZW5hYmxlIGh0dHBkLnNlcnZpY2UKZWNobyAiSGVsbG8gV29ybGQgZnJvbSAkKGhvc3RuYW1lIC1mKSBmcm9tIHRoZSBhdmFpbGFiaWxpdHkgem9uZTogJFJFR0lPTl9BVl9aT05FIiA+IC92YXIvd3d3L2h0bWwvaW5kZXguaHRtbA=="

      + iam_instance_profile {
          + name = "ec2_profile"
        }

      + network_interfaces {
          + security_groups = (known after apply)
        }
    }

  # aws_lb.front will be created
  + resource "aws_lb" "front" {
      + arn                                         = (known after apply)
      + arn_suffix                                  = (known after apply)
      + desync_mitigation_mode                      = "defensive"
      + dns_name                                    = (known after apply)
      + drop_invalid_header_fields                  = false
      + enable_deletion_protection                  = false
      + enable_http2                                = true
      + enable_tls_version_and_cipher_suite_headers = false
      + enable_waf_fail_open                        = false
      + enable_xff_client_port                      = false
      + id                                          = (known after apply)
      + idle_timeout                                = 60
      + internal                                    = false
      + ip_address_type                             = (known after apply)
      + load_balancer_type                          = "application"
      + name                                        = "app-3"
      + preserve_host_header                        = false
      + security_groups                             = (known after apply)
      + subnets                                     = (known after apply)
      + tags                                        = {
          + "Environment" = "Development"
        }
      + tags_all                                    = {
          + "Environment" = "Development"
          + "Source"      = "https://github.com/kunduso/add-asg-elb-terraform"
        }
      + vpc_id                                      = (known after apply)
      + xff_header_processing_mode                  = "append"
      + zone_id                                     = (known after apply)
    }

  # aws_lb_listener.front_end will be created
  + resource "aws_lb_listener" "front_end" {
      + arn               = (known after apply)
      + id                = (known after apply)
      + load_balancer_arn = (known after apply)
      + port              = 80
      + protocol          = "HTTP"
      + ssl_policy        = (known after apply)
      + tags_all          = {
          + "Source" = "https://github.com/kunduso/add-asg-elb-terraform"
        }

      + default_action {
          + order            = (known after apply)
          + target_group_arn = (known after apply)
          + type             = "forward"
        }
    }

  # aws_lb_target_group.front will be created
  + resource "aws_lb_target_group" "front" {
      + arn                                = (known after apply)
      + arn_suffix                         = (known after apply)
      + connection_termination             = false
      + deregistration_delay               = "300"
      + id                                 = (known after apply)
      + ip_address_type                    = (known after apply)
      + lambda_multi_value_headers_enabled = false
      + load_balancing_algorithm_type      = (known after apply)
      + load_balancing_cross_zone_enabled  = (known after apply)
      + name                               = "app-3-front"
      + port                               = 80
      + preserve_client_ip                 = (known after apply)
      + protocol                           = "HTTP"
      + protocol_version                   = (known after apply)
      + proxy_protocol_v2                  = false
      + slow_start                         = 0
      + tags_all                           = {
          + "Source" = "https://github.com/kunduso/add-asg-elb-terraform"
        }
      + target_type                        = "instance"
      + vpc_id                             = (known after apply)

      + health_check {
          + enabled             = true
          + healthy_threshold   = 3
          + interval            = 10
          + matcher             = "200"
          + path                = "/"
          + port                = "traffic-port"
          + protocol            = "HTTP"
          + timeout             = 3
          + unhealthy_threshold = 2
        }
    }

  # aws_nat_gateway.public[0] will be created
  + resource "aws_nat_gateway" "public" {
      + allocation_id        = (known after apply)
      + association_id       = (known after apply)
      + connectivity_type    = "public"
      + id                   = (known after apply)
      + network_interface_id = (known after apply)
      + private_ip           = (known after apply)
      + public_ip            = (known after apply)
      + subnet_id            = (known after apply)
      + tags                 = {
          + "Name" = "app-3-NAT-1"
        }
      + tags_all             = {
          + "Name"   = "app-3-NAT-1"
          + "Source" = "https://github.com/kunduso/add-asg-elb-terraform"
        }
    }

  # aws_nat_gateway.public[1] will be created
  + resource "aws_nat_gateway" "public" {
      + allocation_id        = (known after apply)
      + association_id       = (known after apply)
      + connectivity_type    = "public"
      + id                   = (known after apply)
      + network_interface_id = (known after apply)
      + private_ip           = (known after apply)
      + public_ip            = (known after apply)
      + subnet_id            = (known after apply)
      + tags                 = {
          + "Name" = "app-3-NAT-2"
        }
      + tags_all             = {
          + "Name"   = "app-3-NAT-2"
          + "Source" = "https://github.com/kunduso/add-asg-elb-terraform"
        }
    }

  # aws_nat_gateway.public[2] will be created
  + resource "aws_nat_gateway" "public" {
      + allocation_id        = (known after apply)
      + association_id       = (known after apply)
      + connectivity_type    = "public"
      + id                   = (known after apply)
      + network_interface_id = (known after apply)
      + private_ip           = (known after apply)
      + public_ip            = (known after apply)
      + subnet_id            = (known after apply)
      + tags                 = {
          + "Name" = "app-3-NAT-3"
        }
      + tags_all             = {
          + "Name"   = "app-3-NAT-3"
          + "Source" = "https://github.com/kunduso/add-asg-elb-terraform"
        }
    }

  # aws_route.internet-route will be created
  + resource "aws_route" "internet-route" {
      + destination_cidr_block = "0.0.0.0/0"
      + gateway_id             = (known after apply)
      + id                     = (known after apply)
      + instance_id            = (known after apply)
      + instance_owner_id      = (known after apply)
      + network_interface_id   = (known after apply)
      + origin                 = (known after apply)
      + route_table_id         = (known after apply)
      + state                  = (known after apply)
    }

  # aws_route.private-route[0] will be created
  + resource "aws_route" "private-route" {
      + destination_cidr_block = "0.0.0.0/0"
      + gateway_id             = (known after apply)
      + id                     = (known after apply)
      + instance_id            = (known after apply)
      + instance_owner_id      = (known after apply)
      + network_interface_id   = (known after apply)
      + origin                 = (known after apply)
      + route_table_id         = (known after apply)
      + state                  = (known after apply)
    }

  # aws_route.private-route[1] will be created
  + resource "aws_route" "private-route" {
      + destination_cidr_block = "0.0.0.0/0"
      + gateway_id             = (known after apply)
      + id                     = (known after apply)
      + instance_id            = (known after apply)
      + instance_owner_id      = (known after apply)
      + network_interface_id   = (known after apply)
      + origin                 = (known after apply)
      + route_table_id         = (known after apply)
      + state                  = (known after apply)
    }

  # aws_route.private-route[2] will be created
  + resource "aws_route" "private-route" {
      + destination_cidr_block = "0.0.0.0/0"
      + gateway_id             = (known after apply)
      + id                     = (known after apply)
      + instance_id            = (known after apply)
      + instance_owner_id      = (known after apply)
      + network_interface_id   = (known after apply)
      + origin                 = (known after apply)
      + route_table_id         = (known after apply)
      + state                  = (known after apply)
    }

  # aws_route_table.private[0] will be created
  + resource "aws_route_table" "private" {
      + arn              = (known after apply)
      + id               = (known after apply)
      + owner_id         = (known after apply)
      + propagating_vgws = (known after apply)
      + route            = (known after apply)
      + tags             = {
          + "Name" = "app-3-route-table-1"
        }
      + tags_all         = {
          + "Name"   = "app-3-route-table-1"
          + "Source" = "https://github.com/kunduso/add-asg-elb-terraform"
        }
      + vpc_id           = (known after apply)
    }

  # aws_route_table.private[1] will be created
  + resource "aws_route_table" "private" {
      + arn              = (known after apply)
      + id               = (known after apply)
      + owner_id         = (known after apply)
      + propagating_vgws = (known after apply)
      + route            = (known after apply)
      + tags             = {
          + "Name" = "app-3-route-table-2"
        }
      + tags_all         = {
          + "Name"   = "app-3-route-table-2"
          + "Source" = "https://github.com/kunduso/add-asg-elb-terraform"
        }
      + vpc_id           = (known after apply)
    }

  # aws_route_table.private[2] will be created
  + resource "aws_route_table" "private" {
      + arn              = (known after apply)
      + id               = (known after apply)
      + owner_id         = (known after apply)
      + propagating_vgws = (known after apply)
      + route            = (known after apply)
      + tags             = {
          + "Name" = "app-3-route-table-3"
        }
      + tags_all         = {
          + "Name"   = "app-3-route-table-3"
          + "Source" = "https://github.com/kunduso/add-asg-elb-terraform"
        }
      + vpc_id           = (known after apply)
    }

  # aws_route_table.public will be created
  + resource "aws_route_table" "public" {
      + arn              = (known after apply)
      + id               = (known after apply)
      + owner_id         = (known after apply)
      + propagating_vgws = (known after apply)
      + route            = (known after apply)
      + tags             = {
          + "Name" = "app-3-public"
        }
      + tags_all         = {
          + "Name"   = "app-3-public"
          + "Source" = "https://github.com/kunduso/add-asg-elb-terraform"
        }
      + vpc_id           = (known after apply)
    }

  # aws_route_table_association.private[0] will be created
  + resource "aws_route_table_association" "private" {
      + id             = (known after apply)
      + route_table_id = (known after apply)
      + subnet_id      = (known after apply)
    }

  # aws_route_table_association.private[1] will be created
  + resource "aws_route_table_association" "private" {
      + id             = (known after apply)
      + route_table_id = (known after apply)
      + subnet_id      = (known after apply)
    }

  # aws_route_table_association.private[2] will be created
  + resource "aws_route_table_association" "private" {
      + id             = (known after apply)
      + route_table_id = (known after apply)
      + subnet_id      = (known after apply)
    }

  # aws_route_table_association.public[0] will be created
  + resource "aws_route_table_association" "public" {
      + id             = (known after apply)
      + route_table_id = (known after apply)
      + subnet_id      = (known after apply)
    }

  # aws_route_table_association.public[1] will be created
  + resource "aws_route_table_association" "public" {
      + id             = (known after apply)
      + route_table_id = (known after apply)
      + subnet_id      = (known after apply)
    }

  # aws_route_table_association.public[2] will be created
  + resource "aws_route_table_association" "public" {
      + id             = (known after apply)
      + route_table_id = (known after apply)
      + subnet_id      = (known after apply)
    }

  # aws_security_group.asg_lb_security_group will be created
  + resource "aws_security_group" "asg_lb_security_group" {
      + arn                    = (known after apply)
      + description            = "Allow inbound and outbound traffic to load balancer from the internet."
      + egress                 = [
          + {
              + cidr_blocks      = [
                  + "0.0.0.0/0",
                ]
              + description      = ""
              + from_port        = 0
              + ipv6_cidr_blocks = []
              + prefix_list_ids  = []
              + protocol         = "-1"
              + security_groups  = []
              + self             = false
              + to_port          = 0
            },
        ]
      + id                     = (known after apply)
      + ingress                = [
          + {
              + cidr_blocks      = [
                  + "0.0.0.0/0",
                ]
              + description      = ""
              + from_port        = 80
              + ipv6_cidr_blocks = []
              + prefix_list_ids  = []
              + protocol         = "tcp"
              + security_groups  = []
              + self             = false
              + to_port          = 80
            },
        ]
      + name                   = "App-3-ASG-LB-SG-IN"
      + name_prefix            = (known after apply)
      + owner_id               = (known after apply)
      + revoke_rules_on_delete = false
      + tags                   = {
          + "Name" = "app-3-asg-lb-sg"
        }
      + tags_all               = {
          + "Name"   = "app-3-asg-lb-sg"
          + "Source" = "https://github.com/kunduso/add-asg-elb-terraform"
        }
      + vpc_id                 = (known after apply)
    }

  # aws_security_group.ec2_security_group will be created
  + resource "aws_security_group" "ec2_security_group" {
      + arn                    = (known after apply)
      + description            = "Allow inbound and outbound traffic to EC2 instances from load balancer security group"
      + egress                 = [
          + {
              + cidr_blocks      = [
                  + "0.0.0.0/0",
                ]
              + description      = ""
              + from_port        = 0
              + ipv6_cidr_blocks = []
              + prefix_list_ids  = []
              + protocol         = "-1"
              + security_groups  = []
              + self             = false
              + to_port          = 0
            },
        ]
      + id                     = (known after apply)
      + ingress                = [
          + {
              + cidr_blocks      = []
              + description      = ""
              + from_port        = 80
              + ipv6_cidr_blocks = []
              + prefix_list_ids  = []
              + protocol         = "tcp"
              + security_groups  = (known after apply)
              + self             = false
              + to_port          = 80
            },
        ]
      + name                   = "App-3-Instance-SG"
      + name_prefix            = (known after apply)
      + owner_id               = (known after apply)
      + revoke_rules_on_delete = false
      + tags                   = {
          + "Name" = "app-3-instance-sg"
        }
      + tags_all               = {
          + "Name"   = "app-3-instance-sg"
          + "Source" = "https://github.com/kunduso/add-asg-elb-terraform"
        }
      + vpc_id                 = (known after apply)
    }

  # aws_subnet.private[0] will be created
  + resource "aws_subnet" "private" {
      + arn                                            = (known after apply)
      + assign_ipv6_address_on_creation                = false
      + availability_zone                              = "us-east-2a"
      + availability_zone_id                           = (known after apply)
      + cidr_block                                     = "10.20.30.0/27"
      + enable_dns64                                   = false
      + enable_resource_name_dns_a_record_on_launch    = false
      + enable_resource_name_dns_aaaa_record_on_launch = false
      + id                                             = (known after apply)
      + ipv6_cidr_block_association_id                 = (known after apply)
      + ipv6_native                                    = false
      + map_public_ip_on_launch                        = false
      + owner_id                                       = (known after apply)
      + private_dns_hostname_type_on_launch            = (known after apply)
      + tags                                           = {
          + "Name" = "app-3-private-1"
        }
      + tags_all                                       = {
          + "Name"   = "app-3-private-1"
          + "Source" = "https://github.com/kunduso/add-asg-elb-terraform"
        }
      + vpc_id                                         = (known after apply)
    }

  # aws_subnet.private[1] will be created
  + resource "aws_subnet" "private" {
      + arn                                            = (known after apply)
      + assign_ipv6_address_on_creation                = false
      + availability_zone                              = "us-east-2b"
      + availability_zone_id                           = (known after apply)
      + cidr_block                                     = "10.20.30.32/27"
      + enable_dns64                                   = false
      + enable_resource_name_dns_a_record_on_launch    = false
      + enable_resource_name_dns_aaaa_record_on_launch = false
      + id                                             = (known after apply)
      + ipv6_cidr_block_association_id                 = (known after apply)
      + ipv6_native                                    = false
      + map_public_ip_on_launch                        = false
      + owner_id                                       = (known after apply)
      + private_dns_hostname_type_on_launch            = (known after apply)
      + tags                                           = {
          + "Name" = "app-3-private-2"
        }
      + tags_all                                       = {
          + "Name"   = "app-3-private-2"
          + "Source" = "https://github.com/kunduso/add-asg-elb-terraform"
        }
      + vpc_id                                         = (known after apply)
    }

  # aws_subnet.private[2] will be created
  + resource "aws_subnet" "private" {
      + arn                                            = (known after apply)
      + assign_ipv6_address_on_creation                = false
      + availability_zone                              = "us-east-2c"
      + availability_zone_id                           = (known after apply)
      + cidr_block                                     = "10.20.30.64/27"
      + enable_dns64                                   = false
      + enable_resource_name_dns_a_record_on_launch    = false
      + enable_resource_name_dns_aaaa_record_on_launch = false
      + id                                             = (known after apply)
      + ipv6_cidr_block_association_id                 = (known after apply)
      + ipv6_native                                    = false
      + map_public_ip_on_launch                        = false
      + owner_id                                       = (known after apply)
      + private_dns_hostname_type_on_launch            = (known after apply)
      + tags                                           = {
          + "Name" = "app-3-private-3"
        }
      + tags_all                                       = {
          + "Name"   = "app-3-private-3"
          + "Source" = "https://github.com/kunduso/add-asg-elb-terraform"
        }
      + vpc_id                                         = (known after apply)
    }

  # aws_subnet.public[0] will be created
  + resource "aws_subnet" "public" {
      + arn                                            = (known after apply)
      + assign_ipv6_address_on_creation                = false
      + availability_zone                              = "us-east-2a"
      + availability_zone_id                           = (known after apply)
      + cidr_block                                     = "10.20.30.96/27"
      + enable_dns64                                   = false
      + enable_resource_name_dns_a_record_on_launch    = false
      + enable_resource_name_dns_aaaa_record_on_launch = false
      + id                                             = (known after apply)
      + ipv6_cidr_block_association_id                 = (known after apply)
      + ipv6_native                                    = false
      + map_public_ip_on_launch                        = false
      + owner_id                                       = (known after apply)
      + private_dns_hostname_type_on_launch            = (known after apply)
      + tags                                           = {
          + "Name" = "app-3-public-1"
        }
      + tags_all                                       = {
          + "Name"   = "app-3-public-1"
          + "Source" = "https://github.com/kunduso/add-asg-elb-terraform"
        }
      + vpc_id                                         = (known after apply)
    }

  # aws_subnet.public[1] will be created
  + resource "aws_subnet" "public" {
      + arn                                            = (known after apply)
      + assign_ipv6_address_on_creation                = false
      + availability_zone                              = "us-east-2b"
      + availability_zone_id                           = (known after apply)
      + cidr_block                                     = "10.20.30.128/27"
      + enable_dns64                                   = false
      + enable_resource_name_dns_a_record_on_launch    = false
      + enable_resource_name_dns_aaaa_record_on_launch = false
      + id                                             = (known after apply)
      + ipv6_cidr_block_association_id                 = (known after apply)
      + ipv6_native                                    = false
      + map_public_ip_on_launch                        = false
      + owner_id                                       = (known after apply)
      + private_dns_hostname_type_on_launch            = (known after apply)
      + tags                                           = {
          + "Name" = "app-3-public-2"
        }
      + tags_all                                       = {
          + "Name"   = "app-3-public-2"
          + "Source" = "https://github.com/kunduso/add-asg-elb-terraform"
        }
      + vpc_id                                         = (known after apply)
    }

  # aws_subnet.public[2] will be created
  + resource "aws_subnet" "public" {
      + arn                                            = (known after apply)
      + assign_ipv6_address_on_creation                = false
      + availability_zone                              = "us-east-2c"
      + availability_zone_id                           = (known after apply)
      + cidr_block                                     = "10.20.30.160/27"
      + enable_dns64                                   = false
      + enable_resource_name_dns_a_record_on_launch    = false
      + enable_resource_name_dns_aaaa_record_on_launch = false
      + id                                             = (known after apply)
      + ipv6_cidr_block_association_id                 = (known after apply)
      + ipv6_native                                    = false
      + map_public_ip_on_launch                        = false
      + owner_id                                       = (known after apply)
      + private_dns_hostname_type_on_launch            = (known after apply)
      + tags                                           = {
          + "Name" = "app-3-public-3"
        }
      + tags_all                                       = {
          + "Name"   = "app-3-public-3"
          + "Source" = "https://github.com/kunduso/add-asg-elb-terraform"
        }
      + vpc_id                                         = (known after apply)
    }

  # aws_vpc.this will be created
  + resource "aws_vpc" "this" {
      + arn                                  = (known after apply)
      + cidr_block                           = "10.20.30.0/24"
      + default_network_acl_id               = (known after apply)
      + default_route_table_id               = (known after apply)
      + default_security_group_id            = (known after apply)
      + dhcp_options_id                      = (known after apply)
      + enable_dns_hostnames                 = true
      + enable_dns_support                   = true
      + enable_network_address_usage_metrics = (known after apply)
      + id                                   = (known after apply)
      + instance_tenancy                     = "default"
      + ipv6_association_id                  = (known after apply)
      + ipv6_cidr_block                      = (known after apply)
      + ipv6_cidr_block_network_border_group = (known after apply)
      + main_route_table_id                  = (known after apply)
      + owner_id                             = (known after apply)
      + tags                                 = {
          + "Name" = "app-3"
        }
      + tags_all                             = {
          + "Name"   = "app-3"
          + "Source" = "https://github.com/kunduso/add-asg-elb-terraform"
        }
    }

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

Changes to Outputs:
  + lb_endpoint = (known after apply)

Warning: 'launch_template' always triggers an instance refresh and can be removed

  with aws_autoscaling_group.application,
  on autoscaling.tf line 46, in resource "aws_autoscaling_group" "application":
  46:     triggers = ["launch_template"]

(and one more similar warning elsewhere)

─────────────────────────────────────────────────────────────────────────────

Saved the plan to: TFplan.JSON

To perform exactly these actions, run the following command to apply:
    terraform apply "TFplan.JSON"

Pushed by: @kunduso, Action: pull_request

@kunduso kunduso linked an issue Sep 8, 2023 that may be closed by this pull request
@kunduso kunduso merged commit de8f155 into main Sep 8, 2023
3 of 6 checks passed
@kunduso kunduso deleted the add-asg branch September 12, 2023 13:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Manage Infracost using the flag variable Add load balancer and asg
1 participant