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

Branch 04_02 - request for update to latest autoscaling parameters #249

Open
guteksan opened this issue Jan 23, 2025 · 1 comment
Open

Comments

@guteksan
Copy link

From version 9.0.0, alb does not output target_group_arns and autoscaling does not accept such input parameters. Please update the lesson, or at least the code, to use the latest versions of load balancers and autoscaling groups.

https://registry.terraform.io/modules/terraform-aws-modules/autoscaling/aws/8.0.1?tab=inputs
https://registry.terraform.io/modules/terraform-aws-modules/alb/aws/9.13.0?tab=inputs

@thatnerdjoe
Copy link

Took a bit of tinkering, but I found the solution as of ALB v9.13.0 and ASG v8.1.0.

module "blog"
  source  = "terraform-aws-modules/autoscaling/aws"
  version = "8.1.0"
 
  ...snip...

  vpc_zone_identifier   = module.blog_vpc.public_subnets
  security_groups       = [module.blog_sg.security_group_id]
  traffic_source_attachments = {
    blog_alb = {
      traffic_source_identifier = module.blog_alb.target_groups["blog_asg"].arn
      traffic_source_type = "elbv2"
    }
  }
}

module "blog_alb"
  source = "terraform-aws-modules/alb/aws"
  version = "9.13.0"

  ...snip...

  listeners = {
    blog_http = {
      port     = 80
      protocol = "HTTP"
    
      forward = {
        target_group_key = "blog_asg"
      }
    }
  }
    
  target_groups = {
    blog_asg = {
      name_prefix      = "blog-"
      protocol         = "HTTP"
      port             = 80
      target_type      = "instance"
      # Required argument to attach to the ASG later.
      create_attachment = false
    }
 }

Source: https://github.com/terraform-aws-modules/terraform-aws-autoscaling/blob/v8.1.0/examples/complete/main.tf

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

No branches or pull requests

2 participants