Skip to content

Latest commit

 

History

History
100 lines (85 loc) · 3.64 KB

README.md

File metadata and controls

100 lines (85 loc) · 3.64 KB

cdktf-cloudrun-template

Cloud Development Kit for Terraform (CDKTF) services template deployed on google cloud platform. Read more on cdktf here

Project structure

├── .github
│   └── workflows
│       ├── deployment.yml
│       └── codeql.yml
├── .gitignore
├── LICENSE
├── README.md
└── api
└── client
└── cdktf
    ├── __tests__
    │   └── main-test.ts
    ├── cdktf.json
    ├── help
    ├── jest.config.js
    ├── main.ts
    ├── package-lock.json
    ├── package.json
    ├── setup.js
    ├── stacks
    │   ├── cloudrun.ts
    │   ├── config
    │   │   └── index.ts
    │   └── index.ts
    └── tsconfig.json

Infrastructure Diagram

infra diagram

Setting up deplouyment to gcp artifact registry

  • Install CDKTF cli
      npm install --global cdktf-cli@latest
  • Create a service account key file on gcp service account
  • Create a json key file on gcp keyfile
  • Create an images folder on gcp artifact registry to hold your container services artifact registry
  • Use the keyfile contents to set the following github action secrests. To learn how to set gihub action secrets visit https://docs.github.com/en/actions/security-guides/encrypted-secrets
Environment Variable Description
IMAGE_NAME Contianer service image name e.g users-service
PROJECT_ID Google cloud project id
GCP_REGION Region to deploy your container service e.g us-central-1
GOOGLE_CREDENTIALS JSON string of your google cloud service account key file content
API_ARTIFACT_REGISTRY_CONTAINER Artifact registry container name for the application api / server
CLIENT_ARTIFACT_REGISTRY_CONTAINER Artifact registry container name for the application client

Deploying locally

# Install required dependencies for project
make tools
# Enter the cdktf folder
cd cdktf

# List resources to be created via cdktf
cdktf list 

# Deploy resources to gcp
cdktf deploy --all

# Destroy resources to gcp
cdktf destroy --all 

Registering services with cloud run

In file cloudrun.ts

Update add artifact registry image services for cloudrun to deploy via cdktf services

Docs

Built With

Authors