imdigital/magento-serverless-gcp

Add Google Cloud functions to the serverless framework

1.0.1 2023-03-14 17:48 UTC

This package is auto-updated.

Last update: 2024-04-14 20:03:44 UTC


README

Magento logo       Google Cloud logo

Google Cloud Functions for the Magento 2 Serverless Framework

This Magento module will extend the Magento 2 serverless framework module allowing us to use Google Cloud Functions.


68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c616e67756167652d5048502d626c7565 68747470733a2f2f696d672e736869656c64732e696f2f62616467652f45636f6d6d657263652d4d6167656e746f2d6f72616e6765 68747470733a2f2f696d672e736869656c64732e696f2f62616467652f486f7374696e6725323050726f76696465722d476f6f676c65253230436c6f75642d626c7565 68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4372656174656425323042792d494d4469676974616c2d6f72616e6765


Installation

Requirements


Installing the module and enabling it

To install this module we must run the composer require command requesting its installation:

composer require imdigital/magento-serverless-gcp

Then, enable it by modifying the app/etc/config.php or running the CLI command:

php bin/magento module:enable ImDigital_ServerlessGcp


Serverless function setup

When adding a new serverless function into the serverless_functions database table, we must use gcp as the cloud provider code on the cloud_provider field.

The cloud config field expects a (encrypted) JSON on this format:

{
    "region_id": "us-central1",
    "serviceaccount_key": {
        "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
        "auth_uri": "https://accounts.google.com/o/oauth2/auth",
        "client_email": "my-service-account-email",
        "client_id": "my-client-id",
        "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/my-cert-url",
        "private_key": "my-private-key",
        "private_key_id": "my-private-key-id",
        "project_id": "my-gcp-project-id",
        "token_uri": "https://oauth2.googleapis.com/token",
        "type": "service_account"
    }
}

The region_id is the region where the cloud function is hosted. The serviceaccount_key field is a service account that we must create, and then generate a JSON service account key with access to execute the functions.

These are the permissions you must add to your service account in order to be able to execute cloud functions:


Service Account permissions
Service account permissions