GithubHelp home page GithubHelp logo

cdktf-gcp-cloud-functions-trial's Introduction

CDKTF GCP Functions Trial

Trial on deploying simple Google Cloud Functions Python application with CDKTF on GCP.

Requirements

Installation

Install CDKTF and gcloud CLI from links above.

Ensure Cloud Build API is enabled in Google project

Clone Project

git clone https://github.com/taiyeoguns/cdktf-gcp-cloud-functions-trial.git

and then change to directory

cd cdktf-gcp-cloud-functions-trial

Create and activate virtual environment

python -m venv venv
source venv/bin/activate

Set up gcloud

If gcloud not already set up, open a command prompt, enter:

gcloud init

and follow the instructions.

Install Requirements

pip install -r requirements.txt

Get terraform modules

cd infrastructure
cdktf get

Run locally

cd application
functions-framework --target=hello_http

Server should be started at http://localhost:8080

GCP Deployment

To spin up resources, enter:

cd infrastructure
cdktf deploy

to auto approve, use:

cd infrastructure
cdktf deploy --auto-approve

If successful, deployed application url should be available from the function_url output in the console, e.g. https://us-east1-positive-cacao-243516.cloudfunctions.net/cf-d1d0b561

Endpoint can be tested with https://us-east1-positive-cacao-243516.cloudfunctions.net/cf-d1d0b561

To tear down resources, use:

cd infrastructure
cdktf destroy

to auto-approve, use:

cd infrastructure
cdktf destroy --auto-approve

Project layout

This project structure combines a CDKTF application and a GCP Functions application. These correspond to the infrastructure and application directories respectively. To run any CDKTF commands, ensure you're in the infrastructure directory, and to run any gcloud Functions framework commands ensure you're in the application directory.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.