Integration & Automation
Building a Microsoft test environment using nested Quick Starts
To test their Windows applications, developers typically need a test environment that closely mimics the target production environment. Aspects common to Windows test environments include a network, an Active Directory deployment, a Microsoft SQL Server deployment, a Microsoft Exchange Server deployment, a Microsoft SharePoint deployment, and other common Microsoft workloads.
While AWS customers can build Microsoft test environments on AWS manually, they can save significant time by using existing Microsoft Quick Starts as nested stacks. That automates much of the deployment and frees developers to work on application development.
About this blog post | |
Time to read | 10 minutes |
Time to complete | 25 minutes (not including deployment) |
Cost to complete | ~ $10 |
Learning level | Intermediate (200) |
AWS services | Amazon Virtual Private Cloud (Amazon VPC) AWS CloudFormation Amazon S3 Amazon EC2 AWS Systems Manager |
Overview of the Microsoft workload solution
AWS Quick Starts include automated deployments of popular Microsoft workloads built by AWS solutions architects. The underlying AWS CloudFormation templates are stored in public GitHub repositories and can be used as AWS CloudFormation submodules. A Windows application developer who wants to deploy a test environment can place a CloudFormation template in a GitHub repository, use the git submodule add
command to add the required Quick Start repositories as submodules, and then reference the submodules in their CloudFormation templates.
The following diagram shows the AWS resources that are deployed by this CloudFormation template.
Prerequisites
For this walkthrough, you need the following prerequisites:
- An AWS account
- An EC2 key pair
- A GitHub account
- Basic knowledge of common Microsoft workloads
- Basic knowledge of CloudFormation templates
- A copy of the SharePoint 2019 installation media in .ZIP format (optional)
Note: this blog post assumes that the reader is familiar with CloudFormation templates and parameters. For more information, see the AWS documentation for CloudFormation templates, Parameters, ParameterGroup, and ParameterLabel.
Walkthrough for deploying the nested Microsoft workload stacks
This walkthrough describes the steps to deploy a full Windows test stack:
- A VPC with public and private subnets
- A redundant Active Directory environment with two domain controllers
- A redundant SQL environment with an AlwaysOn Availability Group and database replication
- A redundant SharePoint environment that uses the SQL environment for its databases
- A redundant Exchange environment
- An AWS Auto Scaling group with Remote Desktop Gateway for remote access to the environment
When deploying Windows environments on AWS, customers can deploy only those Quick Starts that are relevant to their workloads. (See the AWS CloudFormation documentation to learn how conditions can be used to select only certain submodules during deployment.) The Quick Starts used for this walkthrough have been selected because they are common deployments.
The following steps describe how to deploy this sample Microsoft test environment stack:
- Create a GitHub repository
- Clone the GitHub repository to a development workstation and create
templates
andsubmodules
subdirectories. - Create a template file in the
templates
subdirectory. - Navigate to the
submodules
subdirectory and usegit submodule add
to incorporate the various Microsoft submodules. - Create parameters, parameter groups, and parameter labels.
- Incorporate the various Microsoft Quick Start submodules as nested stacks.
- Upload all templates and SharePoint 2019 installation media to an S3 bucket.
- Launch the stack.
The Quick Start GitHub repositories can be found at the following links:
- Amazon VPC: https://github.com/aws-quickstart/quickstart-aws-vpc
- Active Directory: https://github.com/aws-quickstart/quickstart-microsoft-activedirectory
- Microsoft SQL: https://github.com/aws-quickstart/quickstart-microsoft-sql
- SharePoint: https://github.com/aws-quickstart/quickstart-microsoft-sharepoint
- Exchange: https://github.com/aws-quickstart/quickstart-microsoft-exchange
- Remote Desktop Gateway: https://github.com/aws-quickstart/quickstart-microsoft-rdgateway
You can find the completed version of this walkthrough at https://github.com/aws-quickstart/msft-nested-example.
Step 1: Create a GitHub repository
- Navigate to your GitHub account (https://github.com/<accountname>).
- In the Repositories pane, choose New to create a new repository. For the purpose of this blog post, I use the name
msft-nested-example
, but the repository can be named anything within the GitHub guidelines. Make sure to select the check box to Initialize this repository with a README.
Step 2: Clone the GitHub repository to a development workstation and create subdirectories
- Use the Clone or download link to clone the repository to your workstation or other development environment (IDE); e.g., Amazon WorkSpaces.
- In your IDE, navigate to the cloned repository, and create submodules and templates subdirectories.
Step 3: Create a template file in the templates subdirectory
- Use your IDE to create a new template file (in this example, I call it
msft.template
) in thetemplates
subdirectory.
Step 4: Incorporate the Microsoft Quick Start submodules
- Navigate to the
submodules
directory. - Add the VPC, Active Directory, Microsoft SQL, SharePoint, Exchange, and Remote Desktop Gateway submodules.
- Initialize the submodules (download their contents and the contents of their respective submodules).
Step 5: Create parameters
- Open the AWS CloudFormation file in the templates subdirectory that was created in step 3.
- Define following parameter groups and parameters.
This example uses the default values for many parameters, including the Exchange Server version, server hostnames, instance types, and others. To create a more customized environment, you can include these parameters.
- To make the AWS CloudFormation launch page more readable, add parameter labels.
- Finally, within the template, describe all of the parameters, including character constraints and default values.
Step 6: Incorporate Quick Starts as nested stacks
In the Resources
section of the template, you can add the various Quick Start submodules as AWS CloudFormation stacks. The outputs from deployed stacks can be passed as parameters to subsequent stacks. For instance, when launching the Microsoft stacks, the VPCID
parameter can be extracted from the output of the VPC stack (VPCStack.Outputs.VPCID
).
- Add the VPC stack.
- Add the Active Directory stack.By setting the
DependsOn
attribute to the VPC stack, you can ensure that the Active Directory stack will not deploy until the VPC stack is complete. - Add the SQL Server stack.By setting the
DependsOn
attribute to the Active Directory stack, you can ensure that the SQL stack will not deploy until the Active Directory stack is complete. - Add the SharePoint stack.By setting the
DependsOn
attribute to the SQL Server stack, you can ensure that the SharePoint stack will not deploy until the SQL Server stack is complete.Note: A copy of the SharePoint 2019 installation media (in .ZIP format) is required to deploy SharePoint. If you do not have access to this, omit the SharePoint stack from the template. - Add the Exchange Server stack.By setting the
DependsOn
attribute to the Active Directory stack, you can ensure that the Exchange stack will not deploy until the Active Directory stack is complete. - Add the Remote Desktop Gateway stack.By setting the
DependsOn
attribute to the Active Directory stack, you can ensure that the Remote Desktop Gateway stack will not deploy until the Active Directory stack is complete.
Step 7: Upload files to the S3 bucket
- If you do not already have an S3 bucket available, navigate to the AWS Management Console, choose S3, and create an S3 bucket. Ensure that the bucket allows public access.
- Create a directory in the S3 bucket, and upload the entire contents of your local copy of the GitHub repository to this directory. Later, you will enter the directory name as the
S3BucketName
parameter.
Step 8: Launch the CloudFormation template
- Navigate to the AWS Management Console, and select CloudFormation.
- Choose Create stack, and select With new resources (standard).
- Enter the S3 location of your template (https://<S3BucketName>.s3.amazonaws.com/≪S3KeyPrefix>templates/msft.template), or upload the template from your local copy of the GitHub repository.
- Fill out the fields that don’t have default values.
- Stack Name. Enter a unique name for the stack.
- Key pair name. Select an EC2 key pair to connect to your instances.
- Availability Zones. Select two Availability Zones for the deployment.
- Domain admin password. This is the password used to administer Active Directory.
- Service account password. This is the password used to run SQL Server.
- SharePoint binary bucket. If you uploaded the SharePoint installation media, enter the bucket name here.
- SharePoint binary key. If you uploaded the SharePoint installation media, enter the S3 key here.
- Allowed RD Gateway external access CIDR. Enter the CIDR that will have access to the Remote Desktop Gateway farm.
- S3 Bucket name. Enter the S3 bucket where you uploaded the GitHub repository contents.
- S3 key prefix. Enter the S3 key prefix where you uploaded the GitHub repository contents. Ensure that the key prefix ends with a forward slash (“/”).
- Choose Next.
- Keep the default stack options, and choose Next.
- Select the check boxes for I acknowledge that AWS CloudFormation might create IAM resources with custom names and I acknowledge that AWS CloudFormation might require the following capability: CAPABILITY_AUTO_EXPAND, and choose Create stack.
Stack creation should begin. Each nested stack will have its own object in the AWS CloudFormation console.
Upon completion, a full Microsoft stack is deployed, including the following resources:- Two domain controllers
- Two Windows Server failover cluster servers running SQL Server
- A file server to act as the failover cluster witness
- Two Exchange nodes
- A file server to act as the Exchange Server cluster witness
- Four SharePoint servers
- Remote Desktop Gateway in an Auto Scaling group
Deployment takes approximately 4 hours.
Cleaning up
To avoid incurring future charges, delete the resources. In the AWS CloudFormation console, select the main stack that you created, and then choose Delete. All objects that were created during launch, including all of the nested stacks, will be deleted.
Conclusion
In this walkthrough, I showed you how to create a single CloudFormation template that leverages existing Quick Starts as submodules to deploy a full Microsoft stack in an automated fashion. Visit the Microsoft section of the AWS Quick Starts page to view the Microsoft products currently available to use as submodules. View the AWS Quick Start GitHub organization page to find their corresponding Git links to use them as submodules for future Microsoft deployments.