We use cookies to make your viewing experience better. By accepting you consent, you agree to our Cookie policy

Accept
Improve your Craft CMS skills

How To Connect Google Cloud To Craft CMS With A Plugin

10 min read
Connect Google Cloud To Craft CMS With A Plugin

Integrating Google Cloud services into your Craft CMS website unlocks game-changing capabilities, but the setup process can be daunting. This guide provides a foolproof walkthrough to seamlessly connect the power of Google Cloud with the flexibility of Craft CMS using the right plugins. You’ll master service configuration, API access, plugin installation, Cloud Storage syncing, and beyond through actionable steps tailored to developers of all levels. Level up your Craft CMS website today with Google Cloud acceleration, analytics, and integrations made easy.

To integrate Google Cloud services into Craft CMS, first install Craft CMS itself. Next, create a Google Cloud account and enable required APIs. Install a plugin like Supercloud and configure API credentials. Map asset volumes to Cloud Storage buckets for syncing. Connect other services like Cloud SQL databases and BigQuery analytics to unlock powerful workflows.

Prerequisites

Craft CMS Installation and Configuration

To integrate Craft CMS with Google Cloud, you first need to install and configure Craft. Here's a step-by-step guide to setting up Craft CMS:

First, check the system requirements. Craft requires PHP 7.0+, MySQL 5.5+, and at least 256MB of RAM allocated to PHP. Use a hosting provider that meets these requirements.

Next, choose between a zip file download or Composer. The zip file contains everything you need for Craft out-of-the-box. Composer lets you integrate Craft into an existing PHP project and manage dependencies.

With the zip, upload and extract the files to your web server. With Composer, run composer create-project craftcms/craft to install.

Once Craft is installed, complete the web-based setup. This involves creating your first admin account, configuring your site URL, setting a site name, and selecting a language.

After the setup, test that your Craft install works by visiting the front-end site. Then log into the admin dashboard to tweak settings, create user accounts, and build out sections and entries.

Some key settings to configure include:

  • System settings - Set site name, timezone, backup options

  • Email settings - Configure email transport method

  • Categories - Organize your content

  • Fields - Create custom fields for entries

  • User accounts - Add admin and front-end user accounts

With those basics set up, your Craft CMS install is ready for content creation and integration!

Creating a Google Cloud Account

To utilize Google Cloud services, you need a Google Cloud account. Here's how to create one:

First, go to cloud.google.com and click on "Get Started for Free." This lets you start a free 12-month trial.

Next, select your country, accept the terms, and fill in your contact details. You'll need to provide credit card info, but won't be charged during the trial.

Choose your billing plan. Options include pay-as-you-go, fixed monthly, or annual commitment. Pay-as-you-go is flexible for testing.

Configure your payment settings based on your billing plan. Add your credit card or pay through invoice.

With your account created, customize your permissions, organization, settings, and usage controls through the Google Cloud console. For example, you can create projects, add users, and enable APIs.

Take time to review key settings like identity and access management (IAM), billing budgets, resource locations, and security preferences to get up and running smoothly.

Your Google Cloud account unlocks services like Compute Engine, Kubernetes, and Cloud Storage to integrate with Craft.

Core Concepts and Terminology

Before diving into integration, it helps to understand the core concepts and terminology behind Craft CMS and Google Cloud.

In Craft, content is organized into sections which hold entries with fields. For example, you may have an "Articles" section with entries that have fields like "Title" and "Summary."

Assets are files like images and docs. Categories let you tag and group. Users with different permissions manage and publish content.

With Google Cloud, everything sits within projects. Resources like virtual machines and databases provide services. Managed services handle tasks like analytics and machine learning.

Cloud IAM controls access through roles and permissions. APIs and SDKs allow integration with other tools. Billing ties usage to cost monitoring and budget alerts.

Learning this basic terminology will provide context when connecting Craft CMS and Google Cloud together through plugins and services.

Selecting an Integration Plugin

Evaluation Criteria for Plugins

When evaluating integration plugins between Craft CMS and Google Cloud, there are several important criteria to consider. Rather than just a bullet list of features, it's crucial to take a holistic view of factors like pricing, support, documentation quality, development activity, security, ease of use, and Craft CMS compatibility.

Analyze each plugin carefully based on these elements to determine the best fit for your specific use cases and budget. High user ratings and reviews across these criteria typically indicate plugins that are well-supported, maintained, and deliver a smooth integration experience.

Prioritize options with clear setup instructions, active ongoing updates, secure protocols, and a simple interface. The goal is to choose a plugin aligned with your technical skill level that connects essential Google Cloud services to Craft CMS without headaches or hidden costs down the road.

Recommended Integration Plugins

Taking a comprehensive view of the evaluation criteria, some of the top plugins for integration include Supercloud, Craft Cloud Services, and CloudCraft. Supercloud offers a robust free tier with no ongoing fees, covering essential services like Cloud Storage, Cloud SQL, and BigQuery.

Craft Cloud Services provides paid premium integrations with excellent customer support. CloudCraft is an open-source, lightweight option focused specifically on Cloud Storage.

Supercloud is likely the best starting point for most, enabling key Google Cloud integrations at no cost. Craft Cloud Services offers more advanced capabilities for those with higher budgets.

CloudCraft is ideal for focused Cloud Storage needs. Consider your specific requirements and resources when deciding among these leading options.

Plugin Features and Considerations

Rather than just a laundry list of features, take a big-picture view when evaluating plugin capabilities. Key integrations like syncing assets to Cloud Storage or hosting your database with Cloud SQL can enable more advanced workflows between Craft CMS and Google Cloud.

Nice-to-have capabilities like push notification support or uptime monitoring provide added value. Compare the plugin feature set to your own short-term and long-term needs. Also investigate setup time, documentation quality, ongoing maintenance needs, and Craft CMS/Google Cloud version compatibility. The goal is to understand how easily a plugin will integrate the specific Google Cloud services you require into your development environment and workflows.

Resist the temptation to choose a plugin based on a simple checklist of features. Carefully weigh how its capabilities, support, and ease of use come together to offer the best integration experience for your needs.

Configuring API Access and Credentials

Enabling Required Google Cloud APIs

To connect Craft CMS to Google Cloud services, you need to enable the necessary APIs in your Google Cloud Platform (GCP) console.

Start by reviewing the plugin documentation to identify which APIs and services you want to integrate. Common examples include Cloud Storage, BigQuery, Cloud SQL, and Cloud Pub/Sub.

In the GCP console, navigate to "APIs and Services" then "Library." Search for and select the required APIs. Click "Enable" to activate each API. This allows API requests from your project.

For advanced services like BigQuery or Cloud Pub/Sub, you may need to configure further settings around usage quotas and permissions. Follow the setup guides specific to each API.

Take time to test enabling APIs by making sample API calls from the console or an SDK. Troubleshoot any errors before progressing to service accounts and credentials.

Creating and Managing Service Accounts

Once required APIs are enabled, the next step is creating a service account for API access:

In the GCP console, go to "APIs & Services" then "Credentials." Click "+ Create credentials" and choose "Service account."

Give the account a name, description and set the required permissions. At minimum, grant "Storage Admin" and "BigQuery Admin" roles.

For added security, grant permissions at the resource level rather than project level when possible.

Click "Create" to generate the service account. This provides an email address and unique ID.

Next, create and download a JSON key for the account. Make sure to secure the key appropriately, since it grants API access.

Manage service accounts from the Credentials page. You can create multiple accounts for different applications and environments (e.g. dev vs prod).

Adding Credentials in Craft CMS

The final step is entering your service account credentials into the Craft CMS plugin settings:

In the Craft CP, go to Settings → Plugins → [Your Google Cloud Plugin]. Locate the settings for API credentials.

Copy and paste the entire JSON contents from the downloaded key into the credential field.

Grant the plugin permission to access the credentials. This authorizes API requests.

That's it! The plugin can now access Google Cloud services using the service account behind the scenes.

Take care not to commit the credentials into version control or expose them publicly for security reasons.

With the account configured in Craft CMS, you can start leveraging Google Cloud services in your project! There are so many Craft CMS plugins to choose from. 

Installing and Configuring the Plugin

Downloading and Installing the Plugin

Once you've selected your integration plugin, it's time to install it into your Craft CMS project.

If using a plugin like Supercloud or Craft Cloud Services from the official Plugin Store, you can install it directly within your Craft CP. Go to Settings → Plugin Store, search for the plugin, and click "Install."

For open source plugins, you'll manually download the ZIP file from Github or the plugin site. Unzip and move the folder to your craft/plugins/ directory.

You may also want to add the plugin as a project dependency with Composer. Edit your composer.json file to require the plugin, then run composer update.

Remember to add the plugin to Craft CMS after installing. Go to Settings → Plugins and click the "Install" button for your plugin.

Check for any plugin updates periodically to ensure compatibility with Craft CMS and Google Cloud. New versions may contain bug fixes, additional features, or other improvements

Plugin Configuration and Settings

After installation, the next step is configuring the plugin's settings and options:

First, enter your Google Cloud credentials from the downloaded service account key as outlined in the previous section. This authorizes API access.

Determine which Google Cloud services you want to integrate. Enable each one in the plugin settings and configure as needed. For example, map Craft asset volumes to Cloud Storage buckets.

Adjust any other settings like file deletion behaviours, image rendering, caching options, and more based on your specific needs. Refer to the plugin documentation for guidance.

For paid plugins like Craft Cloud Services, your license key is also required and unlocks access to premium features.

Take some time to review all settings thoroughly before launching into production. Optionally maintain separate configurations for local, staging, and live environments.

Connecting Google Cloud Services

With credentials entered and options configured, it's time to connect the plugin to Google Cloud:

First, ensure the required Google Cloud APIs have been enabled on your project as outlined earlier.

Authorize the plugin to access your credentials in the settings panel. Grant any requested permissions.

Use the plugin console or utilities to test the connection. For example, create a test Cloud Storage bucket or BigQuery dataset.

Address any connection issues, API errors, or permissions problems before progressing. The plugin logs can help troubleshoot.

Once connected, you can start using Google Cloud services in your Craft CMS project! For example, sync your asset volumes, integrate BigQuery for reporting, or leverage Cloud Pub/Sub for queuing.

Be sure to consult the plugin documentation for tips, examples, and best practices as you leverage the integration. Reach out to the plugin developer with any questions or issues.

Mapping Cloud Storage Buckets

Creating Cloud Storage Buckets

Once your plugin is installed, the first step is creating a Cloud Storage bucket for assets:

In your Google Cloud console, navigate to the Storage browser. Click "Create Bucket" to get started.

Provide a globally unique name for your bucket and set the location type (region or multi-region). Enable versioning for changes in history.

Configure public access settings according to your needs. Limit public access to private assets or allow it for public resources.

Set access controls at the bucket or object level. Use IAM roles like Storage Admin or object ACLs.

Enable encryption, retention policies, or other bucket settings as desired.

Repeat this process to create any additional buckets as needed for different sites, environments, or asset types.

Consult Google's storage documentation for advanced bucket configuration tips.

Connecting Buckets to Asset Volumes

After creating your Storage bucket(s), integrate them with Craft asset volumes:

In your plugin settings, enable the Cloud Storage integration and authorize API access.

Under volume settings, choose your bucket from the dropdown for the desired asset volume. Repeat for other volumes.

Configure sync behaviours like delete propagation and update actively vs on save. Set upload limits.

Enable the "Automatically rescale images" option to optimize uploads. Adjust other settings as needed.

Save your settings. Asset operations like uploads and edits should now sync from that volume to the mapped Cloud Storage bucket.

Grant the plugin role-based permissions to properly manage assets in the bucket. Refer to the docs for details.

Managing Uploads and Sync

With your bucket(s) integrated, uploads and asset changes in Craft will automatically synchronize:

New asset uploads to the volume will be transferred to the mapped bucket behind the scenes.

Deletions, edits, and transformations like crops are also synced based on your propagation settings.

Control synchronization actively with the "Sync now" button or set a cron job for scheduled consistency.

Use Cloud Storage directly for advanced operations like setting object lifecycles, enabling faster tiers, or adjusting permissions.

Monitor usage spikes, set upload limits, and watch out for reaching bucket quotas if needed.

The plugin logs can provide sync statuses and troubleshooting. Enable error notifications as needed.

Integrating Cloud Storage buckets delivers robust asset management, infinite scalability, and advanced workflows!

Integrating Other Google Cloud Services

Google Cloud SQL for Databases

In addition to Cloud Storage, Google Cloud SQL is another essential integration for Craft CMS.

Cloud SQL provides fully-managed MySQL and PostgreSQL relational databases. Through the plugin, Cloud SQL instances can replace locally hosted Craft CMS databases for greater reliability.

First, create a Cloud SQL instance in Google Cloud and configure its settings like machine type, storage capacity, and automated backups. Add users and networks.

In Craft CMS, update your environment variables or config files to use the Cloud SQL connection string instead of a local database. The plugin can help manage environment configurations.

For security, avoid using the root account. Create a separate restricted Cloud SQL user for the Craft app with only the required permissions.

The plugin will handle database operations like migrations, queries, and schema changes through the managed Cloud SQL instance going forward.

With Cloud SQL, you benefit from automated database patching, vertical scaling, high availability configurations, and effortless encryption. Your Craft data is instantly accessible from anywhere too.

BigQuery for Data Analytics

Google BigQuery is a data warehouse for running lightning-fast SQL queries against massive datasets.

By integrating BigQuery into Craft CMS, you can better analyze content performance, monitor site statistics, identify trends, and optimize your strategy.

The plugin provides a graphical interface to construct BigQuery tables based on Craft content. Pull in entries, categories, assets, users, and more.

Build custom dashboards that combine Craft CMS data with other sources like Google Analytics. Schedule queries and reports using BigQuery ML for automated insights.

By leveraging BigQuery's separation of storage and compute, you can query terabytes of Craft and behavioural data nearly instantly. No more struggling with slow analytics on creaking databases.

BigQuery integrations enable data-driven management of your Craft CMS sites. Analyze performance beyond the built-in tools using Google's enterprise-grade analytics engine.

Cloud CDN for Content Delivery

To accelerate content delivery across regions, Google Cloud CDN offers a globally distributed edge caching network.

The plugin allows automatically caching entire Craft CMS sites or specific pages and assets on Cloud CDN. Site visitors are served content from the nearest edge location.

First, enable Cloud CDN in Google Cloud and create a cache instance. Connect your Craft CMS domain and configure behaviour like caching rules.

Set TTLs or leverage cache invalidation to ensure content updates are reflected quickly. Enable compression and TLS encryption.

With Cloud CDN activated, static assets and pages are cached close to end users for sub-second response times. Errors and traffic spikes are smoothly handled.

Lightning performance plus Google's reliability and scale. For public-facing Craft CMS sites, Cloud CDN integration is transformative.

Shape April 2022 HR 202
Andy Golpys
- Author

Andy has scaled multiple businesses and is a big believer in Craft CMS as a tool that benefits both Designer, Developer and Client. 

Share
Feedback
Show us some love
Email Us
We usually reply within 72 hours
Agency Directory
Submit your agency
Affiliate Partners
Let's chat