When searching the internet looking for ways of exporting Amazon EC2 instances running within an AWS account, you will get results mostly referencing some CLI or JSON scripts. Well, if you are not into CLI or JSON, you can accomplish the same goals using the newly added AWS Systems Manager Operations Management feature called – Explorer. This post will walk you through the step by step process to export the EC2 instances running within an AWS account or an entire AWS Organization and linked accounts. The results are stored in Amazon S3 bucket as a CSV file that can be downloaded. Click on the links to read more about AWS Systems Manager announcement and AWS Systems Manager documentation.
Go ahead and get these prerequisites ready prior to configuring Systems Manager Explorer.
- Create or use an existing Amazon S3 bucket. The OpsData queries are exported as comma-seperated value (CSV) files to this Amazon S3 bucket.
- Enable AWS Config recording. If config is not yet enabled on the account, go ahead and enable it and use the default settings. No rules are required for Explorer. This is require to enable EC2 instance recording to record and view data for the OpsData EC2 instance source.
- Create an Amazon SNS topic to notify when the export completes
- Optionally, Enable and Opt-in for Computer Optimizer if you need to also get compute optimize data for the EC2 instances.
Once the prerequisites and ready, follow the steps below to configure Explorer and Export EC2 instances.
- Go to AWS Systems Manager
- Under Operations Management, click on Explorer
- Click on Getting started and use the default settings in the Explorer setup page.
- If Config and/or Computer Optimizer is not ready, you will see something similar to the below screenshot. Stop and go configure or check on this items as stated in prerequisites.
- This is what you should see if those items are properly enabled/configured.
- Click on Enable Explorer(located bottom right)
- Click on Created resource data sync
- Give a friendly name to identify this data sync and select accounts as appropriate. For individual accounts, the Organization options are not available.
- Select the region(s) that you want this data sync to cover.
- Click on create resource data sync (bottom right)
- Navigate to AWS Systems Manager, Explorer, and click on Settings (upper right) and validate that all the required sources are set to enabled. If not, click on Edit to disable/enable as needed. For EC2 export, the Amazon EC2 must be Enabled.
- Navigate to AWS Systems Manager, Explorer and under OpsData Filter, use the drop down to select the data sync that you created in step 8.
- Within the Explorer dashboard, navigate to Instance Count.
- For individual AWS account, you will see something similar to below screenshot. The number if total number of EC2 instances running for this account across the regions that were selected for this data sync configuration.
- If this was enabled at the AWS Organization level, you will see something similar to below screenshot. The Groups section shows the AWS accounts – master and linked, for the organization with the respective EC2 counts.
- Click on the number below the Instance count to view the discovered EC2 instance opsData.
- Click on Export.
- In the Export Data as CSV pop up box, enter select the S3 bucket and SNS topic that was created in the prerequisites. Enter an optional SNS topic message and click Export.
- Click on Status to open the Execution detail. If both the Execution and Execution steps show Success, then data have been successfully exported to the S3 bucket.
- Navigate to Amazon S3, select the desired bucket, click on the csv file, click on the object URL and download/download as.
- Here is a sample EC2 instance data file in CSV/Excel.
If this was useful, please leave a comment. The AWS Systems Manager Explorer has some additional great features that you may want to explore.