How can I view files in EC2 instance? - amazon-web-services

I have just started learning about AWS. I am following along a tutorial and I have created a hello.txt file in EC2 using PuTTY on Windows. I wanted to know where I can see all the files listed in the EC2 instance on a GUI. I believe they are not stored locally on my computer; but I cannot find them on the AWS console either? Thank you.
PuTTY console screenshot

After some more AWS training, I found out that I can also see the files and folders in my EC2 instance in a "GUI" format using the Fleet Manager in AWS Systems Manager. The Systems Manager Agent must be installed in the EC2 instance and the instance must be given the appropriate permissions using IAM.

I wanted to know where I can see all the files listed in the EC2 instance on a GUI
Short answer:
Using a Windows PC to access an AWS EC2 you use PuTTY to navigate the file system. The hello.txt file you created is listed.
To open it you can do a cat hello.txt.
Official Answer:
https://aws.amazon.com/premiumsupport/knowledge-center/ec2-linux-2-install-gui/
The instructions get you to install the MATE desktop environment, a lightweight GUI based on GNOME 2 available as an extra for Amazon Linux 2.

Related

Invoking Windows EC2 terminal remotely

I need to connect to my Windows EC2 terminal to invoke a local script on it from a different machine CMD.
I tried to search and I 'v found the following: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Connect-using-EC2-Instance-Connect.html. This solves the problem for Linux, not windows. Any suggestion or lead for a solution?
On Windows machines, you can remotely SSH onto your EC2 instance using a bash shell, which supports SSH.
If you have git bash installed, it can do the trick for you.
You will need the pem file which you can generate before launching your EC2 instance, at the very last step. Else, you can also use your own key - see docs from AWS here.
You can look into the option of session manager.
Please refer: https://docs.aws.amazon.com/systems-manager/latest/userguide/session-manager.html
To give you a brief, Session Manager is a fully managed AWS Systems Manager capability that lets you manage your Amazon EC2 instances, on-premises instances, and virtual machines (VMs) through an interactive one-click browser-based shell or through the AWS CLI.

Programmatically Download RDP file from AWS once a EC2 instance its launch with it java sdk

There are a few things I require help on, I am currently working with AWS ec2 instances. I have successfully started a server using an Image I have created in AWS and launch the image to multiple instances with the help of the Java SDK. To let me access these instances that I have launched, I understand that in the aws console I am able to get RDP File when I click on download Remote Desktop File when I click on the instance but I am checking if the java SDK provides a way to get the RDP file directly without having me to go into the console.

Creating an iso of a RHEL instance

I have an amazon ec2 instance with RHEL 7.3 on it. I would like to convert this into an iso so that I can migrate it wherever I want. What are the best tools to create an iso of a virtual machine. Or how do I clone/backup this VM so that I can restore it anywhere I want?
You can work with VM and AWS programatically via AWS CLI commands.
You want to get familiar with import-task and export-task commands.
The best place to start is by reading an official AWS guides for:
Exporting an Instance as a VM Using VM Import/Export
Importing a VM as an Image Using VM Import/Export
The key information you need to pick up from the guide is this quote:
"You can't export an instance from Amazon EC2 unless you previously
imported it into Amazon EC2 from another virtualization environment."
Yes, there are solutions, one of them linked by #Nicholas Smith. That being said, if you go the unofficial route you might end up in a dark alley where help might not be available. I highly recommend and warn here to not proceed with trying to clone EC2 into VM at this point. You will spend a lot of time with a huge risk factor for future.
For you to be able to achieve what you want, you need to create a RHEL VM using any VM software, you need to load this VM into AWS and then you will be able to work with VM in AWS making any necessary changes and export again for local or transportation needs.
As you are running a widely-used Linux distribution - RHEL, you can attempt to recreate your EC2 environment manually by launching a VM that runs the same kernel version along with the same package versions. From there, you can tarball what files you need from your production instance and copy them over to your on-premise site by using SCP/SFTP.
Just get your RHEL environment into VM locally and import to AWS and you set.
Clonezilla provides functionality to create images. Generated images can be converted to ISO files.
It doesn't seem to be something that Amazon promote as a service however the aws cli tools have an ec2-unbundle command for extracting from an AMI. There's a guide here on how to download and run an EC2 AMI locally by using it.
Caveat is it appears the ec2-unbundle command currently only works on Linux and not OS X or Windows.

Amazon EC2 Instance - Where to add the credentials file?

I have an Amazon EC2 Instance. On my Instance I want to run a python program. The program tries to access other amazon services. On my Mac the program worked fine, because the credentials file is in the folder "~/.aws/credentials". But I don't know where on my amazon EC2 instance the library "~" is. So where do I have to put my credentials? Hope you can help me.
~ is a shortcut for your home directory. Just go into that directory using the command cd ~. This is the directory you will always start in when you SSH into your server.
Alternatively you could install the AWS CLI and run aws configure. If you are using Amazon Linux then the AWS CLI tool is already installed.
Also, storing credentials on your EC2 instance is not the preferred method. You should look into using EC2 instance profiles.

Creating amazon ec2 windows AMIs using amazon sdk in java

I am writing an application which would enable my company's future clients to be able to launch Amazon aws instances with Windows OS. Hence, I would want to create windows AMIs first. The article below gives a step by step approach for creating EBS-backed windows AMIs using Amazon AWS console.
http://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/Creating_EBSbacked_WinAMI.html
But when I tried looking up the methods provided by CreateImageRequest API provided by Amazon SDK, I couldn't quite figure out how to replicate the AWS management console process for creating a windows image in Java. I exhausted my google searches and I came up empty. Has anyone tried this? Is this even possible at all to create Windows images through Amazon SDK?
I found that CreateInstanceRequest API has an option to specify the OS types but the options are limited to Amazon Linux or Ubuntu 12.04 LTS. The documentation for CreateInstanceRequest is below:
http://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/com/amazonaws/services/opsworks/model/CreateInstanceRequest.html
I would appreciate any useful link or code snippet. Thanks.
I don't completely understand what you are trying to achieve.
Do you want to start an instance in EC2 or with OpsWorks because your second link points to the OpsWorks documentation.
OpsWorks dosen't support Windows right now.