Cloud Development Kit for Terraform (CDKTF) services template deployed on google cloud platform. Read more on cdktf here
├── .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
- Install
CDKTF
clinpm install --global cdktf-cli@latest
- Create a service account key file on gcp
- Create a json key file on gcp
- Create an
images
folder on gcpartifact registry
to hold your container services - 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 |
# 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
In file cloudrun.ts
Update add artifact registry image services for cloudrun to deploy via cdktf