Skip to content

vediatoni/over_engineered_http_service

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tech stack

Go v1.17.3 The main http service is coded in Go.

Google Cloud Platform - GCP For infrastructure:

Terraform For infrastructure provisioning on GCP

Dockerfile For packaging app into container

Project file structure

/cmd Main code for this project.

/build Packaging and Cloud Build file for CI/CD

/deployments Terraform files

You can read more about the structure here

Instructions

  1. Create a project on GCP
  2. Enable Cloud Resource Manager API
  3. Create a service account on GCP (IAM) and download json auth keys for this account (make sure to give it the right permissions- Editor, Project IAM Admin)
  4. Move the json auth file to the root path of this project
  5. Connect repository to the Cloud Build > trigger
  6. Create deployments/terraform.tfvars file and make sure to configure these variables: artifact_registry, project, organization, credentials_file use deployments/variables.tf as a reference
  7. Update ./build/cloudbuild_on_push.yaml substitutions _REPO_NAME, _URL correctly
  8. Run terraform apply
  9. Run Cloud Build trigger (via GUI or git push event)

Extra

To run tests

go test ./cmd/server/ 

To run the service

go run ./cmd/server/

Test the service

GET https://app-oehs-qs4uvgfbba-uc.a.run.app/1/data  
# expected {"accountId":1,"timestamp":"2021-12-07T10:04:12.942215649Z","data":"Something new"}
  
GET https://app-oehs-qs4uvgfbba-uc.a.run.app/
# expected "Hello"

GET https://app-oehs-qs4uvgfbba-uc.a.run.app/testing/data
# expected "Couldn't parse the accountId, make sure it's an integer!"

About

A fun little challenge/homework/assignment

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published