Generate a static site from Wordpress (via WP2Static) using AWS CDK
Project description
CDK Static Wordpress
The goal of this project is to make it easy to deploy a static website, generated by Wordpress as simple and cost-effective as possible.
It's largely inspired by TechToSpeech/terraform-aws-serverless-static-wordpress, but uses AWS CDK instead of Terraform.
It creates the infrastructure to launch a temporary, transient Wordpress container. You then log in and customize it like any Wordpress site, and finally publish it as a static site fronted by a global CloudFront CDN and S3 Origin. When you’re done you shut down the Wordpress container and it costs you almost nothing.
WP2Static is used to generate the static site from the Wordpress container.
Quick Start
-
Install the construct:
yarn add @blimmer/cdk-static-wordpress # or npm i --save @blimmer/cdk-static-wordpress
-
Instantiate a
StaticWordpress
instance aStack
:import { StaticWordpress } from "@blimmer/cdk-static-wordpress"; import { Stack, StackProps } from "aws-cdk-lib"; import { HostedZone } from "aws-cdk-lib/aws-route53"; import { Construct } from "constructs"; export class StaticWordpressStack extends Stack { constructor(scope: Construct, id: string, props?: StackProps) { super(scope, id, props); // You can create or import a hosted zone // See https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_route53.HostedZone.html const exampleHostedZone = new HostedZone(this, "ExampleHostedZone", { zoneName: "example.com", }); new StaticWordpress(this, "StaticWordpress", { fullyQualifiedSiteName: "blog.example.com", hostedZone: exampleHostedZone, wordpressAdminProps: { email: "me@example.com", }, }); } }
-
Deploy with the
cdk deploy
command -
Once the deployment completes, visit the Wordpress console at
admin-<fullyQualifiedSiteName>
. E.g., if your static site isblog.example.com
, visitadmin-blog.example.com/wp-admin
. The default password for the wordpress user ischangeme
(please change it :smile:). -
Customize Wordpress as you see fit, create posts, etc.
-
When you're ready to deploy your static site, trigger WP2Static.
-
Visit your static site (e.g.,
blog.example.com
) once WP2Static completes. -
(optional) Shut down the Wordpress container to save money.
new StaticWordpress(this, "StaticWordpress", { fullyQualifiedSiteName: "blog.example.com", hostedZone: exampleHostedZone, wordpressAdminProps: { email: "me@example.com", run: false, // <-- Shut down the container after deployment }, });
Architecture
TODO
Escape Hatches
This construct provides escape hatches, to allow you to customize the underlying infrastructure if you need to. This is a big benefit of using CDK over Terraform (where every customizable property must be manually exposed as a variable).
Look for *Overrides
in the API docs for customization options. But, be warned, we allow overriding almost
everything, so you can easily produce invalid infrastructure if you don't know what you're doing.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for cdk-static-wordpress-0.1.17.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | a4ba035f5e22fb0a599b9c79203aefee178ee1932ef354e48ec4eda9903698bf |
|
MD5 | 7a892964a9d4f370b85ba10cf23d6de3 |
|
BLAKE2b-256 | f6a2dfba4dfc357155f9e15775fca1aafd0e0f1fe56bc9e6be0e5aa91b60aef9 |
Hashes for cdk_static_wordpress-0.1.17-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 102c22416e9407a9f0d5d0a5dda1e94df3192e55b16f1ae5bffc499b24806340 |
|
MD5 | 2b3af3780f28455e8e78b166fc263f7c |
|
BLAKE2b-256 | f82b2ef481bc631f7756c42a532fb4e2591b031ad99a7cf62257d26f3144796a |