From 4750707460a32e442bd6eae663359a91eee19d7b Mon Sep 17 00:00:00 2001
From: Pete Wilcock <pete.wilcock@gmail.com>
Date: Sat, 19 Jun 2021 18:01:17 +0100
Subject: [PATCH 1/6] Refactoring md5 calculation
---
modules/codebuild/main.tf | 2 +-
modules/codebuild/outputs.tf | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/modules/codebuild/main.tf b/modules/codebuild/main.tf
index c70677a..70fbe2e 100644
--- a/modules/codebuild/main.tf
+++ b/modules/codebuild/main.tf
@@ -59,7 +59,7 @@ resource "aws_s3_bucket_object" "wordpress_dockerbuild" {
bucket = aws_s3_bucket.code_source.id
key = "wordpress_docker.zip"
source = "${path.module}/codebuild_files/wordpress_docker.zip"
- etag = filemd5("${path.module}/codebuild_files/wordpress_docker.zip")
+ etag = data.archive_file.code_build_package.output_md5
}
resource "aws_security_group" "codebuild_security_group" {
diff --git a/modules/codebuild/outputs.tf b/modules/codebuild/outputs.tf
index ba3cd11..b5ffcc1 100644
--- a/modules/codebuild/outputs.tf
+++ b/modules/codebuild/outputs.tf
@@ -4,6 +4,6 @@ output "codebuild_project_name" {
}
output "codebuild_package_etag" {
- value = filemd5("${path.module}/codebuild_files/wordpress_docker.zip")
+ value = data.archive_file.code_build_package.output_md5
description = "The etag of the codebuild package file."
}
From cf3764561449be98787abcedeaa2c434e933592c Mon Sep 17 00:00:00 2001
From: Pete Wilcock <pete.wilcock@gmail.com>
Date: Sat, 19 Jun 2021 18:02:33 +0100
Subject: [PATCH 2/6] Update changelog
---
CHANGELOG.md | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index bd50c04..df4eb97 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,9 @@
# Changelog
+## 0.1.1 - 19th June 2021
+
+Bugfix: Refactor md5 calculation on archive_file in codebuild child module.
+
## 0.1.0 - 19th June 2021
Initial release of Serverless Static Wordpress Terraform module.
From 4dba3354cc005d18e7fd9d06216d33784a81e4f9 Mon Sep 17 00:00:00 2001
From: Pete Wilcock <pete.wilcock@gmail.com>
Date: Sat, 19 Jun 2021 18:13:52 +0100
Subject: [PATCH 3/6] Update docs
---
.header.md | 11 ++---------
README.md | 11 ++---------
docs/examples/main.tf | 11 ++---------
3 files changed, 6 insertions(+), 27 deletions(-)
diff --git a/.header.md b/.header.md
index 74ee2da..0bd5d5e 100644
--- a/.header.md
+++ b/.header.md
@@ -129,10 +129,7 @@ resource "null_resource" "trigger_build" {
codebuild_etag = module.peterdotcloud_website.codebuild_package_etag
}
provisioner "local-exec" {
- command = <<-EOT
- aws codebuild start-build --project-name "${module.peterdotcloud_website.codebuild_project_name}"
- --profile "${local.profile}" --region "${local.aws_region}"
- EOT
+ command = "aws codebuild start-build --project-name ${module.peterdotcloud_website.codebuild_project_name} --profile ${local.profile} --region ${local.aws_region}"
}
depends_on = [
module.peterdotcloud_website, module.docker_pullpush
@@ -156,11 +153,7 @@ resource "null_resource" "update_nameservers" {
nameservers = aws_route53_zone.apex.id
}
provisioner "local-exec" {
- command = <<-EOT
- aws route53domains update-domain-nameservers --region us-east-1 --domain-name "${local.site_domain}"
- --nameservers Name="${aws_route53_zone.apex.name_servers.0}" Name="${aws_route53_zone.apex.name_servers.1}"
- Name="${aws_route53_zone.apex.name_servers.2}" Name="${aws_route53_zone.apex.name_servers.3}" --profile peterdotcloud
- EOT
+ command = "aws route53domains update-domain-nameservers --region us-east-1 --domain-name ${local.site_domain} --nameservers Name=${aws_route53_zone.apex.name_servers.0}Name=${aws_route53_zone.apex.name_servers.1} Name=${aws_route53_zone.apex.name_servers.2} Name=${aws_route53_zone.apex.name_servers.3} --profile peterdotcloud"
}
depends_on = [aws_route53_zone.apex]
}
diff --git a/README.md b/README.md
index decc2fc..4803ab3 100644
--- a/README.md
+++ b/README.md
@@ -130,10 +130,7 @@ resource "null_resource" "trigger_build" {
codebuild_etag = module.peterdotcloud_website.codebuild_package_etag
}
provisioner "local-exec" {
- command = <<-EOT
- aws codebuild start-build --project-name "${module.peterdotcloud_website.codebuild_project_name}"
- --profile "${local.profile}" --region "${local.aws_region}"
- EOT
+ command = "aws codebuild start-build --project-name ${module.peterdotcloud_website.codebuild_project_name} --profile ${local.profile} --region ${local.aws_region}"
}
depends_on = [
module.peterdotcloud_website, module.docker_pullpush
@@ -157,11 +154,7 @@ resource "null_resource" "update_nameservers" {
nameservers = aws_route53_zone.apex.id
}
provisioner "local-exec" {
- command = <<-EOT
- aws route53domains update-domain-nameservers --region us-east-1 --domain-name "${local.site_domain}"
- --nameservers Name="${aws_route53_zone.apex.name_servers.0}" Name="${aws_route53_zone.apex.name_servers.1}"
- Name="${aws_route53_zone.apex.name_servers.2}" Name="${aws_route53_zone.apex.name_servers.3}" --profile peterdotcloud
- EOT
+ command = "aws route53domains update-domain-nameservers --region us-east-1 --domain-name ${local.site_domain} --nameservers Name=${aws_route53_zone.apex.name_servers.0}Name=${aws_route53_zone.apex.name_servers.1} Name=${aws_route53_zone.apex.name_servers.2} Name=${aws_route53_zone.apex.name_servers.3} --profile peterdotcloud"
}
depends_on = [aws_route53_zone.apex]
}
diff --git a/docs/examples/main.tf b/docs/examples/main.tf
index 61f9038..a0c5f9a 100644
--- a/docs/examples/main.tf
+++ b/docs/examples/main.tf
@@ -61,10 +61,7 @@ resource "null_resource" "trigger_build" {
codebuild_etag = module.peterdotcloud_website.codebuild_package_etag
}
provisioner "local-exec" {
- command = <<-EOT
- aws codebuild start-build --project-name "${module.peterdotcloud_website.codebuild_project_name}"
- --profile "${local.profile}" --region "${local.aws_region}"
- EOT
+ command = "aws codebuild start-build --project-name ${module.peterdotcloud_website.codebuild_project_name} --profile ${local.profile} --region ${local.aws_region}"
}
depends_on = [
module.peterdotcloud_website, module.docker_pullpush
@@ -83,11 +80,7 @@ resource "null_resource" "update_nameservers" {
nameservers = aws_route53_zone.apex.id
}
provisioner "local-exec" {
- command = <<-EOT
- aws route53domains update-domain-nameservers --region us-east-1 --domain-name "${local.site_domain}"
- --nameservers Name="${aws_route53_zone.apex.name_servers.0}" Name="${aws_route53_zone.apex.name_servers.1}"
- Name="${aws_route53_zone.apex.name_servers.2}" Name="${aws_route53_zone.apex.name_servers.3}" --profile peterdotcloud
- EOT
+ command = "aws route53domains update-domain-nameservers --region us-east-1 --domain-name ${local.site_domain} --nameservers Name=${aws_route53_zone.apex.name_servers.0}Name=${aws_route53_zone.apex.name_servers.1} Name=${aws_route53_zone.apex.name_servers.2} Name=${aws_route53_zone.apex.name_servers.3} --profile peterdotcloud"
}
depends_on = [aws_route53_zone.apex]
}
From 46e31bde90553c3b87254234fabb194afc14f7fa Mon Sep 17 00:00:00 2001
From: Pete Wilcock <pete.wilcock@gmail.com>
Date: Sat, 19 Jun 2021 20:12:26 +0100
Subject: [PATCH 4/6] Updating documentation and minor bugfixes
---
.header.md | 45 ++++++++++++++++++++++++++++++++
CHANGELOG.md | 1 +
README.md | 47 +++++++++++++++++++++++++++++++++-
modules/codebuild/README.md | 2 +-
modules/codebuild/variables.tf | 2 +-
variables.tf | 2 +-
6 files changed, 95 insertions(+), 4 deletions(-)
diff --git a/.header.md b/.header.md
index 0bd5d5e..63a9526 100644
--- a/.header.md
+++ b/.header.md
@@ -159,3 +159,48 @@ resource "null_resource" "update_nameservers" {
}
```
See [examples](docs/examples) for full set-up example.
+
+## Launching container, customise Wordpress and publish static site
+
+Check that the CodeBuild job for the container has built successfully.
+
+Toggle the `launch` value of the module to 1, and re-run Terraform plan/apply, which will launch the instance of the
+Wordpress management container.
+
+First-time launch of container will take 5-6 minutes as the installation of Wordpress completes. You can
+check status if you wish in CloudWatch log groups for ECS. It will come up within a few seconds on subsequent launches.
+
+The Wordpress management container will become available at http://wordpress.yourdomain.com (note HTTP, not HTTPS) by
+default, unless you specified your own `wordpress_subdomain` prefix.
+
+Default admin is: supervisor
+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.
+
+You may now edit Wordpress as you would normally, customise 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
+the size of your site. When complete the site will be published in S3, and available via the public URL configured
+in your module definition.
+
+Gentle reminder that no backup options are currently bundled with this module - the most effective means would be to
+generate and retain a backup from within Wordpress for maximum flexibility. We recommend the UpdraftPlus plugin.
+
+## Troubleshooting
+
+If you experience issues with the publish element of WP2Static, you can retry. It can be more reliable to proceed to
+'Caches' section and select to delete all caches. Currently you need to additionally delete the S3 deploy cache manually.
+
+You should also try increasing the CPU/Memory allocated to the container. Undersizing the container can cause timeout
+issues that are currently not well handled in the plugin.
+
+If the job fails immediately and your site has previously generated a sitemaps.xml file, ensure you restore the plugin
+that generates this file and the crawl job can fail fast if it cannot locate it. For all other features and issues
+relating to WP2Static, [raise an issue on their repo](https://github.com/leonstafford/wp2static/issues).
+For any issues relating to this module, [raise an issue against this repo.](https://github.com/TechToSpeech/terraform-aws-serverless-static-wordpress/issues)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index df4eb97..f474bd9 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -3,6 +3,7 @@
## 0.1.1 - 19th June 2021
Bugfix: Refactor md5 calculation on archive_file in codebuild child module.
+Bugfix: Re-typed AWS account number as string to avoid rounding on account numbers prepended with zeros.
## 0.1.0 - 19th June 2021
diff --git a/README.md b/README.md
index 4803ab3..334713f 100644
--- a/README.md
+++ b/README.md
@@ -161,11 +161,56 @@ resource "null_resource" "update_nameservers" {
```
See [examples](docs/examples) for full set-up example.
+## Launching container, customise Wordpress and publish static site
+
+Check that the CodeBuild job for the container has built successfully.
+
+Toggle the `launch` value of the module to 1, and re-run Terraform plan/apply, which will launch the instance of the
+Wordpress management container.
+
+First-time launch of container will take 5-6 minutes as the installation of Wordpress completes. You can
+check status if you wish in CloudWatch log groups for ECS. It will come up within a few seconds on subsequent launches.
+
+The Wordpress management container will become available at http://wordpress.yourdomain.com (note HTTP, not HTTPS) by
+default, unless you specified your own `wordpress_subdomain` prefix.
+
+Default admin is: supervisor
+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.
+
+You may now edit Wordpress as you would normally, customise 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
+the size of your site. When complete the site will be published in S3, and available via the public URL configured
+in your module definition.
+
+Gentle reminder that no backup options are currently bundled with this module - the most effective means would be to
+generate and retain a backup from within Wordpress for maximum flexibility. We recommend the UpdraftPlus plugin.
+
+## Troubleshooting
+
+If you experience issues with the publish element of WP2Static, you can retry. It can be more reliable to proceed to
+'Caches' section and select to delete all caches. Currently you need to additionally delete the S3 deploy cache manually.
+
+You should also try increasing the CPU/Memory allocated to the container. Undersizing the container can cause timeout
+issues that are currently not well handled in the plugin.
+
+If the job fails immediately and your site has previously generated a sitemaps.xml file, ensure you restore the plugin
+that generates this file and the crawl job can fail fast if it cannot locate it. For all other features and issues
+relating to WP2Static, [raise an issue on their repo](https://github.com/leonstafford/wp2static/issues).
+For any issues relating to this module, [raise an issue against this repo.](https://github.com/TechToSpeech/terraform-aws-serverless-static-wordpress/issues)
+
## Inputs
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
-| <a name="input_aws_account_id"></a> [aws\_account\_id](#input\_aws\_account\_id) | The AWS account ID into which resources will be launched. | `number` | n/a | yes |
+| <a name="input_aws_account_id"></a> [aws\_account\_id](#input\_aws\_account\_id) | The AWS account ID into which resources will be launched. | `string` | n/a | yes |
| <a name="input_cloudfront_aliases"></a> [cloudfront\_aliases](#input\_cloudfront\_aliases) | The domain and sub-domain aliases to use for the cloudfront distribution. | `list(any)` | `[]` | no |
| <a name="input_cloudfront_class"></a> [cloudfront\_class](#input\_cloudfront\_class) | The [price class](https://aws.amazon.com/cloudfront/pricing/) for the distribution. One of: PriceClass\_All, PriceClass\_200, PriceClass\_100 | `string` | `"PriceClass_All"` | no |
| <a name="input_ecs_cpu"></a> [ecs\_cpu](#input\_ecs\_cpu) | The CPU limit password to the Wordpress container definition. | `number` | `256` | no |
diff --git a/modules/codebuild/README.md b/modules/codebuild/README.md
index 2dfab0f..b0fe45b 100644
--- a/modules/codebuild/README.md
+++ b/modules/codebuild/README.md
@@ -7,7 +7,7 @@ This module sets up the build to take a vanilla Wordpress image and bake customi
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
-| <a name="input_aws_account_id"></a> [aws\_account\_id](#input\_aws\_account\_id) | The AWS account ID into which resources will be launched. | `number` | n/a | yes |
+| <a name="input_aws_account_id"></a> [aws\_account\_id](#input\_aws\_account\_id) | The AWS account ID into which resources will be launched. | `string` | n/a | yes |
| <a name="input_codebuild_bucket"></a> [codebuild\_bucket](#input\_codebuild\_bucket) | The name of the bucket used for codebuild of the image. | `string` | n/a | yes |
| <a name="input_container_memory"></a> [container\_memory](#input\_container\_memory) | The memory allocated to the container (in MB) | `number` | n/a | yes |
| <a name="input_main_vpc_id"></a> [main\_vpc\_id](#input\_main\_vpc\_id) | The VPC ID into which to launch resources. | `string` | n/a | yes |
diff --git a/modules/codebuild/variables.tf b/modules/codebuild/variables.tf
index f05c228..304200b 100644
--- a/modules/codebuild/variables.tf
+++ b/modules/codebuild/variables.tf
@@ -18,7 +18,7 @@ variable "wordpress_ecr_repository" {
}
variable "aws_account_id" {
- type = number
+ type = string
description = "The AWS account ID into which resources will be launched."
}
diff --git a/variables.tf b/variables.tf
index 3dc71d7..34a5a15 100644
--- a/variables.tf
+++ b/variables.tf
@@ -13,7 +13,7 @@ variable "subnet_ids" {
}
variable "aws_account_id" {
- type = number
+ type = string
description = "The AWS account ID into which resources will be launched."
}
From 1b98c034592eed25e13f1c2bb57916df26f960e0 Mon Sep 17 00:00:00 2001
From: Pete Wilcock <pete.wilcock@gmail.com>
Date: Sat, 19 Jun 2021 20:14:55 +0100
Subject: [PATCH 5/6] Spelling fix
---
.header.md | 4 ++--
README.md | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/.header.md b/.header.md
index 63a9526..43b8b2c 100644
--- a/.header.md
+++ b/.header.md
@@ -160,7 +160,7 @@ resource "null_resource" "update_nameservers" {
```
See [examples](docs/examples) for full set-up example.
-## Launching container, customise Wordpress and publish static site
+## Launching container, customize Wordpress and publish static site
Check that the CodeBuild job for the container has built successfully.
@@ -184,7 +184,7 @@ 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.
-You may now edit Wordpress as you would normally, customise your site as you like, and when ready proceed to the 'Run'
+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
the size of your site. When complete the site will be published in S3, and available via the public URL configured
in your module definition.
diff --git a/README.md b/README.md
index 334713f..8756087 100644
--- a/README.md
+++ b/README.md
@@ -161,7 +161,7 @@ resource "null_resource" "update_nameservers" {
```
See [examples](docs/examples) for full set-up example.
-## Launching container, customise Wordpress and publish static site
+## Launching container, customize Wordpress and publish static site
Check that the CodeBuild job for the container has built successfully.
@@ -185,7 +185,7 @@ 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.
-You may now edit Wordpress as you would normally, customise your site as you like, and when ready proceed to the 'Run'
+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
the size of your site. When complete the site will be published in S3, and available via the public URL configured
in your module definition.
From f0df0eb66d441a3edc3e623f776c6076acef5832 Mon Sep 17 00:00:00 2001
From: Pete Wilcock <pete.wilcock@gmail.com>
Date: Sat, 19 Jun 2021 23:08:04 +0100
Subject: [PATCH 6/6] Fixing WAF active bug
---
CHANGELOG.md | 1 +
main.tf | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index f474bd9..82695be 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,7 @@
Bugfix: Refactor md5 calculation on archive_file in codebuild child module.
Bugfix: Re-typed AWS account number as string to avoid rounding on account numbers prepended with zeros.
+Bugfix: Fix passed WAF variable values if set to inactive.
## 0.1.0 - 19th June 2021
diff --git a/main.tf b/main.tf
index 00eda28..7fd9575 100644
--- a/main.tf
+++ b/main.tf
@@ -29,7 +29,7 @@ module "cloudfront" {
depends_on = [aws_acm_certificate_validation.wordpress_site,
module.waf]
cloudfront_class = var.cloudfront_class
- waf_acl_arn = module.waf[0].waf_acl_arn
+ waf_acl_arn = var.waf_enabled ? module.waf[0].waf_acl_arn : null
}
module "waf" {