This Magento module will extend the Magento 2 serverless framework module allowing us to use Google Cloud Functions.
- Magento >= 2.4.5-p1
- PHP >= 8.1
- Grpc for PHP
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
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: