Skip to content

Commit 7f4f243

Browse files
committed
Fix 047-firewall: try replace-route, fall back to create-route — passes locally in eu-west-1
1 parent 0103b52 commit 7f4f243

1 file changed

Lines changed: 18 additions & 8 deletions

File tree

tuts/047-aws-network-firewall-gs/aws-network-firewall-gs.sh

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -698,21 +698,31 @@ echo "Updating internet gateway route table..."
698698
if ! aws ec2 replace-route \
699699
--route-table-id "$IGW_ROUTE_TABLE_ID" \
700700
--destination-cidr-block "$CUSTOMER_SUBNET_CIDR" \
701-
--vpc-endpoint-id "$FIREWALL_ENDPOINT"; then
702-
echo "ERROR: Failed to update internet gateway route"
703-
cleanup_resources
704-
exit 1
701+
--vpc-endpoint-id "$FIREWALL_ENDPOINT" 2>/dev/null; then
702+
if ! aws ec2 create-route \
703+
--route-table-id "$IGW_ROUTE_TABLE_ID" \
704+
--destination-cidr-block "$CUSTOMER_SUBNET_CIDR" \
705+
--vpc-endpoint-id "$FIREWALL_ENDPOINT"; then
706+
echo "ERROR: Failed to update internet gateway route"
707+
cleanup_resources
708+
exit 1
709+
fi
705710
fi
706711

707712
# Update the customer subnet route table
708713
echo "Updating customer subnet route table..."
709714
if ! aws ec2 replace-route \
710715
--route-table-id "$SUBNET_ROUTE_TABLE_ID" \
711716
--destination-cidr-block "0.0.0.0/0" \
712-
--vpc-endpoint-id "$FIREWALL_ENDPOINT"; then
713-
echo "ERROR: Failed to update customer subnet route"
714-
cleanup_resources
715-
exit 1
717+
--vpc-endpoint-id "$FIREWALL_ENDPOINT" 2>/dev/null; then
718+
if ! aws ec2 create-route \
719+
--route-table-id "$SUBNET_ROUTE_TABLE_ID" \
720+
--destination-cidr-block "0.0.0.0/0" \
721+
--vpc-endpoint-id "$FIREWALL_ENDPOINT"; then
722+
echo "ERROR: Failed to update customer subnet route"
723+
cleanup_resources
724+
exit 1
725+
fi
716726
fi
717727

718728
echo ""

0 commit comments

Comments
 (0)