Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to resolve "The external IP address 'IP_ADDRESS_NAME' was not found in region" in GCP

First question on StackOverflow. Feel free to ask if more context is needed and thank you in advance.

I'm setting up a Google Compute Engine Managed Instance Group that has two requirements:

  • Easy HTTPS configuration. Hence the use of managed instance group with a loadbalancer.
  • Static IP for IP whitelisting by a third party.

I know the static IP makes it not horizontally scalable but that doesn't matter in this scenario.

The problem I'm facing is that static IP address can not be applied to the instance group because GCE states that the name is not found in the region. The deal is, the static IP address region is europe-west4 and the managed group zone is europe-west4a so it should be able to find it, right?

So my question is, why isn't this working?

I've tried making the instance-group region based instead of zone based but that gives the same error.

The command line is throwing the error:

# [START create_template]

  gcloud compute instance-templates create ${TEMPLATE} \
    --image-family=${IMAGE_FAMILY} \
    --image-project=${IMAGE_PROJECT} \
    --machine-type=${MACHINE_TYPE} \
    --scopes=${SCOPES} \
    --metadata-from-file startup-script=${STARTUP_SCRIPT} \
    --tags ${TAGS}\
    --metadata BUCKET=${BUCKET} \
    --address=${STATIC_IP_ADDRESS_NAME}

# [END create_template]

# Create the managed instance group.
# [START create_group]
  gcloud compute instance-groups managed create ${GROUP} \
    --base-instance-name ${GROUP} \
    --size 1 \
    --template ${TEMPLATE} \
    --zone europe-west4-a

# [END create_group]

The expected output is creating a compute engine with a static egress IP address.

I'm getting the following error.

ERROR: (gcloud.compute.instance-groups.managed.create) Could not fetch resource:
 - Invalid value for field 'resource.instanceTemplate': 'https://www.googleapis.com/compute/v1/projects/companyproject-test/global/instanceTemplates/service-name-group-tmpl'. Unable to create an instance from instanceTemplate service-name-group-tmpl in zone europe-west4-a:
        Invalid value for field 'instance.networkInterfaces[0].accessConfigs[0].natIP': The specified external IP address 'STATIC_IP_ADDRESS_NAME' was not found in region 'europe-west4'

In the documentation of Static external IP addresses they state that a resources of that region or zone can use a static IP address. See 'Static external IP addresses' in the documentation.

Also, the documentation that states adding an address to a single instance template is possible. Link

like image 469
Nils Groen Avatar asked Dec 06 '25 08:12

Nils Groen


1 Answers

Resolved the problem by assigning the static IP address to the single instance in the group with the following commands:

# Retrieve the single instance name and save it in a variable
  instance=`gcloud compute instance-groups managed list-instances name-group --zone=europe-west4-a --format="value(instance.basename())"`

# Remove the existing external NAT of the instance
  gcloud compute instances delete-access-config $instance \
    --access-config-name "External NAT" \
    --zone=$ZONE
# Add the new external NAT that has the static address
    gcloud compute instances add-access-config $instance \
   --access-config-name "External NAT" \
    --address $IP_ADDRESS \
    --zone=$ZONE
like image 85
Nils Groen Avatar answered Dec 08 '25 01:12

Nils Groen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!