{"id":7435,"date":"2024-11-20T10:37:27","date_gmt":"2024-11-20T09:37:27","guid":{"rendered":"https:\/\/blog.besharp.it\/?p=7435"},"modified":"2024-11-20T10:37:31","modified_gmt":"2024-11-20T09:37:31","slug":"remote-development-on-aws-from-cloud9-to-vs-code","status":"publish","type":"post","link":"https:\/\/blog.besharp.it\/remote-development-on-aws-from-cloud9-to-vs-code\/","title":{"rendered":"Remote Development on AWS: from Cloud9 to VS Code"},"content":{"rendered":"\n
Software development has significantly transformed in recent years, with many developers embracing distributed and collaborative working approaches. With the spread of DevOps methodologies, the adoption of the cloud-native paradigm, and the growing use of automation tools, flexibility and the ability to work on different platforms have become essential. However, this flexibility also introduces challenges, particularly when maintaining the consistency of development environments, which varies greatly depending on the device or operating system used and the projects you are working on.<\/p>\n\n\n\n
AWS announced<\/a> that it has no plans to develop new features for Cloud9, and the service has not been available to new customers for several months. This has led many developers to look for alternatives that offer more customization, flexibility, and a better user experience. Visual Studio Code (VS Code)<\/strong>, combined with an EC2 or ECS instance on AWS, is a great alternative. This configuration allows developers to access a robust, unified remote development environment, maintaining the same configurations and tools they are used to, regardless of the client device used.<\/p>\n\n\n\n Using VS Code for remote development ensures a portable workflow, access to on-demand computing resources, and ultra-fast connectivity for downloading libraries, dependencies, and artifacts.<\/p>\n\n\n\n This approach reduces compatibility issues, fully leverages EC2 instances’ capabilities, and allows for the integration of custom tools and configurations.<\/p>\n\n\n\n In this article, we will explore how to configure Visual Studio Code to work on an EC2 instance, exploring the necessary settings and their benefits step by step.<\/p>\n\n\n\n To obtain an experience similar to that of Cloud9, the code, dependencies, libraries, and specific configurations must physically reside on the remote instance. The local client must, therefore, be wholly integrated with the host, showing its terminal and using the remote environment for library searches, auto-completion, and all functions that require access to the source.<\/p>\n\n\n\n Additionally, running tests on the remote instance or launching a development server to test the software you are working on must be possible.<\/p>\n\n\n\n With Visual Studio Code, we can get everything we need through a single extension, which allows us to connect the client to a Visual Studio Code Server<\/a>.<\/p>\n\n\n\n Therefore, we will configure an EC2 instance to host the development server and see how to configure the client to connect to the instance and use it for remote development.<\/p>\n\n\n\n <\/p>\n\n\n <\/p>\n\n\n\n Communication between client and server is based on SSH, and it is possible to configure a single instance for multiple developers by taking advantage of the user space authentication and segregation mechanism already present in Linux and supported by SSH.<\/p>\n\n\n\n Each developer can create a user account on the instance, and each user will run a distinct VS Code server process.<\/p>\n\n\n\n Developing on a remote instance offers several significant benefits, including the ability to significantly improve a team’s workflow and simplify the management of development environments. <\/p>\n\n\n\n For example, one of the most common problems is inconsistency between developer machine configurations. Even slight differences can cause errors that are difficult to diagnose or hinder and slow down collaborative work. <\/p>\n\n\n\n With a remote instance, all of these configurations are centralized. Each developer works in an identical environment, potentially in the same instance, with no specific contraindications. This minimizes compatibility issues and ensures that dependencies are always up-to-date and consistent. <\/p>\n\n\n\n It is possible to configure the host to offer the most commonly used interpreters and libraries, centralizing versioning and distribution.<\/p>\n\n\n\n Where necessary, interpreter version management systems, such as pyenv or nvm, can also be installed and made available to all developers.<\/p>\n\n\n\n A further aspect to be noticed is performance. Many modern frameworks are resource-intensive during the compilation or build phases, not to mention the growing use of machine learning algorithms that require large amounts of CPU time, dedicated GPUs, and large amounts of RAM.<\/p>\n\n\n\n By freeing the IDE from the execution environment using a remote instance, developers can assign hardware resources that are significantly more performing than local devices, increasing or reducing them as needed to optimize costs and speed up work.<\/p>\n\n\n\n Furthermore, if a local device fails or requires maintenance, there are no significant interruptions: the remote environment remains intact and ready for use. <\/p>\n\n\n\n Finally, centralizing development on a remote server makes it easier to implement and monitor security policies and control user activity.<\/p>\n\n\n\n The first step is to install and configure the “Remote\u2014SSH”<\/a> extension in Visual Studio Code. This extension is the heart of remote connection, allowing you to work on a remote instance as if it were local while maintaining the power and flexibility of your development environment.<\/p>\n\n\n\n This add-on for VS Code allows you to open a folder on a remote server directly from the editor using an SSH tunnel. With this extension, files are viewed, edited, and managed within VS Code but remain physically on the remote server. <\/p>\n\n\n\n The commands written on the integrated terminal, which is a remote terminal, are also conveyed inside the SSH tunnel, as are all the operations that VS Code performs on the FS to provide support for the desired language and frameworks.<\/p>\n\n\n\n Installing the extension is very easy. In the left sidebar of VS Code, click on the extensions icon and search for “Remote\u2014SSH.” The first result should be the official Microsoft extension.<\/p>\n\n\n\n <\/p>\n\n\n <\/p>\n\n\n\n Let’s proceed with the extension installation. Once the process is completed, a new option will be available in the control panel that allows you to connect to a remote host.<\/p>\n\n\n\n <\/p>\n\n\n <\/p>\n\n\n\n No unique configurations are necessary on the remote instance. Once the SSH tunnel is established, VS Code will install the server automatically.<\/p>\n\n\n\n The server component is installed in user space and does not require elevated privileges.<\/p>\n\n\n\n The client will then directly update the server-side component, proposing updates to the user just as it does for the client part.<\/p>\n\n\n\n Therefore, we need to start an EC2 instance, taking care to choose the most suitable resources based on the use case. <\/p>\n\n\n\n Suppose you’re testing or the use case needs more horsepower. In that case, the t family gets the best value and usually fits nicely into the CPU usage pattern of a developer who doesn’t compile intensively.<\/p>\n\n\n\nThe solution<\/h2>\n\n\n\n
<\/figure><\/div>\n\n\n
Advantages of remote instance development<\/h2>\n\n\n\n
Client Configuration: “Remote – SSH” Extension<\/h2>\n\n\n\n
<\/figure><\/div>\n\n\n
<\/figure><\/div>\n\n\n
Instance configuration<\/h2>\n\n\n\n