# Introducing a new Eventarc destination - internal HTTP endpoint in a VPC network

Author: [Mete Atamel](https://atamel.dev/) | Published: 2023-11-13 | Topics: Workflows, Serverless, Google Cloud Platform, How To | Canonical: https://atamel.dev/posts/2023/11-13_introduce_eventarc_internal_http_endpoint/


## Introduction

[Eventarc](https://cloud.google.com/eventarc/docs) helps users build
event-driven architectures without having to implement, customize, or maintain
the underlying infrastructure.

Eventarc has added support (in public preview) for delivering events to internal
HTTP endpoints in a Virtual Private Cloud (VPC) network. Customers, especially
large enterprises, often run compute (typically GKE or GCE) on VPC-private IPs,
often behind internal load balancers. This launch will enable these services to
consume Eventarc events.

Internal HTTP endpoints can be an [internal IP
address](https://cloud.google.com/vpc/docs/ip-addresses) or [fully qualified DNS
name
(FQDN)](https://cloud.google.com/compute/docs/internal-dns#instance-fully-qualified-domain-names)
for any HTTP endpoint in the VPC network. Examples of destinations that can be
targeted via the internal HTTP endpoints include [Compute Engine
VMs](https://cloud.google.com/compute/docs/ip-addresses) with internal IPs,
services fronted by an [L7 Internal Load
Balancer](https://cloud.google.com/load-balancing/docs/dns-names), [Private
Service Connect
endpoints](https://cloud.google.com/vpc/docs/configure-private-service-connect-services#list-endpoints),
[Google Kubernetes Engine
Ingress](https://cloud.google.com/kubernetes-engine/docs/how-to/internal-load-balance-ingress#validate),
[Google Kubernetes Engine
Services](https://cloud.google.com/kubernetes-engine/docs/concepts/service),
[Cloud Run behind an internal Application Load
Balancer](https://cloud.google.com/load-balancing/docs/l7-internal/setting-up-l7-internal-serverless)
and any destinations registered with Cloud DNS via [DNS
record](https://cloud.google.com/dns/docs/records-overview).

## Create a trigger to an internal HTTP endpoint

To create an Eventarc trigger to an internal HTTP endpoint hosted in a VPC
network subnet, you need to go through a couple of steps.

First, you need to create a firewall rule that allows ingress traffic to your
internal HTTP endpoint (in this case 80):

```sh
gcloud compute firewall-rules create $RULE_NAME \
    --network=projects/$PROJECT_ID/global/networks/$NETWORK_NAME \
    --direction=INGRESS \
    --priority=1000 \
    --action=ALLOW \
    --source-ranges=10.10.10.0/24 \
    --rules=tcp:80
```

Note that `--source-ranges` is optional and if provided, it needs to be the same
as what's used in the subnet. It enables the firewall rule to specifically
capture the ranges where Eventarc delivery traffic is coming from via the PSC
network attachment.

Second, you need to create a network attachment. A [network
attachment](https://cloud.google.com/vpc/docs/about-network-attachments) is a
regional resource that lets you explicitly authorize Eventarc to connect to a
VPC network. Eventarc uses the network attachment to establish a connection to
the internal HTTP endpoint hosted in a VPC network.

```sh
gcloud compute network-attachments create $ATTACHMENT_NAME \
    --region=$REGION \
    --subnets=$SUBNET_NAME \
    --connection-preference=ACCEPT_AUTOMATIC
```

Now, you can create an Eventarc trigger to the internal HTTP endpoint (running
on a Compute Engine VM in this instance) with the network attachment:

```sh
gcloud eventarc triggers create $TRIGGER_NAME \
    --location=$REGION \
--destination-http-endpoint-uri=http://$INSTANCE_NAME.$ZONE.c.PROJECT_ID.internal \
    --network-attachment="projects/$PROJECT_ID/regions/$REGION/networkAttachments/$ATTACHMENT_NAME" \
    --event-filters="type=google.cloud.pubsub.topic.v1.messagePublished" \
    --service-account=$PROJECT_NUMBER-compute@developer.gserviceaccount.com
```

That’s it! Now, your internal Compute Engine VM can receive Pub/Sub events from
Eventarc. For an end-to-end tutorial, check out [Receive Pub/Sub events at an
internal HTTP endpoint in a VPC
network](https://cloud.google.com/eventarc/docs/vpc-endpoints/receive-vpc-events).

## Limitations

There are some limitations you need to be aware of:

* You can't create more than one Eventarc trigger for the same DNS name. This will be resolved soon.
* There is a limit of 100 Eventarc triggers for internal HTTP endpoints per project.
* Only the following Eventarc trigger locations are supported (but more regions are coming soon): `asia-east1`, `europe-north1`, `europe-west1`, `us-central1`, `us-east1`. More regions are coming soon.

## Learn more

To learn more, check out the official documentations and tutorials:

* [Route events to an internal HTTP endpoint in a VPC
  network](https://cloud.google.com/eventarc/docs/vpc-endpoints/route-vpc-internal-endpoint-events)
* [Receive Pub/Sub events at an internal HTTP endpoint in a VPC
  network](https://cloud.google.com/eventarc/docs/vpc-endpoints/receive-vpc-events)

As always, feel free to reach out to me on Twitter
@[meteatamel](https://twitter.com/meteatamel) for feedback and questions.

