This example shows how to run a hello world service on Google Run using Terraform
Prerequisites: Java 11
Terraform is used to create the Google Cloud Run infrastructure needed to deploy our hello world spring boot service. The following commands create the cloud infrastructure and will eventually show the URL of the deployed service,
git clone https://github.com/mozammal/spring-boot-terraform-google-sql-gcloud-run-demo.git
cd spring-boot-terraform-google-sql-gcloud-run-demo
mvn clean compile jib:build
cd terraform
terraform init
terraform plan
terraform apply
terraform output url
You’ve now come to the point where you can finally make post and get requests if you open the URL of the aforementioned deployed service on Google Cloud Run using terraform output url.
-
Method: POST
-
example JSON payload
{
"firstName": "mozammal",
"lastName": "hossain"
}
-
endpoint: http://{url}/customers
-
Method: GET
Destroy the infrastructure that we created in the previous step by running the following command:
terraform destroy