AWS – Amazon FSx for Windows File Server

Create a Home page in ASP.Net Core 3.1 MVC

AWS recently launched a Windows version of EFS so that users who prefer Windows EC2 instances can enjoy all of the same benefits. Follow this recipe to find out how to create an FSx file share using PowerShell.

Getting ready

You will need a Windows EC2 instance that is joined to a domain to complete this recipe. If you already have one, skip to the How to do it section. If not, follow these steps to create a Directory Service directory and an EC2 instance that is joined to your domain:

Note that the resources you create in this recipe will not fall under the free tier! There will be charges associated with them, even if you tear down the resources after you finish this chapter.
  1. Go to the Directory Service dashboard and click Set up a directory:

Directory Service
  1. Select AWS Managed Microsoft AD from under  Directory types:

Selecting the directory type
  1. Configure the directory information on the next screen. Again, note that this recipe does not fall into the free tier! There will be charges associated with these resources:

Directory information
  1. Be sure to remember the password you set in the previous step. You will need to log in to your EC2 instance with the domain user account  not with the machine administrator account – via the EC2 console.
  1. Choose your VPC and Subnets. To keep things simple, choose your default VPC:

Choosing the VPC and subnets
  1. On the next screen, confirm your settings and click Create directory.
  2. Wait for the directory to be created.
  3. Go to the EC2 dashboard and click Launch Instance to create a new Windows instance.
  1. Select Microsoft Windows Server 2019 Base:

Choosing an Amazon Machine Image (AMI)
  1. On the following screen, select an instance type. Choose t2.micro to stay in the free tier. However, be aware that the performance of Windows Server on this small instance will be very slow. A larger instance type will perform much better, but it will incur a cost until you terminate it.
  2. Click Next: Configure Instance Details.
  3. On the following screen, select a Subnet that matches the subnet that’s used by your Active Directory instance. Also, choose the directory in the Domain join directory dropdown.
  4. Click Next: Add Storage and accept the defaults.
  5. Click Next: Add Tags and optionally tag the instance with a unique name so that you can recognize it on the dashboard.
  6. Click Next: Configure security group and choose the default VPC security group.
  7. Click Review and Launch and launch your instance.

How to do it…

Once you are logged in to your instance as the Admin domain user (this is the user you created when you were configuring the directory in step 3, not the machine administrator!), follow these steps to create and access an FSx file share:

  1. Open up a PowerShell terminal.
  2. Enter the following commands to enable script execution, import AWS Tools for Windows PowerShell, and then check the version to make sure everything works as expected:
PS C:\Users\Admin> Set-ExecutionPolicy RemoteSigned
PS C:\Users\Admin> Import-Module AWSPowerShell
PS C:\Users\Admin> Get-AWSPowerShellVersion

AWS Tools for Windows PowerShell
Version 3.3.462.0
Copyright 2012-2018, Inc. or its affiliates. All Rights Reserved.

Amazon Web Services SDK for .NET
Core Runtime Version
Copyright 2009-2015, Inc. or its affiliates. All Rights Reserved.

Release notes:

This software includes third party software subject to the following copyrights:
- Logging from log4net, Apache License

  1. Set your access key and secret key:
PS C:\Users\Admin> Set-AWSCredential -AccessKey [YOUR-ACCESS-KEY] -SecretKey [YOUR-SECRET-KEY]
  1. Create the filesystem. After running this command, you will get an output that describes the filesystem. You can use ClientRequestToken to make queries relating to this specific filesystem as it is being created. Make sure you use the same subnet as your EC2 instance:
PS C:\Users\Admin> New-FSXFileSystem -ClientRequestToken MyToken -FileSystemType WINDOWS -StorageCapacity 300 -SubnetId YOUR_SUBNET_ID -WindowsConfiguration @{ThroughputCapacity=8;ActiveDirectoryId='YOUR_DIRECTORY_ID'}
  1. Check its progress. The following command returns information for all filesystems. It can take several minutes for the filesystem to become available, which is indicated by Lifecycle: AVAILABLE in the output:
PS C:\Users\Admin> Get-FSXFileSystem
  1. Once it’s available, map the network drive via the file explorer, or use the following command:
PS C:\Users\Admin> net use E: \\[YOUR-FILESYSTEM-ID].[YOUR-DOMAIN]\share /persistent:yes
  1. Now, you should be able to read and write to the network share mapped to the E: drive. To test it, open notepad.exe and create a new file on the E: drive.
  2. To avoid further charges, terminate the instance, delete the filesystem, and remove Active Directory when you have finished this recipe.

How it works…

FSx for Windows combines the functionality of a Microsoft Windows domain with the resilient file storage of EFS so that Windows users can interact with a network share in exactly the same way they would if the share were created using native Windows filesystem commands within a domain. FSx is compatible with SMB versions 2.0 to 3.1.1, which allows backward compatibility to Windows Server 2008 and Windows 7, and even allows for connections from Linux machines.

Comments are closed.