update readme

This commit is contained in:
Benjamin Sadik 2022-08-25 17:16:43 +02:00
parent fd52c4c2c4
commit 216afda2ce
3 changed files with 98 additions and 1 deletions

View File

@ -1 +1,98 @@
# TODO
# Wordpress deployment on Cloud Run
43% of the Web is built on Wordpress. Because of its simplicity and versatility, Wordpress can be used for internal websites as well as customer facing e-commerce platforms in small to large businesses while still offering security.
This repository contains the necessary Terraform files to deploy a functioning new Wordpress website exposed to the public internet with minimal technical overhead.
This architecture can be used for the following use cases and more:
* Blog
* Intranet / internal Wiki
* Ecommerce platform
## Architecture
![Wordpress on Cloud Run](images/architecture.png "Wordpress on Cloud Run")
The main components that are deployed in this architecture are the following (you can learn about them by following the hyperlinks):
* [Cloud Run](https://cloud.google.com/run): serverless PaaS offering to host containers for web oriented applications while offering security, scalability and easy versioning.
* [Cloud SQL](https://cloud.google.com/sql): Managed solution for SQL DB
## Setup
### Prerequisites
#### Setting up the project for the deployment
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`.
### Deployment
#### Step 0: Cloning the repository
Click on the image below, sign in if required and when the prompt appears, click on “confirm”.
[<p align="center"> <img alt="Open Cloudshell" width = "300px" src="images/button.png" /> </p>]()
LINK NEEDED
Before we deploy the architecture, you will at least need the following information (for more precise configuration see the Variables section):
* The project Id.
* A Google Cloud Registry path to a Wordpress container image.
#### Step 1: Build Wordpress image
In order to deploy the Wordpress service to Cloud Run, you need to build and store the image in Google Cloud Registry (GCR).
Make sure that the GCR API is enabled and run the following commands in your Cloud Shell environment with your `project_id` in place of the `MY_PROJECT` placeholder:
``` {shell}
docker pull wordpress
docker tag wordpress gcr.io/MY_PROJECT/busybox
docker push gcr.io/MY_PROJECT/wordpress
```
#### Step 2: Deploy resources
Once you have the required information, head back to the Cloud Shell editor. Make sure youre in the following directory: `cloudshell_open/cloud-foundation-fabric/examples/third-party-solutions/wordpress/cloudrun/`.
Configure the Terraform variables in your terraform.tfvars file. See [terraform.tfvars.sample](terraform.tfvars.sample) as starting point.
Initialize your Terraform environment:
``` {shell}
alias tf=terraform
tf init
tf apply -var-file="terraform.tfvars.sample"
```
The resource creation will take a few minutes, at the end this is the output you should expect for successful completion along with a list of the created resources.
#### Clean up your environment
The easiest way to remove all the deployed resources is to run the following command in Cloud Shell:
``` {shell}
tf destroy -var-file="terraform.tfvars.sample"
```
The above command will delete the associated resources so there will be no billable charges made afterwards.
<!-- BEGIN TFDOC -->
## Variables
| name | description | type | required | default |
|---|---|:---:|:---:|:---:|
| [project_id](variables.tf#L32) | Project id, references existing project if `project_create` is null. | <code>string &#35; TODO: check locals</code> | ✓ | |
| [wordpress_image](variables.tf#L49) | Image to run with Cloud Run, starts with \"gcr.io\" | <code>string</code> | ✓ | |
| [cloud_run_invoker](variables.tf#L55) | IAM member authorized to access the end-point (for example, 'user:YOUR_IAM_USER' for only you or 'allUsers' for everyone) | <code>string</code> | | <code>&#34;allUsers&#34;</code> |
| [prefix](variables.tf#L17) | Unique prefix used for resource names. Not used for project if 'project_create' is null. | <code>string</code> | | <code>&#34;&#34;</code> |
| [principals](variables.tf#L43) | List of emails of people/service accounts to give rights to, eg 'user@domain.com'. | <code>list&#40;string&#41;</code> | | <code>&#91;&#93;</code> |
| [project_create](variables.tf#L23) | Provide values if project creation is needed, uses existing project if null. Parent is in 'folders/nnn' or 'organizations/nnn' format. | <code title="object&#40;&#123;&#10; billing_account_id &#61; string&#10; parent &#61; string&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | | <code>null</code> |
| [region](variables.tf#L37) | Region for the created resources | <code>string</code> | | <code>&#34;europe-west4&#34;</code> |
<!-- END TFDOC -->

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB