Hi all, I’m currently trying to migrate ECS infras...
# aws
c
Hi all, I’m currently trying to migrate ECS infrastructure from terraform to pulumi. In terraform, I used to define the target group manually on ALB listener. But I don’t see any example related with defining target group in the doc (https://www.pulumi.com/docs/clouds/aws/guides/elb/). Can someone direct me to a proper example to do this? I will provide the terraform code for example.
Copy code
resource "aws_lb_target_group" "target_group" {
  name        = "${var.env}-${var.service_name}-tg"
  target_type = "ip"
  protocol    = "HTTP"
  port        = 80
  vpc_id      = var.vpc_id # Referencing the default VPC

  health_check {
    protocol            = "HTTP"
    port                = "80"
    path                = "/"
    matcher             = "200"
    healthy_threshold   = 3
    unhealthy_threshold = 3
    timeout             = 5
    interval            = 10
  }

  tags = {
    Name        = "${var.service_name}-tg"
    Environment = var.env
    Project     = var.service_name
  }
}

resource "aws_lb_listener" "http_listener" {
  load_balancer_arn = aws_alb.alb.arn # Referencing our load balancer
  port              = "80"
  protocol          = "HTTP"

  default_action {
    type = "redirect"

    redirect {
      port        = "443"
      protocol    = "HTTPS"
      status_code = "HTTP_301"
    }
  }
}

resource "aws_lb_listener" "https_listener" {
  load_balancer_arn = aws_alb.alb.arn # Referencing our load balancer
  port              = "443"
  protocol          = "HTTPS"
  ssl_policy        = "ELBSecurityPolicy-2016-08"
  certificate_arn   = var.certificate_arn

  default_action {
    type             = "forward"
    target_group_arn = aws_lb_target_group.target_group.arn # Referencing our target group
  }
}
P.S. I use typescript
a
Hi @cold-restaurant-98613, is this what you are looking for? https://www.pulumi.com/registry/packages/aws/api-docs/lb/listener/#redirect-action
c
That’s right. Thank you for the link. I tried asking Pulumi AI and it keeps giving an example that use awsx. I will check the document first before asking more question (if any).
g
since you are familiar with terraform,
awsx
is only a collection of opinionated solutions built on top of classic
aws
which is almost 1to1 terraform aws provider. You should be able to map terraform resources to pulumi. CamelCase vs snake_case. "Data" resources in TF = functions in pulumi