Skip to content

Resource handler returned message: "The CIDR '172.28.0.0/15' is invalid.

0

Hi All,

I wrote a cloud formation template, basically it is deploying VPC, subnets, SG's & etc., etc. with VPC IP address being 172.16.0.0/12.

Can anyone review and tell me what wrong am I doing here ? I almost lost 3 hrs trying to figure out.

Below table shows that all these subnets are part of 172.16.0.0/12. So I can technically use it.

172.16.0.0/15 172.16.0.0 - 172.17.255.255 172.16.0.1 - 172.17.255.254 131070 Divide 172.18.0.0/15 172.18.0.0 - 172.19.255.255 172.18.0.1 - 172.19.255.254 131070 Divide 172.20.0.0/14 172.20.0.0 - 172.23.255.255 172.20.0.1 - 172.23.255.254 262142 Divide 172.24.0.0/14 172.24.0.0 - 172.27.255.255 172.24.0.1 - 172.27.255.254 262142 Divide 172.28.0.0/15 172.28.0.0 - 172.29.255.255 172.28.0.1 - 172.29.255.254 131070 Divide 172.30.0.0/15 172.30.0.0 - 172.31.255.255 172.30.0.1 - 172.31.255.254 131070 Divide

Now whenever I try to deploy the template it throws below error.

2026-01-26 20:00:53 UTC+0530
dbtiersubnet01
CREATE_FAILED
Likely root cause
-
Resource handler returned message: "The CIDR '172.28.0.0/15' is invalid. (Service: Ec2, Status Code: 400, Request ID: cc38a4c1-7d83-4283-9e6e-f51966ef63e4) (SDK Attempt Count: 1)" (RequestToken: f3348a64-0655-c03b-77fc-c5d07c1e5208, HandlerErrorCode: InvalidRequest)

Thanks, Piyush

asked 9 months ago203 views

4 Answers
0

Okay, thanks for the response but it is not the case. If you check the below ranges all are logically correct and falls under VPC 172.16.0.0/16.

172.16.0.0/18 172.16.0.0 - 172.16.63.255 172.16.0.1 - 172.16.63.254 16382 Divide 172.16.64.0/18 172.16.64.0 - 172.16.127.255 172.16.64.1 - 172.16.127.254 16382 Divide 172.16.128.0/18 172.16.128.0 - 172.16.191.255 172.16.128.1 - 172.16.191.254 16382 Divide 172.16.192.0/19 172.16.192.0 - 172.16.223.255 172.16.192.1 - 172.16.223.254 8190 Divide 172.16.224.0/20 172.16.224.0 - 172.16.239.255 172.16.224.1 - 172.16.239.254 4094 Divide 172.16.240.0/20 172.16.240.0 - 172.16.255.255 172.16.240.1 - 172.16.255.254 4094 Divide

But I still get the same error.

2026-01-26 21:08:16 UTC+0530 dbtiersubnet01 CREATE_FAILED Likely root cause

Resource handler returned message: "The CIDR '172.16.192.0/19' is invalid. (Service: Ec2, Status Code: 400, Request ID: 25cf8e65-96df-4c5e-a078-8f6d495ffb2c) (SDK Attempt Count: 1)" (RequestToken: d48a7f34-9c0a-8c12-8c20-c3004c636967, HandlerErrorCode: InvalidRequest)

answered 9 months ago

  • Could you please share the specific CloudFormation template you are currently using?

0

The issue you're encountering is related to the CIDR block size you're trying to use for your VPC. While your calculations show that 172.16.0.0/12 encompasses all the subnets you've listed, AWS has specific limitations on VPC CIDR block sizes.

In AWS, VPC CIDR blocks must have a prefix length between /16 and /28. Your main VPC CIDR of 172.16.0.0/12 is too large (it contains too many IP addresses) for AWS to accept. The /12 prefix is outside the allowed range.

For your subnets like 172.28.0.0/15, the error occurs because you're trying to create a subnet with a CIDR that's either:

  1. Not within your VPC's CIDR block (if you've defined your VPC with a different CIDR)
  2. Too large for a subnet (subnets must be within the VPC CIDR and can't be larger than the VPC itself)

To fix this issue:

  1. Define your VPC with a valid CIDR block size (e.g., 172.16.0.0/16)
  2. Ensure all your subnets have CIDR blocks that fall within your VPC's CIDR
  3. Make sure your subnet CIDRs don't overlap with each other

If you need a very large address space, you can create multiple VPCs and connect them using VPC peering or AWS Transit Gateway.
Sources
Adopting IPv6 to your existing Amazon VPC | AWS re:Post

answered 9 months ago

EXPERT

reviewed 9 months ago

0

Hello.

As stated in the following document, the CIDR range that can be used for a VPC is between /16 and /28.
Therefore, if you pass a CIDR that cannot be accepted by AWS, such as /12, to the parameters when creating a VPC, the error you described will occur.
As stated in the AI ​​automated response from AWS re:Post Agent, if you create it as /16 it will work. https://docs.aws.amazon.com/vpc/latest/userguide/vpc-cidr-blocks.html

When you create a VPC, you must specify an IPv4 CIDR block for the VPC. The allowed block size is between a /16 netmask (65,536 IP addresses) and /28 netmask (16 IP addresses). After you've created your VPC, you can associate additional IPv4 CIDR blocks with the VPC. For more information, see Add or remove a CIDR block from your VPC.

EXPERT

answered 9 months ago

0

The CIDR is valid and your CIDRs do not overlap. Can you try pasting your CIDRs in notepad and view all characters and look for any special characters. The special character, if there, most likely causing your CIDR to be invalid. Alternatively, if copy/paste the CIDRs from somewhere, you can type it in instead of copying.

EXPERT

answered 9 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.