Desktop and Application Streaming
Persistent storage for Amazon AppStream 2.0 Linux Fleets on Amazon Elastic File System
Amazon Elastic File System (EFS) used with Amazon AppStream 2.0 creates a persistent storage location often required by educational or research institutions while optimizing storage and application access. Combining these services simplifies how these institutions store their data or education materials and ensures researchers and students have access regardless of their location. Furthermore, the integration prioritizes secure data management while promoting collaboration. Adopting these technologies enhances institutions digital infrastructure, providing a responsive and accessible platform for researchers, educators and learners.
Common Use Cases:
While this blog could be used in a variety of use cases the examples below focus on educational institutions as a common use case.
Why would an educational institution want to attach an EFS file share to AppStream 2.0 Linux instances? The answer lies in the collaborative nature of modern learning:
- Shared Resources: Educational institutions often have common resources including textbooks, research papers, lab content, and learning software. By integrating EFS with AppStream 2.0, students and faculty can access these shared resources seamlessly, irrespective of their location with consistent performance.
- Collaborative Projects: Modern education emphasizes group projects and team-based assignments. Using EFS as a centralized file system, student groups can collaboratively work on documents, software, or datasets, while using applications streamed from AppStream 2.0.
- Laboratory Simulations: For institutions that rely heavily on simulations and laboratory software a consistent shared storage system allows students to start a project on one device and resume work on another flexibly.
Prerequisites:
- AWS Account: Ensure you have an active AWS account and necessary permissions.
- An EFS File System: Before you can attach anything, you need an EFS filesystem set up. For more information on creating an EFS File System see Creating Your Amazon EFS File System.
- Security Groups: The EFS file system security group must allow NFS (port 2049 TCP protocol) from the AppStream 2.0 fleet security group or subnet CIDR block.
Step by Step Instructions:
- Open the Amazon AppStream 2.0 Console.
- Deploy the Image Builder utilizing the Amazon Linux 2 image. For instructions see Install and Configure Streaming Applications with Image Builder.
- Establish a connection to the Image Builder.
- Upon successful connection to the Image Builder, launch the Terminal application located under “Applications”.
- Given that this documentation leverages the Amazon EFS, it is important to install the amazon-efs-utils. These tools, often referred to as the Amazon EFS client, include the EFS mount helper, facilitating the mounting of EFS file systems.
Run the following command to install the EFS utilities:
sudo yum install -y amazon-efs-utils
- To mount the EFS share upon session initiation, session scripts are employed. This is a multi-stage process:
-
- Create a new file in a text editor like vi. The values of below two variables must be changed in the script before using it.
EFS_ENDPOINT: This is the DNS name of the EFS file system (created as part of pre requisites). It is available in EFS Filesystem page as shown below.
MOUNT_DIRECTORY: EFS file system is mounted on /mnt/efs_share. Change it as per requirements.
Paste the below sample BASH script into the file. Save the changes and exit the editor.
This sample script runs during instance launch and mounts the EFS share.
sudo vi /opt/appstream/SessionScripts/efs_mount.sh
#!/bin/bash
# Script to mount an Amazon EFS share to a specified mount point
# Constants
EFS_ENDPOINT=" fs-0caxxxxxxxda9.efs.us-west-2.amazonaws.com"
MOUNT_DIRECTORY="/mnt/efs_share"
MOUNT_OPTIONS="nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,noresvport"
# Ensure the mount point exists; if not, create it
if [ ! -d "${MOUNT_DIRECTORY}" ]; then
mkdir -p "${MOUNT_DIRECTORY}"
# Set the sticky bit to ensure only file owners can modify their respective files
# Adjust permissions as needed
chmod 1777 "${MOUNT_DIRECTORY}"
fi
# Attempt to mount the EFS share
mount -t nfs4 -o ${MOUNT_OPTIONS} "${EFS_ENDPOINT}:/" "${MOUNT_DIRECTORY}"
# Log the outcome of the mount operation
if [ $? -eq 0 ]; then
echo "$(date): Successfully mounted EFS at ${MOUNT_DIRECTORY}."
else
echo "$(date): Error mounting EFS."
fi
To save a file and exit vi editor, press Esc,
then type :wq
and press Enter
.
-
- Change the permissions of the created and test if EFS share mounts successfully.
chmod +x /opt/appstream/SessionScripts/efs_mount.sh
sudo /opt/appstream/SessionScripts/efs_mount.sh
df -h
-
- Subsequently, update the configuration file with the script’s details. Open `config.json` in a text editor.
sudo vi /opt/appstream/SessionScripts/config.json
Modify the ‘executable’ section in the JSON to run the script created in the prior step. The modified `config.json` should resemble the structure provided.
{
"SessionStart": {
"executables": [
{
"context": "system",
"filename": "/opt/appstream/SessionScripts/efs_mount.sh",
"arguments": "",
"s3LogEnabled": true
}
],
"waitingTime": 30
},
"SessionTermination": {
"executables": [],
"waitingTime": 30
}
}
To save a file and exit vi editor, press Esc,
then type :wq
and press Enter
.
- Complete any use case specific customizations for the AppStream 2.0 fleet including application installations or settings as described in this documentation. Once all customizations are complete, advance to the next step.
- After ensuring all applications are installed, configured, and validated, generate an image from the Image Builder. Run the following command within the Image Builder’s terminal. Replace `Image_name` with your desired image name.
AppStreamImageAssistant create-image --name Image_name
- Monitor the image creation status via the AppStream 2.0 console.
- Upon completion of the build process, the image status should indicate “Available”.
- Create an AppStream 2.0 Fleet utilizing the image created in previous steps and establish an AppStream 2.0 Stack. For guidance on configuring a Stack, see Setting Up Stacks and Fleets. For the intent of this blog, a fleet with a desktop view has been generated.
- Once the stack is operational, access the AppStream 2.0 application. Select the desktop icon to initiate a new AppStream 2.0 desktop session.
- Within the streaming session activate a new terminal window and verify the EFS mount status using the `df` command.
df -h /mnt/efs_share/
- For validation purposes, initiate multiple AppStream 2.0 sessions. The EFS share should be accessible on all activated instances.
Now administrators, educators, or users can stage and store shared data within the mount and begin collaborating with persistent shared storage.
Cleaning Up:
You can stop your running fleet and delete your active stack to free up resources and to avoid unintended charges to your account.
Note that you cannot delete a stack with an associated fleet.
To clean up your resources
- In the navigation pane, choose Stacks.
- Select the stack and choose Actions, Disassociate Fleet. In the confirmation dialog box, choose Disassociate.
- In the navigation pane, choose Fleets.
- Select the fleet that you want to stop, choose Actions, and then choose Stop. It takes about five minutes to stop a fleet.
- When the status of the fleet is Stopped, choose Actions, Delete.
- In the navigation pane, choose Stacks.
- Select the stack and choose Actions, Delete.
Conclusion:
In conclusion, the integration of EFS and AppStream 2.0 plays a pivotal role in advancing the digital capabilities of educational institutions. This approach ensures that resources are stored in a persistent manner and readily accessible, promoting efficient teaching and learning. As the landscape of research and education evolves such integrations are crucial in laying the foundation for a seamless experience for students and educators.
For more information about Amazon AppStream 2.0 see What Is Amazon AppStream 2.0 and for Amazon Elastic File System see What is Amazon Elastic File System.
To get hands-on information, checkout the Getting started with AppStream 2.0 workshop.
Sudheer Manubolu is Solutions Architect with Amazon Web Services (AWS). He assists higher education customers through cloud implementations, leveraging in-depth knowledge of AWS services to design efficient solutions. Before joining AWS, he handled a broad spectrum of tasks, ranging from physical server installations to application development. | |
Grant Joslyn is a solutions architect for the US state and local government public sector team at Amazon Web Services (AWS). He specializes in end user compute and cloud automation. He provides technical and architectural guidance to customers building secure solutions on AWS. He is a subject matter expert and thought leader for strategic initiatives that help customers embrace DevOps practices. |