These sample scripts provide a way to launch an AWS EC2 instance with user data that will create an FSxN
volume and LUN, mount it to the instance, while installing all the needed libraries and resources.
- LUN size will be set to 90% of the volume size, the remaining space is needed for the LUN management operation. This means that usable volume size is 90% of the requested size.
- The process might take several minutes to be complete.
- Create an AWS SecretsManager secret to hold the password of the account you plan to use to authenticate to the FSxN file system with.
The secret should be of type
otherwith value set toPlain Textthat holds just the password. - Create an AWS IAM role that has EC2 as the trusted entity and has permissions to read the secret value. Here is an example policy that will do that:
Replace the "Resource" ARN with the ARN of your secret.
{ "Version": "2012-10-17", "Statement": [ { "Sid": "VisualEditor0", "Effect": "Allow", "Action": [ "secretsmanager:GetSecretValue" ], "Resource": "arn:aws:secretsmanager:us-west-2:999999999:secret:fsxn-password-75WJ57" } ] }
There are two ways to deploy an EC2 instance with the needed user data script:
- Copy the CloudFormation template found in the repo EC2-cloud_formation.yaml to you local machine and deploy a CloudFormation stack using it. CloudFormation will prompt you for all the required parameters.
- Follow the instruction below to deploy an EC2 instance from the AWS console.
-
Download the needed script according to the instance type you want to run. Either linux_userData.sh for a Linux distribution or windows_userData.ps1 for Windows. The Linux script has been tested with
Amazon Linux 2023,Ubuntu 24.04,Red Hat Enterprise Linux 10andDebian 13distributions, while the Windows script is designed forWindows Server 2025 Base.Note that since AWS has a 16KB limit for the user data the linux_userData.sh script is made up of the variable assignment noted below, and a compressed, base64 encoded version of the
linux_userData_real.shscript. When thelinux_userData.shscript is run, it will decode and uncompress what was thelinux_userData_real.shscript and run it.Once you have downloaded the script, open it in a text editor and set the required values as noted below.
For the Linux version of the script, set the following values at the top of it:
- SECRET_ARN - The ARN of the secret that has the password for the
ONTAP-USER. - FSXN_ADMIN_IP - IP address, or hostname, of the FSxN management endpoint.
- VOLUME_NAME - The name of the volume you want to create in your FSxN.
- VOLUME_SIZE - The size of the volume you want to create in GB e.g [100]
- SVM_NAME - The name of the SVM where the volume is to be created.
- ONTAP_USER - The ONTAP user id you wish to authenticate with.
For the Windows version of the script, set the following values at the top of it:
- $secretId - secret ARN that holds the password for the
$user. - $ip - IP address, or hostname, of the FSxN management endpoint.
- $volName - The name of the volume you want to create in your FSxN.
- $volSize - The size of the volume you want to create in GB e.g [100]
- $drive_letter - The drive letter to assign to the volume.
- $user - The ONTAP user id you wish to authenticate with.
- $svm_name - The name of the SVM where the volume is to be created.
- SECRET_ARN - The ARN of the secret that has the password for the
-
Save the script file.
- Launch new instance
- Fill in the server name.
- Under the Quick Start tab select the Linux distribution of your choice. The supported distributions are: `Amazon Linux 2023`, `Ubuntu 24.04`, `Red Hat Enterprise Linux 10` and `Debian 13`
- Fill in the other settings based on your networking and business needs.
- Under 'Advanced details':
- Set the 'IAM instance profile' to the policy you created in the preperation step above.
- At the bottom, under the 'User data' section, press 'choose file' and select the script saved above.
- Launch the instance.
The installation log file can be found at: /var/log/iscsi-install.log.
If an error occurs while the installation is running, the script will terminate and all installations and setup will roll back.
- Launch new instance
- Fill in the server name.
- Select 'Windows'.
- Under Amazon Machine Image select 'Windows Server 2025 Base'.
- Fill in any other setting based on your networking and business needs.
- Under the 'Advanced details':
- Set the 'IAM instance profile' to the role you created in the steps above.
- At the bottom, under the 'User data' section, press 'choose file', and select the script saved above.
- Launch the instance.
The installation log file can be found at: C:\Users\Administrator\install.log.
If an error occurs while the installation is running, a message will be inserted into the
installation log file, it will attempt to roll back any work that it preformed, finally the script will terminate.
Note: It can take 10 to 15 minutes for the script to complete. Check the installation log file to confirm it is done.
The line Uninstall script removed should be at the bottom of the file when the script has finished.
This repository is maintained by the contributors listed on GitHub.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at apache.org/licenses/LICENSE-2.0.
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" basis, without WARRANTIES or conditions of any kind, either express or implied.
See the License for the specific language governing permissions and limitations under the License.
© 2026 NetApp, Inc. All Rights Reserved.