Cloudanix Joins AWS ISV Accelerate Program

Cloudanix – Your Partner in Cloud Security Excellence

Creating CNAME for Google Cloud Functions

  • Ajinkya Jawalkar Ajinkya Jawalkar
  • Monday, Jan 23, 2023

In this blog, we will create a CNAME for our cloud functions with path matches. The problem with cloud functions is that they use long URLs. We will be using the load balancer method to create a CNAME. We will create three path matches for three separate cloud functions.

  • Firstly we have to create a domain name in any domain registrar of your choice like Cloudflare. For example mysamplefunctions.com
  • To use this method we need a project owner or project editor role or the following permissions

Network Admin: Create load balancer and networking components

Compute Instance Admin: Create and modify NEGs

Security Admin: Create and modify SSL certificates

  • We need to set up a global IP address to reach the load balancer
    Run the following command
gcloud compute addresses create function-ip \
--network-tier=PREMIUM \
--ip-version=IPV4 \
--global

gcloud compute addresses describe function-ip \
--format="get(address)" \
--global

Console

Reserving a static address
  • Create a serverless NEG (network endpoint group) for your first function let’s say. Image processor. The --cloud-function-name should be the name that you see for the function in the cloud console.
gcloud compute network-endpoint-groups create imageprocessorneg \
--region=us-central1 \
--network-endpoint-type=serverless \
--cloud-function-name=imageprocessor

Console

Creating a network endpoint group

Add the FQDN and keep the other fields as is

filling details of the network endpoint group
  • Create a backend service for the same.
gcloud compute backend-services create imageprocessorservice \
--load-balancing-scheme=EXTERNAL \
--global

You cannot create a global backend service from the console. To create a regional backend service

new regional backend service

Specify the network endpoint group name created in the previous step in the below drop-down menu.

adding the network endpoint group
  • Add the serverless NEG as a backend-to-backend service
gcloud compute backend-services add-backend imageprocessorservice \
--global \
--network-endpoint-group=imageprocessorneg \
--network-endpoint-group-region=us-central1
  • Create a NEG for your second Cloudrun service let’s say video processor. The --cloud-function-name should be the name that you see for the function in the cloud console
gcloud compute network-endpoint-groups create videoprocessorneg \
--region=us-central1 \
--network-endpoint-type=serverless \
--cloud-function-name=videoprocessor
  • Create backend service for same.
gcloud compute backend-services create videoprocessorservice \
--load-balancing-scheme=EXTERNAL \
--global
  • Add serverless NEG as backend to backend service.
gcloud compute backend-services add-backend videoprocessorservice \
--global \
--network-endpoint-group=videoprocessorneg \
--network-endpoint-group-region=us-central1
  • Create a NEG for your third Cloudrun service let’s say audio processor. The --cloud-function-name should be the name that you see for the function in the cloud console
gcloud compute network-endpoint-groups create audioprocessorneg \
--region=us-central1 \
--network-endpoint-type=serverless \
--cloud-function-name=audioprocessor
  • Create backend service for same.
gcloud compute backend-services create audioprocessorservice \
--load-balancing-scheme=EXTERNAL \
--global
  • Add serverless NEG as a backend to backend service.
gcloud compute backend-services add-backend audioprocessorservice \
--global \
--network-endpoint-group=audioprocessorneg \
--network-endpoint-group-region=us-central1
  • Create a URL map to route incoming requests to the backend service.
gcloud compute url-maps create myurlmap \
--default-service imageprocessorservice

The --default-service will be used if no path is specified in the url.

  • Create path matchers for all the services.
gcloud compute url-maps add-path-matcher myurlmap \
--path-matcher-name=service-matcher \
--new-hosts=mysamplefunctions.com \
--default-service=imageprocessorservice \
--backend-service-path-rules='/image=imageprocessorservice,/video=videoprocessorservice,/audio=audioprocessorservice'
  • Create a target HTTP(S) proxy to route requests to your URL map.
gcloud compute target-http-proxies create myhttpproxy \
--url-map=myurlmap

Console steps 13, 14, and 15:
a. Create a http load balancer

create a http load balancer

b. Select the backend services created in the previous step

select backend service created

c. Add the host and path rules. Add the respective backend services in the last column.

adding host and path rules

d. Click Create

  • Create a global forwarding rule to route incoming requests to the proxy.
gcloud compute forwarding-rules create myhttpforwadingrule \
--load-balancing-scheme=EXTERNAL \
--network-tier=PREMIUM \
--address=function-ip \
--target-http-proxy=myhttpproxy \
--global \
--ports=80
  • After the load balancer is created, note the IP address that is associated with the load balancer: for example, 30.90.80.100. To point your domain to your load balancer, create an A record using your domain registration service.

  • Make sure that proxy is disabled in the domain registrar like Cloudflare so the traffic is routed to the load balancer.

  • So you can now access the functions in the following manner.
    – For image processor
    mysamplefucntions.com/image
    – For video processor.
    mysamplefucntions.com/video
    – For Audio processor.
    myaudioprocessor.com/audio

  • The document for reference are

  1. https://cloud.google.com/load-balancing/docs/https/setting-up-https-serverless#gcloud:-cloud-functions
  2. https://cloud.google.com/load-balancing/docs/url-map-concepts
  3. https://cloud.google.com/load-balancing/docs/negs/serverless-neg-concepts

People Also Read

What Our Users Are Saying

Customer Reviews

Cloudanix is trusted by security leaders worldwide to deliver proactive, reliable, and cutting-edge cloud security.

One day, I changed the password of a root account, and my CTO called me within less than a minute to confirm if I did so. I was not expecting a reaction this quick. He told me Cloudanix alerted him of this password change and that he wanted to confirm as it was a critical security notification. I couldn't believe it!

Ritesh Agarwal
Ritesh Agarwal
CEO, Airgap Networks

Compliance is one way of staying secure, but what I want is the ability to go deeper and attain 'true security.' Cloudanix provides us the capability to do so.

Vishal Madan
Vishal Madan
Head of Engineering, iMocha

Cloudanix is building for the future of the cloud, which makes the product all the more desirable.

Ritesh Agarwal
Ritesh Agarwal
CEO, Airgap Networks

Cloudanix gave us the visibility we were missing. Being able to move from permanent access to a robust Just-In-Time (JIT) workflow has fundamentally changed our security posture without slowing down our engineering velocity.

Pavan Kumar Lekkala
Pavan Kumar Lekkala
SRE Lead, HugoHub

We are excited to leverage Cloudanix's comprehensive multi-cloud DevSecOps solution to secure our production workloads on AWS. Cloudanix has demonstrated that it can solve many challenges that DevSecOps teams face while continually adding new features such as SOC2 compliance and drift detection.

Satish Mohan
Satish Mohan
Co-founder & CTO, Airgap Networks

Managing third-party partner access was once a major concern for our security posture. With Cloudanix JIT Cloud, we've effectively achieved zero third-party risk. We can now grant access confidently, knowing that it is temporary, audited, and automatically revoked, resulting in a 100% reduction in our privileged access exposure.

Okesh Badhiye
Okesh Badhiye
Head of Technical Engineering, Finfinity

The snooze feature and responsible alerts have helped us save time and prioritize what to tackle first.

Satish Mohan
Satish Mohan
Co-founder & CTO, Airgap Networks

Implementing Cloudanix JIT internally allowed us to practice what we preach. By eliminating permanent access to our own clouds and databases, we've neutralized the risk of standing privileges, ensuring our own 'keys to the kingdom' are never left exposed.

Girish Manghnani
Girish Manghnani
Managing Partner, Tech Inspira

The problem with permissions is a lot of times, the gaps are left open due to oversights from inside the organization itself. With Cloudanix's CIEM, we get a complete view of user permissions and access. This enables us to update the permissions, reducing the attack surface.

Nilesh Pethani
Nilesh Pethani
Application Architect, iMocha

In the world of Fintech, trust is our currency. Cloudanix provided the frictionless visibility we needed to secure our EKS workloads across AWS, ensuring we stay audit-ready for SOC2 and GDPR without slowing down our engineering velocity.

Amol Naik
Amol Naik
Head of Security & Infrastructure, HugoHub

Cloudanix delivered value within 5 minutes of onboarding. Continuous monitoring, timely detection, and excellent documentation helped us attain a great cloud security posture.

Divyanshu Shukla
Senior DevSecOps, Meesho

Technology strategies and business strategies are in a state of constant change which includes centralization and decentralization of responsibilities. Regardless of strategic shift, we still have intellectual property to protect. Cloudanix are critical partners for us in our public cloud security posture across our three cloud providers.

Jerry Locke
Jerry Locke
Senior Director Global Solutions Engineering, Eversana

Cloudanix has been amazing. They opened up a common Slack channel with us — and it feels like we are talking to our own team and getting things done with Cloud security. The support team is always available, friendly, helpful, and ready to go out of their way.

Satish Mohan
Satish Mohan
CTO, Airgap Networks

Beyond just access management, Cloudanix CSPM has given us a unified view of our AWS environment. The real-time alerting and anomaly detection allow us to prevent any untoward activity before it happens, which is critical for a marketplace connecting 50+ financial institutions.

Okesh Badhiye
Okesh Badhiye
Head of Technical Engineering, Finfinity

For a Fintech company, data is our most valuable — and most sensitive — asset. Cloudanix DAM hasn't just improved our visibility; it has given us control. The ability to mask data and prevent unauthorized queries in real-time is a game-changer for our compliance and customer trust.

Jiten Gala
Jiten Gala
President Engineering and Product, Kapittx

Our clients, especially in the Middle East financial sector, demand absolute accountability. Cloudanix JIT Cloud has been a competitive differentiator for us, allowing us to provide secure, governed access to customer accounts that meet their strictest audit and compliance requirements.

Girish Manghnani
Girish Manghnani
Managing Partner, Tech Inspira

Cloudanix is always on my team's lips because of its exceptional support. Be it a small or big query, Cloudanix has gone above and beyond to resolve them. This one's a keeper for us.

Sujit Karpe
Sujit Karpe
CTO, iMocha

For a long-lasting partnership, great support goes a long way. Cloudanix has delivered exceptional support whenever required. Their edge is their team is always ready to go beyond to solve any issues that we have. This speaks volumes about the culture at Cloudanix.

Akash Maheshwari
Akash Maheshwari
Co-founder, MoveInSync

Beyond the technology, Cloudanix feels like an extension of our own team. Their willingness to stand up a dedicated Middle East tenant for us and provide exceptional support at a sensible price makes them a long-term partner for Hugosave.

Surya Tamada
Surya Tamada
CTO, HugoHub

The real-time notifications that Cloudanix provides are a real lifesaver. Their adaptive notifications ensure that my team stays productive and doesn't get interrupted all the time.

Digvijay Singh
Staff Security Engineer, Meesho

The whole point in technological evolution is to help improve the world we live in. We must protect that and to do so requires an effective and efficient security strategy. The Cloudanix team helped make our public cloud security posture management strategy a reality. The symbiotic relationship we have allows for a continuous feedback loop which is how business should operate.

Larry Wheat
Larry Wheat
Staff Solutions Engineer, Eversana

Ready to see your graph?

Connect a cloud account in under 30 minutes. See every finding rooted in identity, asset, and blast radius — with a fix path attached.

Book a Demo