Trace EC2 Console Activity in Multiple Code Format Using AWS Console-to-Code
Tags: aws, awsec2instance, awscloudwatch, awsconsoletocode
Published: 2024-01-06 15:50:56

“ I have checked the documents of AWS to trace ec2 console activity. So I found out that it can be possible using aws console-to-code(a feature of ec2 console). Pricing of Amazon EC2 depends on usage of instance and AWS Console-to-Code cost is free of charge. This service feature is available in the N.Virginia region only for now.”

AWS Console-to-Code is a generative AI capability that makes it simple, fast and cost-effective to move from prototyping on the AWS Management Console to deploying production code for your workloads. Customers can now generate code for their console actions in their preferred format. The code helps customers get started and bootstrap their automation pipelines for their workloads tasks.

It makes it easy to convert actions performed in the console to reusable code, in the language of your choice. It automatically captures your actions and workflows and in a few simple clicks, generates code for it.

In this post, you will get to know how to trace ec2 console activity in multiple code format using aws console-to-code. Here I have used an ec2 server with a detailed monitoring option enabled and console-to-code feature to trace and record the ec2 console activity.

#Architecture Overview
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x7dz1qqbz9x4jwcrq8lo.png)
The architecture diagram shows the overall deployment architecture with data flow, amazon ec2 and aws console-to-code.

#Solution overview
The blog post consists of the following phases:
1. Launch of EC2 Instance with Detailed Monitoring Enabled
2. Output of Code and CLI Commands for EC2 Instance Console Activity in Multiple Format

##Phase 1: Launch of EC2 Instance with Detailed Monitoring Enabled
1. Open the ec2 console and launch an ec2 instance with default parameters. Also enable detailed monitoring option.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ww2g0vjps57vxzmdeddc.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8285h3mztpyje3tq8qq0.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7mb26t9hpkggzu3b59ig.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3apbhqpgferca0iww1xd.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9d5n89vw142wdg7y94p5.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/742d5lfmygfmhhx2hkub.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wjke79u2zjt18hg8457p.png)

##Phase 2: Output of Code and CLI Commands for EC2 Instance Console Activity in Multiple Format
1. The code can be used for the automation process for launching the same parameter instance again in other environments.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/22sizjzp3nvsoxayy4ug.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5f46pxb81z0vks2kh1pw.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tfaals8gava6r4xsm8r7.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kaoywgy019oywf8si0gv.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x8zu016p2q1j4zax6hhc.png)

#Clean-up
Delete EC2 Instance.

#Pricing
I review the pricing and estimated cost of this example. 

Cost of EC2 Instance = $0.09

Cost of AWS Console-to-code = $0.0

Total Cost = $(0.09 + 0.0) = $0.09

#Summary
In this post, I showed “how to trace ec2 console activity in multiple code format using aws console-to-code”.

For more details on AWS Console-to-code, Checkout Get started AWS Console-to-code, open the [AWS Console-to-code console](https://us-east-1.console.aws.amazon.com/ec2/home?region=us-east-1#console-to-code:). To learn more, read the [AWS Console-to-code documentation](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/console-to-code.html#use-console-to-code-gif).

Thanks for reading!

Connect with me: [Linkedin](https://www.linkedin.com/in/gargee-bhatnagar-6b7223114)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/38sdi4nsp89fnui8h7dk.png)