Skip to content

Commit

Permalink
Fixed deregistration
Browse files Browse the repository at this point in the history
  • Loading branch information
carlssonk committed Sep 27, 2024
1 parent 7a6ffb0 commit e7a1178
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion modules/ecs-service/resources/deregister_instance.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ ECS_SERVICE_NAME="$2"
CLUSTER_NAME="MainCluster"

# Look up the service ID using the discovery name
SERVICE_ID=$(aws servicediscovery list-services --filters Name="NAME",Values="$DISCOVERY_NAME",Condition="EQ" --query 'Services[0].Id' --output text)
SERVICE_ID=$(aws servicediscovery list-services --query "Services[?Name=='$DISCOVERY_NAME'].Id" --output text)

if [ -z "$SERVICE_ID" ]; then
echo "Failed to find service ID for discovery name: $DISCOVERY_NAME"
Expand Down
5 changes: 2 additions & 3 deletions modules/ecs-service/resources/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@ resource "null_resource" "deregister_instance_from_aws_service_discovery_service
}

provisioner "local-exec" {
when = destroy
command = "${path.module}/deregister_instance.sh ${self.triggers.discovery_name} ${self.triggers.service_name}"
on_failure = continue
when = destroy
command = "${path.module}/deregister_instance.sh ${self.triggers.discovery_name} ${self.triggers.service_name}"
}
}

Expand Down

0 comments on commit e7a1178

Please sign in to comment.