|
1 | 1 | # EC2 User data scripts |
2 | 2 |
|
3 | 3 | ## Introduction |
4 | | -Those samples provides a way to launch AWS EC2 instances with user data scripts that will create FSxN volume and LUN, mount it to the instance, |
5 | | -while installing all the needed libraries and resources |
| 4 | +These sample scripts provide a way to launch an AWS EC2 instance with `user data` that will create an FSxN |
| 5 | +volume and LUN, mount it to the instance, while installing all the needed libraries and resources. |
6 | 6 |
|
7 | 7 | ## Set Up |
8 | | -Create secet in AWS secret manager, secret should be saved as text. |
9 | | -In IAM create policy that will allow to read the secret. |
10 | | -Set the following permissions: |
| 8 | +1. Create an AWS SecretsManager secret to hold the password of the account you plan to use to authenicate to the FSxN file system with. |
| 9 | +The secret should be of type `other` with value set to `Plain Text` that holds just the password. |
| 10 | +1. Create an AWS IAM role that has permissions to read the secret value. Here is an example policy that will do that: |
| 11 | + ```json |
| 12 | + { |
| 13 | + "Version": "2012-10-17", |
| 14 | + "Statement": [ |
| 15 | + { |
| 16 | + "Sid": "VisualEditor0", |
| 17 | + "Effect": "Allow", |
| 18 | + "Action": [ |
| 19 | + "secretsmanager:GetSecretValue" |
| 20 | + ], |
| 21 | + "Resource": "arn:aws:secretsmanager:us-west-2:999999999:secret:fsxn-password-75WJ57" |
| 22 | + } |
| 23 | + ] |
| 24 | + } |
| 25 | + ``` |
| 26 | + Replace the "Resource" ARN with the ARN of your secret. |
11 | 27 |
|
12 | | -Example AWS Policy |
13 | | -{ |
14 | | - "Version": "2012-10-17", |
15 | | - "Statement": [ |
16 | | - { |
17 | | - "Sid": "VisualEditor0", |
18 | | - "Effect": "Allow", |
19 | | - "Action": [ |
20 | | - "secretsmanager:GetSecretValue" |
21 | | - ], |
22 | | - "Resource": "arn:aws:secretsmanager:us-west-2:847548833:secret:test/posh-75WJ57" |
23 | | - } |
24 | | - ] |
25 | | -} |
| 28 | +3. Download the needed script according to the instance type you want to run (Linux or Windows). |
26 | 29 |
|
27 | | -1. AWS Amazon Linux |
28 | | - First, get the needed script according to the instance type you want to run. |
29 | | - Set the following values in the script: |
30 | | - - SECRET_NAME - Secret name has it been saved in AWS secret manager |
31 | | - - AWS_REGION - AWS secret manager region |
32 | | - - FSXN_ADMIN_IP - FSxN administrator IP |
33 | | - - VOLUME_NAME - The name of the volume you want to create in your FSxN. |
34 | | - - VOLUME_SIZE - The size of the volume you want to create in GB e.g [100g] |
35 | | - - SVM_NAME - The SVM name, if you have another SVM which is not the default 'fsx'. |
| 30 | + For the Linux version of the script, set the following values at the top of it: |
| 31 | + - ONTAP_USER - The ONTAP user id you wish to authenicate with. |
| 32 | + - SECRET_NAME - Secret name has has the password for the `ONTAP-USER`. |
| 33 | + - AWS_REGION - AWS secret manager region. |
| 34 | + - FSXN_ADMIN_IP - IP address, or hostname, of the FSxN management endpoint. |
| 35 | + - VOLUME_NAME - The name of the volume you want to create in your FSxN. |
| 36 | + - VOLUME_SIZE - The size of the volume you want to create in GB e.g [100g] |
| 37 | + - SVM_NAME - The name of the SVM where the volume is to be created. |
| 38 | + |
| 39 | + For the Windows version of the script, set the following values at the top of it: |
| 40 | + - $user - The ONTAP user id you wish to authenicate with. |
| 41 | + - $secretId - secret ARN that holds the password for the `$user`. |
| 42 | + - $ip - IP address, or hostname, of the FSxN management endpoint. |
| 43 | + - $volName - The name of the volume you want to create in your FSxN. |
| 44 | + - $volSize - The size of the volume you want to create in GB e.g [100] |
| 45 | + - $drive_letter - The drive letter to assign to the volume. |
| 46 | + - $svm_name - The name of the SVM where the volume is to be created. |
| 47 | + |
| 48 | +4. Save the script file. |
36 | 49 |
|
37 | | -Save the script file. |
38 | | -In AWS console EC2 - Launch new instance fill server name and select 'Windows' select 'Microsoft Windows Server 2025 Base' fill any other needed data, |
39 | | -Go to 'IAM instance profile' and create or use instance profile with the policy you have just created. |
40 | | -Go to Advanced details and scroll down to User data, press 'choose file' select the script file you have saved. |
41 | | -Launch the instance. |
42 | | -The installation log file can be found at: /home/ec2-user/output.txt |
43 | | -If an error occurs while the installation is running, the process will be terminated and all installations and setup will roll back. |
44 | | - |
45 | | -2. AWS Microsoft Windows Server 2025 |
46 | | - Set the following values in the script: |
47 | | - - $secretId - secret ARN from yours AWS secret manager |
48 | | - - $ip - FSxN administrator IP |
49 | | - - $password - FSxN administrator password |
50 | | - - $volName - The name of the volume you want to create in your FSxN. |
51 | | - - $volSize - The size of the volume you want to create in GB e.g [100] |
52 | | - - $drive_letter - The drive letter to assign to the volume. |
53 | | - |
54 | | - Save the script file. |
55 | | - |
56 | | -## In AWS console EC2 - |
| 50 | +## On AWS console EC2 |
57 | 51 |
|
58 | | -For Linux installation: |
59 | | - - Launch new instance fill in the server name and select 'Amazon Linux' then select under Amazon Machine Image select 'Amazon Linux 2023 AMI' fill in any other required data, |
60 | | - Go to 'IAM instance profile' and create or use instance profile with the policy you have just created. |
61 | | - Go to Advanced details and scroll down to User data, press 'choose file', and select the script file you have saved. |
62 | | - Launch the instance. |
63 | | - The installation log file can be found at: /home/ec2-user/install.log |
| 52 | +### For Linux installation: |
| 53 | +<ol> |
| 54 | + <li>Launch new instance |
| 55 | + <ol> |
| 56 | + <li>Fill in the server name.</li> |
| 57 | + <li>Select 'Amazon Linux.</li> |
| 58 | + <li>Under Amazon Machine Image select 'Amazon Linux 2023 AMI'.</li> |
| 59 | + <li>Fill in the other settings based on your networking and business needs.</li> |
| 60 | + <li>Under 'Advanced details': |
| 61 | + <ol> |
| 62 | + <li>Set the 'IAM instance profile' to the policy you created in the steps above.</li> |
| 63 | + <li>At the bottom, under the 'User data' section, press 'choose file' and select the script saved above.</li> |
| 64 | + </ol> |
| 65 | + </li> |
| 66 | + </ol> |
| 67 | + </li> |
| 68 | + <li>Launch the instance.</li> |
| 69 | +</ol> |
| 70 | + |
| 71 | +The installation log file can be found at: `/home/ec2-user/install.log`. |
| 72 | +If an error occurs while the installation is running, the script will terminate and all installations and setup will roll back. |
64 | 73 |
|
65 | | -For Windows installation: |
66 | | - - Launch new instance fill in the server name and select 'Windows', then select under Amazon Machine Image select 'Windows Server 2025 Base', fill in any other required data, |
67 | | - go to Advanced details and scroll down to User data, press 'choose file', and select the script file you have saved. |
68 | | - Launch the instance. |
69 | | - The installation log file can be found at: C:\Users\Administrator\install.log |
| 74 | +### For Windows installation: |
| 75 | +<ol> |
| 76 | + <li>Launch new instance |
| 77 | + <ol> |
| 78 | + <li>Fill in the server name.</li> |
| 79 | + <li>Select 'Windows'.</li> |
| 80 | + <li>Under Amazon Machine Image select 'Windows Server 2025 Base'.</li> |
| 81 | + <li>Fill in any other setting based on your networking and business needs.</li> |
| 82 | + <li>Under the 'Advanced details': |
| 83 | + <ol> |
| 84 | + <li>Set the 'IAM instance profile' to the policy you created in the steps above.</li> |
| 85 | + <li>At the bottom, under the 'User data' section, press 'choose file', and select the script saved above.</li> |
| 86 | + </ol> |
| 87 | + </li> |
| 88 | + </ol> |
| 89 | + </li> |
| 90 | + <li>Launch the instance.</li> |
| 91 | +</ol> |
| 92 | + |
| 93 | +The installation log file can be found at: `C:\Users\Administrator\install.log`. |
| 94 | +If an error occurs while the installation is running, the script will terminate and all installations and setup will roll back. |
0 commit comments