# Integrated AWS hub Application Load Balancer

**Purpose:** provide one public HTTP entry point for the existing EG334S Ireland
hub service. This is not a separate website or VPC.

## Architecture and ownership

- AWS account: personal test-bed account `980195619820`
- Region: `eu-west-1` (Europe — Ireland)
- Existing hub VPC: `vpc-025cee2ec308dffaf` (`10.1.0.0/16`)
- Existing primary hub: `i-074bf0cb910a99e02` (`10.1.1.61`)
- Existing cold-recovery ASG: `eg334s-hub-recovery-HubRecoveryAsg`
- ALB stack: `eg334s-personal-demo-site`
- Public entry point: internet-facing Application Load Balancer
- ALB subnets: `10.1.1.0/24` in `eu-west-1a` and `10.1.2.0/24` in `eu-west-1b`

The historical ALB stack name and DNS name are intentionally retained to avoid
replacing the live ALB. The stack no longer owns demonstration EC2 instances,
a launch template or a separate application Auto Scaling group.

During normal operation, the target group contains the existing primary hub
instance. The cold-recovery ASG has desired capacity zero and is associated
with the same target group. If hub recovery is triggered, its replacement
instance registers automatically after starting.

## Deployment order

Obtain the existing target group ARN:

```bash
TARGET_GROUP_ARN="$(
  aws cloudformation describe-stacks \
    --profile bernard-admin \
    --region eu-west-1 \
    --stack-name eg334s-personal-demo-site \
    --query 'Stacks[0].Outputs[?OutputKey==`TargetGroupArn`].OutputValue' \
    --output text
)"
```

First associate the recovery ASG with that target group:

```bash
aws cloudformation deploy \
  --profile bernard-admin \
  --region eu-west-1 \
  --stack-name eg334s-hub-recovery \
  --template-file docs/iac/hub-recovery-eu-west-1.yaml \
  --parameter-overrides AlbTargetGroupArn="$TARGET_GROUP_ARN" \
  --capabilities CAPABILITY_NAMED_IAM \
  --no-fail-on-empty-changeset
```

Then deploy or update the integrated ALB stack:

```bash
aws cloudformation deploy \
  --profile bernard-admin \
  --region eu-west-1 \
  --stack-name eg334s-personal-demo-site \
  --template-file docs/iac/hub-alb-eu-west-1.yaml \
  --parameter-overrides \
    VpcId=vpc-025cee2ec308dffaf \
    PublicSubnetA=subnet-0f989a512edd5fc00 \
    PublicSubnetB=subnet-09054c9211254de43 \
    PrimaryInstanceId=i-074bf0cb910a99e02 \
    HubSecurityGroupId=sg-053fe0da99c1231ef \
    EnvironmentLabel=PERSONAL-TEST-BED \
  --no-fail-on-empty-changeset
```

## Verification

Run:

```bash
./scripts/check-hub-alb.sh
```

Normal readiness requires:

- HTTP status `200` through the ALB;
- the existing primary hub is the only healthy normal target;
- the ALB spans both Ireland subnets;
- the cold-recovery ASG is attached to the same target group at desired zero;
- the temporary demonstration ASG no longer exists;
- VPN #1 remains available with at least one tunnel endpoint `UP`.

The ALB being multi-AZ does not mean that two application instances are
normally running. This design deliberately uses one active hub and a cold
recovery instance to control cost while retaining the accepted 10-minute hub
recovery objective.

## Change and teardown boundary

Do not delete the ALB stack as part of ordinary hub testing. It is now an
integrated access component for the live Ireland hub. Deleting it removes the
public HTTP entry point but does not delete the hub VPC, VGW, VPN connections,
primary hub instance or recovery stack.
