Skip to content

Commit

Permalink
feat: allow cloudfront invalidations
Browse files Browse the repository at this point in the history
  • Loading branch information
blimmer committed May 15, 2022
1 parent abc903d commit 05a25f0
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
14 changes: 10 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -194,10 +194,16 @@ Default password: techtospeech.com
Change these on first log in or specify your own in module instantiation.

You will find WP2Static with S3 Add-on installed. Go to the WP2Static Menu->Addons, and click the 'Disabled' button to
Enable the Add-on.

The configuration of the plugin has been set up such that no additional configuration is required unless you wish to
change any options.
Enable the Add-on. Enable enabling, click the Configure icon on this page. In the S3 table, change "Object ACL" from
"public-read" to "private". In the CloudFront table, copy the region from the S3 table and enter your CloudFront
Distribution ID. You can find the ID in the AWS console. Then click "Save S3 Options". See
[this GitHub issue](https://github.com/TechToSpeech/terraform-aws-serverless-static-wordpress/issues/15) to automate
these changes.

Finally, you'll need to configure permalinks to a format that is supported on static sites. Go to Settings -> Permalinks
in the sidebar. By default, `plain` is likely selected. You need to change this to any other format for static
publishing to work. Click "Save Changes" to confirm the change. You can confirm you have selected a valid choice by
viewing WP2Static Menu -> Diagnostics.

You may now edit Wordpress as you would normally, customize your site as you like, and when ready proceed to the 'Run'
section of the WP2Static plugin, and click the 'Generate Static Site' button. This will take some minutes depending on
Expand Down
6 changes: 6 additions & 0 deletions ecs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ data "aws_iam_policy_document" "wordpress_bucket_access" {
effect = "Allow"
resources = ["arn:aws:route53:::hostedzone/${var.hosted_zone_id}"]
}

statement {
actions = ["cloudfront:CreateInvalidation"]
effect = "Allow"
resources = [module.cloudfront.wordpress_cloudfront_distribution_arn]
}
}

resource "aws_iam_policy" "wordpress_bucket_access" {
Expand Down
5 changes: 5 additions & 0 deletions modules/cloudfront/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ output "wordpress_bucket_arn" {
value = aws_s3_bucket.wordpress_bucket.arn
}


output "wordpress_cloudfront_distribution_arn" {
value = aws_cloudfront_distribution.wordpress_distribution.arn
}

output "wordpress_cloudfront_distribution_domain_name" {
value = aws_cloudfront_distribution.wordpress_distribution.domain_name
}
Expand Down

0 comments on commit 05a25f0

Please sign in to comment.