Skip to content

Commit 05a25f0

Browse files
committed
feat: allow cloudfront invalidations
Fixes TechToSpeech#70
1 parent abc903d commit 05a25f0

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

README.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -194,10 +194,16 @@ Default password: techtospeech.com
194194
Change these on first log in or specify your own in module instantiation.
195195

196196
You will find WP2Static with S3 Add-on installed. Go to the WP2Static Menu->Addons, and click the 'Disabled' button to
197-
Enable the Add-on.
198-
199-
The configuration of the plugin has been set up such that no additional configuration is required unless you wish to
200-
change any options.
197+
Enable the Add-on. Enable enabling, click the Configure icon on this page. In the S3 table, change "Object ACL" from
198+
"public-read" to "private". In the CloudFront table, copy the region from the S3 table and enter your CloudFront
199+
Distribution ID. You can find the ID in the AWS console. Then click "Save S3 Options". See
200+
[this GitHub issue](https://github.com/TechToSpeech/terraform-aws-serverless-static-wordpress/issues/15) to automate
201+
these changes.
202+
203+
Finally, you'll need to configure permalinks to a format that is supported on static sites. Go to Settings -> Permalinks
204+
in the sidebar. By default, `plain` is likely selected. You need to change this to any other format for static
205+
publishing to work. Click "Save Changes" to confirm the change. You can confirm you have selected a valid choice by
206+
viewing WP2Static Menu -> Diagnostics.
201207

202208
You may now edit Wordpress as you would normally, customize your site as you like, and when ready proceed to the 'Run'
203209
section of the WP2Static plugin, and click the 'Generate Static Site' button. This will take some minutes depending on

ecs.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ data "aws_iam_policy_document" "wordpress_bucket_access" {
4040
effect = "Allow"
4141
resources = ["arn:aws:route53:::hostedzone/${var.hosted_zone_id}"]
4242
}
43+
44+
statement {
45+
actions = ["cloudfront:CreateInvalidation"]
46+
effect = "Allow"
47+
resources = [module.cloudfront.wordpress_cloudfront_distribution_arn]
48+
}
4349
}
4450

4551
resource "aws_iam_policy" "wordpress_bucket_access" {

modules/cloudfront/outputs.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ output "wordpress_bucket_arn" {
66
value = aws_s3_bucket.wordpress_bucket.arn
77
}
88

9+
10+
output "wordpress_cloudfront_distribution_arn" {
11+
value = aws_cloudfront_distribution.wordpress_distribution.arn
12+
}
13+
914
output "wordpress_cloudfront_distribution_domain_name" {
1015
value = aws_cloudfront_distribution.wordpress_distribution.domain_name
1116
}

0 commit comments

Comments
 (0)