Skip to content

Commit

Permalink
added template for Wordpress with Aurora in addition to the old templ…
Browse files Browse the repository at this point in the history
…ate using MySQL
  • Loading branch information
andreaswittig committed May 29, 2017
1 parent 02ccbd9 commit 503294a
Show file tree
Hide file tree
Showing 4 changed files with 930 additions and 5 deletions.
22 changes: 20 additions & 2 deletions docs/wordpress.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ This template combines the following services:
* ELB: load balancer forwarding requests to EC2 instances and terminating SSL
* EC2: virtual machines running the web servers
* EFS: storage for WordPress files (WordPress core, plugins, themes, user uploads, ...)
* RDS: MySQL database
* RDS: MySQL or Aurora database

![Architecture](./img/wordpress-ha.png)

## Installation Guide
## Installation Guide (MySQL)

*Important: A custom domain name (e.g. `www.yourdomain.com`) is needed before installing Wordpress based on this template.*

Expand All @@ -35,6 +35,24 @@ This template combines the following services:
1. Copy the value of `CloudFrontDomainName` from the **Outputs** tab of your stack.
1. Create or update a CNAME/Alias record for your custom domain name pointing to the `CloudFrontDomainName` from the previous step.

## Installation Guide (Aurora)

*Important: A custom domain name (e.g. `www.yourdomain.com`) is needed before installing Wordpress based on this template.*

1. This templates depends on our [`vpc-*azs.yaml`](../vpc/) template. [![Launch Stack](./img/launch-stack.png)](https://console.aws.amazon.com/cloudformation/home#/stacks/new?stackName=vpc-2azs&templateURL=https://s3-eu-west-1.amazonaws.com/widdix-aws-cf-templates-releases-eu-west-1/__VERSION__/vpc/vpc-2azs.yaml)
1. Create an ACM certificate for your custom domain name within the region you want to launch your stack in. Copy the ARN of the certificate. This is for the ELB.
1. Create another ACM certificate for your custom domain name in region `us-east-1`. Copy the ARN of the certificate. This is for CloudFront (note: [CloudFront only supports ACM certificates in us-east-1](https://docs.aws.amazon.com/acm/latest/userguide/acm-services.html))
1. [![Launch Stack](./img/launch-stack.png)](https://console.aws.amazon.com/cloudformation/home#/stacks/new?stackName=wordpress-ha&templateURL=https://s3-eu-west-1.amazonaws.com/widdix-aws-cf-templates-releases-eu-west-1/__VERSION__/wordpress/wordpress-ha-aurora.yaml)
1. Click **Next** to proceed with the next step of the wizard.
1. Specify a name and all parameters for the stack.
1. Click **Next** to proceed with the next step of the wizard.
1. Click **Next** to skip the **Options** step of the wizard.
1. Check the **I acknowledge that this template might cause AWS CloudFormation to create IAM resources.** checkbox.
1. Click **Create** to start the creation of the stack.
1. Wait until the stack reaches the state **CREATE_COMPLETE**
1. Copy the value of `CloudFrontDomainName` from the **Outputs** tab of your stack.
1. Create or update a CNAME/Alias record for your custom domain name pointing to the `CloudFrontDomainName` from the previous step.

## Dependencies
* `vpc/vpc-*azs.yaml` (**required**)
* `vpc/vpc-ssh-bastion.yaml` (recommended)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
public class TestWordpressHA extends ACloudFormationTest {

@Test
public void test() {
public void testMySQL() {
final String vpcStackName = "vpc-2azs-" + this.random8String();
final String stackName = "wordpress-ha-" + this.random8String();
final String classB = "10";
Expand Down Expand Up @@ -69,4 +69,61 @@ public void test() {
}
}

@Test
public void testAurora() {
final String vpcStackName = "vpc-2azs-" + this.random8String();
final String stackName = "wordpress-ha-aurora" + this.random8String();
final String classB = "10";
final String keyName = "key-" + this.random8String();
final String domainName = this.generateDomain(stackName);
final String blogTitle = "Stay-AWSome";
final String blogPassword = this.random8String();
try {
this.createKey(keyName);
try {
this.createStack(vpcStackName,
"vpc/vpc-2azs.yaml",
new Parameter().withParameterKey("ClassB").withParameterValue(classB)
);
try {
this.createStack(stackName,
"wordpress/wordpress-ha-aurora.yaml",
new Parameter().withParameterKey("ParentVPCStack").withParameterValue(vpcStackName),
new Parameter().withParameterKey("WebServerKeyName").withParameterValue(keyName),
new Parameter().withParameterKey("DomainName").withParameterValue(domainName),
new Parameter().withParameterKey("CloudFrontAcmCertificate").withParameterValue(Config.get(Config.Key.CLOUDFRONT_ACM_CERTIFICATE_ARN)),
new Parameter().withParameterKey("ElbAcmCertificate").withParameterValue(Config.get(Config.Key.ACM_CERTIFICATE_ARN)),
new Parameter().withParameterKey("BlogTitle").withParameterValue(blogTitle),
new Parameter().withParameterKey("BlogAdminUsername").withParameterValue("admin"),
new Parameter().withParameterKey("BlogAdminPassword").withParameterValue(blogPassword),
new Parameter().withParameterKey("BlogAdminEMail").withParameterValue("no-reply@widdix.de")
);
try {
final String domain = this.createDomain(stackName, this.getStackOutputValue(stackName, "CloudFrontDomainName"));
final String url = "https://" + domain;
final Callable<String> callable = () -> {
final HttpResponse response = WS.url(url).timeout(10000).get();
// check HTTP response code
if (WS.getStatus(response) != 200) {
throw new RuntimeException("200 expected, but saw " + WS.getStatus(response));
}
return WS.getResponseAsString(response);
};
final String response = this.retry(callable);
// check if blog title appears in HTML
Assert.assertTrue(response.contains(blogTitle));
} finally {
this.deleteDomain(stackName);
}
} finally {
this.deleteStack(stackName);
}
} finally {
this.deleteStack(vpcStackName);
}
} finally {
this.deleteKey(keyName);
}
}

}
Loading

0 comments on commit 503294a

Please sign in to comment.