Prefix length error message received when deploying IPsec over Interconnect using Terraform

Problem

While creating IPsec over Interconnect using Terraform, you get the following error message:
The IP address does not match the given prefix length, it has invalid CIDR format.

Environment

  • Google Cloud Platform project
  • IPsec Over Interconnect
  • Terraform template

Solution

You need to use a valid CIDR format when defining the IP addresses to be used.
For example:
  • 10.40.31.185/29 is not the right IP range (CIDR block)
  • The right IP range for the 29 prefix is 10.40.31.184/29.
You can use an online IP calculator to help them find the right CIDR block.

Cause

CIDR block used to define the IP addresses is not correct.