AWS Builder Center
Your Cloud Workspace Is Temporary. Your Work Shouldn't Be.

Your Cloud Workspace Is Temporary. Your Work Shouldn't Be.

What happens when your AWS CloudShell VPC environment disappears? Your scripts, files, and configurations may disappear with it. Explore how Git, Amazon S3, and reproducible setup scripts can help protect your work, rebuild your development environment, and avoid starting from scratch. A practical guide to making temporary cloud workspaces more resilient.

CSE-AIML Student

Your Cloud Workspace Is Temporary. Your Work Shouldn't Be.

Imagine this.
You open AWS CloudShell, connect to resources inside your VPC, and start working on a project. You install a few tools, write some scripts, configure your environment, and finally get everything working.
You leave for a while. When you return, your CloudShell VPC environment has timed out.
You open it again, expecting to continue where you left off. But your files are gone. Your installed tools are missing. Your configurations have disappeared.
The frustrating part? You didn't necessarily make a mistake. This is how CloudShell VPC environments are designed to work.
So, how do we make sure that our work survives even when the environment doesn't?
Let's explore a practical approach using three familiar AWS and development practices: Git, Amazon S3, and reproducible setup scripts.



1. First, understand what happens to your CloudShell environment

AWS CloudShell gives you a browser-based command-line environment without requiring you to install a terminal locally. It comes with useful pre-installed tools and supports working with AWS services through the AWS CLI.
However, there is an important distinction between a standard CloudShell environment and a CloudShell VPC environment.
In a standard environment, AWS provides up to 1 GB of persistent storage in your home directory ( $HOME ) for each AWS Region. Files stored there can remain available across sessions, subject to AWS's retention policy.
CloudShell VPC environments work differently.
They allow you to launch CloudShell inside a VPC, associate a subnet and security groups, and work with resources using that VPC's network configuration. This is particularly useful when accessing private resources.
But there is a trade-off: CloudShell VPC environments do not provide persistent home-directory storage.
AWS documents that the home directory is deleted when the VPC environment times out, or when you delete or restart the environment. The usual inactivity timeout is 20–30 minutes. In AWS GovCloud (US) Regions, it is 10 minutes.
There is another limitation worth knowing: the built-in upload and download options in the CloudShell Actions menu are unavailable in VPC environments.
These are documented service behaviours, not unexpected failures.
The important thing is to understand the environment's lifecycle before depending on it for work that needs to survive.

2. What exactly can disappear?

Think of your CloudShell VPC environment as a temporary workshop.
You may have several things inside it:
  • Project files: Python scripts, shell scripts, configuration files, and other working documents.
  • Installed dependencies: Libraries and tools you installed while working.
  • Environment configurations: Custom aliases, shell settings, and environment-specific configuration.
  • Temporary working data: Generated files, logs, and intermediate results.
  • Running processes: Background tasks, active sessions, and processes that were using the environment.
When the environment is removed, you should not expect these things to be available in the next environment.
However, not everything needs to be preserved in the same way.
Your source code belongs in version control. Your important files can be backed up separately. Your dependencies should be documented. Your setup process should be repeatable.
This leads to a simple idea:
Don't try to preserve the entire temporary environment. Preserve the things needed to recreate your work.

3. A practical three-part strategy

Instead of treating the CloudShell VPC home directory as permanent storage, divide your work into three categories.

Part 1: Preserve what you build — Git

Your source code should not exist only inside a temporary terminal.
Use Git to track your project files, scripts, and changes. Push important work to a remote repository so that you can retrieve it from another environment.
For example:
mkdir -p ~/workspace/my-project
cd ~/workspace/my-project

git init
After creating your project files, track and commit them:
git add .
git commit -m "Initial project setup"
If you have configured a remote repository:
git remote add origin YOUR_REPOSITORY_URL
git push -u origin main
Later, from a fresh environment, you can retrieve the project:
git clone YOUR_REPOSITORY_URL
Git gives you more than a copy of your files. It provides a history of changes, making it easier to understand what changed and recover earlier versions.
Remember to avoid committing credentials, private keys, access tokens, or other sensitive information. Use appropriate secret-management practices instead.

Part 2: Protect important working files — Amazon S3

Git is excellent for source code, but not every file belongs in a Git repository.
You might have generated reports, exported data, project artifacts, or other files that need separate storage.
This is where Amazon S3 becomes useful.
You can create an S3 bucket and use the AWS CLI to transfer a selected project directory to it.
For example, suppose your project is stored in:
~/workspace/my-project/
And your S3 bucket is:
s3://YOUR-BUCKET/cloudshell-backups/my-project/
First, check what would be uploaded:
aws s3 sync ~/workspace/my-project/ \
s3://YOUR-BUCKET/cloudshell-backups/my-project/ \
--dryrun
The  --dryrun  option previews the operations without actually transferring files.
If the preview looks correct, perform the backup:
aws s3 sync ~/workspace/my-project/ \
s3://YOUR-BUCKET/cloudshell-backups/my-project/
That's it. Your selected project files are now stored separately from the temporary CloudShell VPC environment.
When you open a fresh environment, recreate the destination directory and restore the files:
mkdir -p ~/workspace/my-project

aws s3 sync \
s3://YOUR-BUCKET/cloudshell-backups/my-project/ \
~/workspace/my-project/
You can then inspect the restored files and continue working.
An important precaution: Don't blindly back up your entire home directory. It may contain credentials, temporary tokens, private configuration, or other sensitive files. Select the project directories and artifacts you actually need, and review their contents before uploading.
Also, avoid adding  --delete  to these basic backup commands. That option can delete destination files that aren't present in the source. It is not necessary for this simple backup-and-restore workflow.

Part 3: Remember how to rebuild — setup scripts

Here is something that is easy to overlook.
Restoring your project files does not automatically restore the tools and dependencies you installed.
Suppose your project requires a particular Python library. You installed it manually in your previous environment. After the environment disappears, the project files may be recoverable, but that library may need to be installed again.
This is why reproducible setup matters.
For a Python project, maintain a dependency file such as:
requirements.txt
It can contain the libraries your project needs, ideally with appropriate version constraints or pinned versions.
You can then install them in a fresh environment using:
python -m pip install -r requirements.txt
You can also create a setup script:
#!/bin/bash

set -e

echo "Preparing project environment..."

python -m pip install -r requirements.txt

echo "Project setup completed."
Save it as:
setup.sh
Run it whenever you create a fresh environment:
chmod +x setup.sh
./setup.sh
For projects using Node.js, Java, or other technologies, maintain the corresponding dependency manifests, lockfiles, and setup instructions.
The objective is simple: someone should be able to retrieve your project and understand how to prepare it without relying on your memory of every command you previously executed.



4. The networking question: How can CloudShell VPC reach S3?

There is one important AWS networking detail we shouldn't overlook.
If your CloudShell VPC environment is inside a private subnet, how will it communicate with Amazon S3?
One option is to use a Gateway VPC Endpoint for Amazon S3.
A gateway endpoint allows resources in your VPC to access S3 without requiring an internet gateway or NAT device for that S3 traffic.
You create the endpoint in the VPC, associate the relevant route tables, and configure its endpoint policy as needed.
The route tables determine which subnet traffic uses the endpoint. The endpoint policy can further restrict which S3 resources and actions are accessible through it.
There is no additional charge for using an S3 Gateway Endpoint itself. However, normal S3 storage, request, and other applicable AWS charges still apply.
This is useful when you want to transfer project files to S3 while keeping the traffic within the AWS network rather than routing it through a public internet path.
But remember one distinction:
Network connectivity is not the same as permission to access data.
Even if your VPC can reach S3, your IAM identity still needs the required permissions.
For a basic backup and restore workflow, the relevant permissions commonly include:
  •  s3:ListBucket  for listing objects in the relevant bucket or prefix.
  •  s3:PutObject  for uploading files.
  •  s3:GetObject  for downloading files.
Additional permissions may be needed depending on your configuration, such as encryption with a customer-managed KMS key or specific bucket-policy conditions.
Use least-privilege IAM policies that restrict access to the required bucket and prefix. Don't solve permission errors by granting broad access to every S3 resource.
If you use a gateway endpoint, also check its endpoint policy and the S3 bucket policy. Both can affect whether a request is allowed.



5. How do you know your recovery actually works?

A backup is useful only if you can restore it.
Uploading files to S3 and assuming everything is safe is not enough. A better approach is to perform a small recovery test.
For example, create a checksum for an important file before backing it up:
sha256sum ~/workspace/my-project/main.py
After uploading the project, open a fresh CloudShell VPC environment and restore it from S3.
Then calculate the checksum again:
sha256sum ~/workspace/my-project/main.py
Compare the two values.
If the checksums match, the contents of that file match.
You can also compare the restored directory structure and inspect important files.
For a more complete test, verify that:
  1. The project files are present.
  1. The dependency installation completes successfully.
  1. Your setup script runs without errors.
  1. Your application or script executes as expected.
  1. Important configuration can be recreated without exposing secrets.
This is a small exercise, but it changes the way you think about backups.
Instead of asking, "Did I upload my files?", ask, "Can I recover my work in a fresh environment?"



6. What this approach does not restore

It is important to understand the limitations of this strategy.
Git and S3 can preserve source code and selected files, while setup scripts can help recreate dependencies and configurations. But they do not preserve the entire state of a running environment.
For example, they do not automatically restore:
  • Running processes or background jobs.
  • Active terminal sessions.
  • Temporary memory and process state.
  • Every manually installed system-level tool.
  • Network connections or temporary session credentials.
  • Resources created elsewhere in AWS that were not included in your recovery plan.
This is why the goal should not be to create an exact copy of the old CloudShell environment.
The goal is to make your important work recoverable and your development setup reproducible.
If you need long-running processes, durable compute, or a workspace that retains its environment state, consider whether a different compute option, such as an appropriately configured Amazon EC2 instance, is better suited to your workload.
CloudShell is designed for convenient, interactive access. It should not automatically become the storage or compute foundation for every long-running project.

7. A few security and cost practices worth following

Before making this workflow part of your routine, keep these points in mind:
Security
  • Keep S3 buckets private and enable S3 Block Public Access.
  • Use least-privilege IAM permissions.
  • Enable appropriate encryption at rest.
  • Never store access keys, passwords, or private tokens in project backups unnecessarily.
  • Review your backup contents before uploading.
  • Consider enabling S3 Versioning if you need protection against accidental overwrites or deletions. Remember that retained object versions consume storage and can incur charges.
Cost
  • S3 storage and requests are subject to the applicable pricing.
  • Large or frequent backups can increase storage and request costs.
  • Versioning can retain older object versions, so configure lifecycle rules if appropriate.
  • An S3 Gateway Endpoint has no additional endpoint usage charge, but this does not make all related AWS services free.
The idea is not to build an unnecessarily complicated backup system. Start with a small, secure workflow and expand it only when your project requires it.



8. The bigger lesson: Build for recovery, not just convenience

A temporary development environment is not necessarily a problem.
In fact, temporary environments can be useful because they provide convenient access to resources without requiring you to maintain a permanent machine.
The problem begins when we treat temporary infrastructure as permanent storage.
A more reliable way to approach cloud development is to separate three responsibilities:
Responsibility
Suitable approach
Preserve source code and its history
Git
Store selected project files and artifacts
Amazon S3
Recreate dependencies and configurations
Setup scripts and dependency manifests
Together, these practices make your work less dependent on a particular terminal session or temporary environment.
You don't need to remember every command you typed yesterday. You don't need to manually recreate every file. And you don't have to assume that a working environment will remain available forever.
Your workspace may disappear, but your project should have a way back.

Let's discuss

Imagine your CloudShell VPC environment disappeared right now.
How long would it take you to get back to where you were?
Would you be ready in a few minutes because your code, dependencies, and setup instructions are already organised? Or would you need to rebuild everything manually?
I'd be interested to know how other developers approach this:
  • Do you rely mainly on Git?
  • Do you maintain S3 backups for important artifacts?
  • Do you use automated setup scripts?
  • Or do you follow a different approach altogether?
Share your approach in the comments. It would be interesting to learn how the community makes temporary cloud workspaces more resilient.
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article