# Upgrade: ALB module v9 to v10

## Who is affected

`load-balancing-alb` stacks that define custom `rules` with `actions` in their override, such as `_gp_alb_override.tf`.

If you have no custom rules, this guide does not apply to you.

## What changed

### Listener rule actions

The `type` field is replaced by a **nested object** named after the action type.

**Before (v9):**

```hcl
rules = {
  metrics = {
    actions = [
      {
        type         = "fixed-response"
        content_type = "text/plain"
        status_code  = "404"
      }
    ]
  }
}
```

**After (v10):**

```hcl
rules = {
  metrics = {
    actions = [
      {
        fixed_response = {
          content_type = "text/plain"
          status_code  = "404"
        }
      }
    ]
  }
}
```

### Other action types

The same pattern applies to all action types:

```hcl
# v9: forward
actions = [{ type = "forward", target_group_key = "my-tg" }]
# v10: forward
actions = [{ forward = { target_group_key = "my-tg" } }]

# v9: redirect
actions = [{ type = "redirect", port = "443", protocol = "HTTPS", status_code = "HTTP_301" }]
# v10: redirect
actions = [{ redirect = { port = "443", protocol = "HTTPS", status_code = "HTTP_301" } }]
```

### Query string conditions

If you use `query_string` in conditions, it changed from a map to a list of maps:

```hcl
# v9
conditions = [{ query_string = { key = "foo", value = "bar" } }]
# v10
conditions = [{ query_string = [{ key = "foo", value = "bar" }] }]
```

## How to upgrade

1. Find any `_gp_alb_override.tf` (or similar override) that defines `rules` with `actions`
1. Replace `type = "<action-type>"` + flat fields with `<action-type> = { ... }` nested block
1. Update any `query_string` conditions to the list-of-maps format
1. Run `terraform plan` - verify changes. Note: upgrading to v10 removes some `terraform-aws-modules = "alb"` tags

## References

- [Upstream upgrade guide (UPGRADE-10.0.md)](https://github.com/terraform-aws-modules/terraform-aws-alb/blob/master/docs/UPGRADE-10.0.md)
- [v10.0.0 release notes](https://github.com/terraform-aws-modules/terraform-aws-alb/releases/tag/v10.0.0)
