We've a VDI infrastructure in AWS (AWS workspaces) and we're planning to automate the process of provisioning workspaces. Instead of going to GUI console, and launching workspaces by selecting individual users is little time consuming. Thus, I want to create them in bunches from AWS CLI (installed on centos 7). To achieve this I've created below shell script to launch the workspaces from CLI with least efforts. Please note, the ws-userlist.txt has a list of 60 users, one word per line.
for i in `cat ws-userlist.txt`;do command-to-create-workspaces DirectoryId=<directoryID>,UserName=$i,BundleId=<bundleID>;done
Now, here, there is a limitation of above workspace creation command. It can only build maximum 25 workspaces at one execution. I wonder if there any way to make the loop read the ws-userlist.txt in such a way that it read the first 25 users and take it as input for the command and execute it. once the it get executed, loop should go back to the input file, and read next set of 25 users and execute the command. Once it get executed, loop again go back to input file, and read the last 10 usernames and run the command.
Please note, username count could vary.Sometime I may have a list of 30, sometimes it could be 55.
I've basic knowledge of shell scripting. Need your expert help on this.
Thanks in advance.
Here is the example command to create workspaces : command-to-create-workspaces DirectoryId=<directoryID>,UserName=<User>,BundleId=<bundleID>
I wonder how can I supply the input to "UserName=" option in the command using the code given by you. UserName option should pick the input from ws-userlist.txt. Please advise.
With the help of my colleagues, I'm able to do what I was expecting to do. Here is the code which works for me.
for userid in `awk 'NR==1, NR==25' user-ids.txt`;
do
aws workspaces command to create workspaces UserName=$userid,BundleId=<bundleID>
done
for userid in `awk 'NR==26, NR==50' user-ids.txt`;
do
aws workspaces command to create workspaces UserName=$userid,BundleId=<bundleID>
done