This project contains a Google Cloud Function written in Java that handles Pub/Sub messages. The function is responsible for processing incoming messages from Pub/Sub, extracting relevant data, sending emails using MailGun SMTP, and updating a PostgreSQL database using serverless VPC connector .
-
Prerequisites:
- Google Cloud Platform account
- Java Development Kit (JDK) installed
- Maven installed
-
Clone the repository:
git clone https://github.com/your-username/gcfv2pubsub.git cd gcfv2pubsub
-
Environment Variables:
Make sure to set the following environment variables:
mailgun_email
: Email address used for sending emails via MailGun.api_key
: API key for MailGun authentication.db_ip
: private IP address of the PostgreSQL database server.password
: Password for the PostgreSQL database.
gcloud functions deploy pubSubFunction \
--entry-point=gcfv2pubsub.PubSubFunction \
--runtime=java17 \
--trigger-topic=your-topic-name \
--memory=512MB \
--region=your-region