Software đã được cài đặt trong CloudShell biến mất sau vài giờ

Bài toán:
Install 1 phần mềm vào CloudShell (vd: Terraform) bằng cách như sau:

sudo yum install -y yum-utils
sudo yum-config-manager --add-repo https://rpm.releases.hashicorp.com/AmazonLinux/hashicorp.repo
sudo yum -y install terraform

thì vài giờ sau Terraform biến mất, lại phải install lại ->Tại sao và có cách nào workaround không?

Trả lời:

Khi bạn sử dụng các Package manage utilities ví dụ như yum để install các software, thì các software này sẽ biến mất khi shell session kết thúc [1].
Về thời gian kết thúc của shell session bạn hãy tham khảo tài liệu [2]

Về phương án workaround là bạn hãy xem xét install software vào thư mục home của CloudShell.
Đặc điểm kỹ thuật của CloudShell là dữ liệu thư mục home sẽ bị xóa sau 120 ngày kể từ thời điểm session cuối cùng của bạn kết thúc.
Do đó, bạn có thể tránh việc xóa này bằng cách launch CloudShell trước thời gian thư mục home bị xóa [3].

Tài liệu tham khảo:

[1] https://docs.aws.amazon.com/cloudshell/latest/userguide/vm-specs.html#installing-software

Package manage utilities such as yum install programs in directories (/user/bin, for example), which are recycled when your shell session ends. This means additional software is installed and used on a per-session basis.

[2] https://docs.aws.amazon.com/cloudshell/latest/userguide/limits.html#session-lifecycle-limitations

[3] https://docs.aws.amazon.com/cloudshell/latest/userguide/limits.html#persistent-storage-limitations

If you stop using AWS CloudShell in an AWS Region, data is retained in the persistent storage of that Region for 120 days after the end of your last session. After 120 days unless you take action, your data will be automatically deleted from the persistent storage of that Region. You can prevent removal by simply launching AWS CloudShell again in that AWS Region.