This architecture uses click-to-deploy so you can spin up infrastructure in minutes using terraform!
43% of the Web is built on Wordpress. Because of its simplicity and versatility, Wordpress can be used for internal websites and customer facing e-commerce platforms in small to large businesses, while still offering security. Cloud Run automatically scales your WordPress application to handle any amount of traffic, without requiring manual intervention. This means that your website can handle large traffic spikes, without worrying about capacity.
Cloud Run allows you to deploy your WordPress application quickly and easily, with a few clicks or commands. You can deploy your application from a container image stored in a container registry or directly from a Git repository. This click-to-deploy architecture leverages the serverless and scalability benefits of using Cloud Run to host a Wordpress Application connected to a PostgreSQL instance.
This repo is based on the Cloud Foundation Fabric blueprint available here.
These are some of the use cases you can build on top of this infrastructure:
- Business websites
- E-commerce websites
- Portfolios
- Non-profit websites
- Educational Websites
The main components that are deployed in this architecture are the following (you can learn about them by following the hyperlinks):
- Cloud Run: serverless PaaS offering to host containers for web-oriented applications, while offering security, scalability and easy versioning
- Cloud SQL: Managed solution for SQL databases
- VPC Serverless Connector: Solution to access the CloudSQL VPC from Cloud Run, using only internal IP addresses
Pricing Estimates - We have created a sample estimate based on some usage we see from new startups looking to scale. This estimate would give you an idea of how much this deployment would essentially cost per month at this scale and you extend it to the scale you further prefer. Here's the link.
This example will deploy all its resources into the project defined by the project_id
variable. Please note that we assume this project already exists. However, if you provide the appropriate values to the project_create
variable, the project will be created as part of the deployment.
If project_create
is left to null, the identity performing the deployment needs the owner
role on the project defined by the project_id
variable. Otherwise, the identity performing the deployment needs resourcemanager.projectCreator
on the resource hierarchy node specified by project_create.parent
and billing.user
on the billing account specified by project_create.billing_account_id
.
Before we deploy the architecture, you will need the following information:
- The service project ID.
- A unique prefix that you want all the deployed resources to have (for example: awesomestartup). This must be a string with no spaces or tabs.
- A Wordpress image if you want to use your own, otherwise you can use the provided standard image.
- A list of Groups or Users with Service Account Token creator role on Service Accounts in IAM format, eg 'group:group@domain.com'.
Notes:
- If you want to change your admin password later on, please note that you can only do so via the Wordpress user interface.
- If you have the domain restriction org. policy on your organization, you have to edit the
cloud_run_invoker
variable and give it a value that will be accepted in accordance to your policy.
Click on the button below, sign in if required and when the prompt appears, click on βconfirmβ. It will walk you through setting up your architecture.
This is the startup screen that appears after clicking the button and confirming:
During the process, you will be asked for some user input. All necessary variables are explained at the bottom of this ReadMe file. In case of failure, you can simply click the button again.
π Congratulations! π
You have successfully deployed the foundation for running Wordpress using CloudRun on Google Cloud.
Note: You might get the following error (or a similar one):
β Error: resource is in failed state "Ready:False", message: Revision '...' is not ready and cannot serve traffic.β
In case this happens, manually run
deploystack install
to run the installation again.
Upon completion, you will see the output with the values for the Cloud Run service and the user and password to access the /admin
part of the website. You can also view it later with:
terraform output
# or for the concrete variable:
terraform output cloud_run_service
When clicking on the Wordpress link, it will immediately prompt you to register as an administrator. The password will be pre-filled and can be changed after registration.
The easiest way to remove all deployed resources is to run the following command in Cloud Shell:
deploystack uninstall
The above command will delete the associated resources so there will be no billable charges made afterwards.
A special thank you goes out to Natalia Strelkova (skalolazka) and Grigory Movsesyan, the original developers of this example architecture.
name | description | type | default |
---|---|---|---|
project_id | Project id, references existing project if project_create is null. |
string |
|
wordpress_image | Image to run with Cloud Run, starts with "gcr.io" | string |
mirror.gcr.io/library/wordpress |
cloud_run_invoker | IAM member authorized to access the end-point (for example, 'user:YOUR_IAM_USER' for only you or 'allUsers' for everyone) | string |
"allUsers" |
cloudsql_password | CloudSQL password (will be randomly generated by default) | string |
null |
connector | Existing VPC serverless connector to use if not creating a new one | string |
null |
create_connector | Should a VPC serverless connector be created or not | bool |
true |
ip_ranges | CIDR blocks: VPC serverless connector, Private Service Access(PSA) for CloudSQL, CloudSQL VPC | object({β¦}) |
{β¦} |
prefix | Unique prefix used for resource names. Not used for project if 'project_create' is null. | string |
"" |
principals | List of users to give rights to (CloudSQL admin, client and instanceUser, Logging admin, Service Account User and TokenCreator), eg 'user@domain.com'. | list(string) |
[] |
project_create | Provide values if project creation is needed, uses existing project if null. Parent is in 'folders/nnn' or 'organizations/nnn' format. | object({β¦}) |
null |
region | Region for the created resources | string |
|
wordpress_password | Password for the Wordpress user (will be randomly generated by default) | string |
null |
wordpress_port | Port for the Wordpress image | number |
8080 |
name | description | sensitive |
---|---|---|
cloud_run_service | CloudRun service URL | β |
cloudsql_password | CloudSQL password | β |
wp_password | Wordpress user password | β |
wp_user | Wordpress username |