Git Product home page Git Product logo

a5-iim-tf-gcp-challenge's Introduction

a5-iim-tf-gcp-challenge

Initialisation

(Optionnel) Pour éviter de renseigner à la main les différentes variables à chaque fois, on peut créer un fichier terraform.tfvars les contenant :

region = "europe-west1"
zone = "europe-west1-d"
project = "project-id-12345667"
backend = "uniquebucketname"
location = "EU"
dataset = "datasetname"
table = "tablename"

Activer les API Google Cloud nécessaires : (lien)[https://console.cloud.google.com/flows/enableapi?apiid=cloudbuild.googleapis.com,run.googleapis.com,artifactregistry.googleapis.com,cloudfunctions.googleapis.com,storage.googleapis.com]

Initialiser Terraform :

terraform init

Créer le bucket pour stocker le backend :

terraform plan -target=module.bucket.google_storage_bucket.backend -out=plan.tfplan
terraform apply plan.tfplan

Mettre à jour main.tf en ajoutant ce bloc à terraform (l.7) :

  backend "gcs" {
    bucket = "<nom choisi précédemment>"
    prefix = "terraform/state"
  }

Puis migrer le state vers le backend distant :

terraform init -migrate-state

Création

Exécuter Terraform :

terraform apply

Il se chargera de provisionner l'infrastructure pour nous.

Test

Une fois la fonction prête, on peut la tester avec :

curl -H "Authorization: bearer $(gcloud auth print-identity-token)" $(gcloud functions describe hello_world --gen2 --region=europe-west1 --format="value(serviceConfig.uri)")

gcloud auth print-identity-token permet d'authentifier la requête, et gcloud functions describe hello_world --gen2 --region=europe-west1 --format="value(serviceConfig.uri)" permet de récupérer l'URL de la fonction. Remplacer europe-west1 par la région choisie si besoin.

On peut ensuite vérifier dans la console de Google Cloud que les données ont été ajoutées à BigQuery.

a5-iim-tf-gcp-challenge's People

Contributors

souchetjulie avatar

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.