GCP SDK Fun

Sometimes, especially if you aren’t a developer by trade, you can get stuck on something small that will find you banging your forehead on your desk (figuratively, of course). Most of the time, it is easy enough to find an answer online or even from ChatGPT. Other times, you may not be so lucky. The other day, I fell victim to a TWE or time wasting event that I thought was worth writing about. Fasten your seatbelt!

Intro
Intro

GCP SDK provides libraries and tools for interacting with Google’s cloud products and services. Pick your poison with whatever programming language you choose! On this particular Fun Day, I was writing a quick script to build VPCs and subnets from .yaml files and then expose a destroy call to wipe everything out when particular testing was completed. I’ve built something similar for AWS SDK for Go. On this particular day, I ran into the following error:

Error
Error

I knew I had to set AutoCreateSubnetworks: false, in the code as it disables GCP from automagically creating subnets for me. Of course, I want to do that myself! And this is where the confusion started – I did have this set, and I had omitted the ‘IPv4Range’ at the VPC level despite what the error said.

I searched on DuckDuckGo, my search engine of choice, and came up empty. In my desperation, I turned to a bucket-of-bolts I don’t fully understand who’s supposed to know all the answers, ChatGPT. I pasted in the error message and code. The AI Overlord then patted me on the back (again figuratively) and told me to set AutoCreateSubnetworks: false and remove IPv4Range from my code since that is for legacy networks. The problem is that IPv4Range wasn’t defined anywhere in my code and AutoCreateSubnetworks was already set to false.

As I sat pondering reality, space, and time, I decided to just google search it and came across this excellent answer on Stack Overflow. Apparently, the AutoCreateSubnetworks field is not included in the request payload unless you define it explicitly with ForceSendFields: []string{“AutoCreateSubnetworks”},. All I needed was this extra line:

Artificial Intelligence is a society-altering technology. Is it coming for our jobs anytime soon? I don’t think so. Will it help enhance and augment our workflows? Yes, Absolutely! However, situations like this remind me that there is no substitute for people who possess deep skills and understanding in particular areas of technology. This holds especially TRUE when something fails or isn’t exhibiting the correct behavior. Happy coding!