Generate code for your console actions using Console-to-Code - Amazon Elastic Compute Cloud

Generate code for your console actions using Console-to-Code

Console-to-Code is in preview release for Amazon EC2 and is subject to change. Available only in the US East (N. Virginia) Region.

The console provides a guided path for creating resources and testing prototypes. If you want to create the same resources at scale, you’ll need automation code. Console-to-Code is a feature of the Amazon EC2 console that can help you get started with your automation code. Console-to-Code records your console actions, including default values and compatible parameters. It then uses generative AI to suggest code in your preferred infrastructure-as-code (IaC) format for the actions you want. You can use the code as a starting point, customizing it to make it production-ready for your specific use case.

There is no additional cost for using Console-to-Code.

How it works

Console-to-Code can help you get started with your automation code, as follows:

  1. You perform actions in the console, such as launching an instance or enabling detailed monitoring.

  2. Console-to-Code records all your actions, including all the default settings and compatible parameters that the console provides.

  3. You choose the actions that you want to use in your automation scripts. These can be mutating or read-only (non-mutating) actions, or both types of actions.

  4. Console-to-Code generates code in your desired infrastructure-as-code (IaC) format, for example, TypeScript.

  5. You copy the code to use in your code development tool or download it to share.

  6. You then use the code as a starting point for your automation scripts. You'll need to validate that the code meets your intent and that the parameters will configure your resources as expected. You'll need to customize the code to make it production-ready for your use case. Once you're satisfied with the code, you can use it in your automation scripts.

For the instructions on how to use Console-to-Code in the Amazon EC2 console, see Use Console-to-Code.

Limitations

The following limitations apply when using Console-to-Code.

Supported Regions

Currently only available in the US East (N. Virginia) Region.

Supported code formats

Console-to-Code can currently generate infrastructure-as-code (IaC) in the following code formats:

  • CDK Java

  • CDK Python

  • CDK TypeScript

  • CloudFormation JSON

  • CloudFormation YAML

Retained actions

  • Current session: Only actions taken during the current session are displayed in the Recorded actions table. Actions taken during previous sessions are not retained.

  • Browser refresh: Recorded actions are lost when you refresh the browser tab.

  • Tab isolation: The Recorded actions table is specific to the browser tab in which the actions were taken. Actions performed in one tab are not visible in the Recorded actions table in another tab.

Recorded actions table

The following table lists and describes the columns in the Recorded actions table in the Console-to-Code console.

Column title Description
Console page

The console page on which the action was performed.

Operation

The API operation.

Type

The type of action.

  • Mutating – API actions that create, modify, or delete resources.

  • Read only – API actions that retrieve data about resources (generally all Describe* actions).

CLI command

Details about the action that was taken, including the parameters and values.

Creation time

The time the action was taken.

Use Console-to-Code

Use the following instructions to generate code using Console-to-Code in the Amazon EC2 console.

To view an animation of these steps, see View an animation: Generate code using Console-to-Code in the Amazon EC2 console.

To generate code using Console-to-Code
  1. Open the Amazon EC2 console in the US East (N. Virginia) Region at https://console.aws.amazon.com/ec2/home?region=us-east-1.

    Note

    Console-to-Code is in preview release and currently only available in the US East (N. Virginia) Region. Only actions performed in this Region will be recorded.

  2. Use the console to create resources and test prototypes. For example, use the console to configure and launch instances and enable detailed monitoring.

    Console-to-Code records every action that you perform.

  3. In the left navigation pane, choose Console-to-Code.

  4. In the Recorded actions table, review your actions that were recorded, and decide which actions to include for code generation.

    • Use the search field to filter the table by a specific console page or action. As you start to type, the table is filtered.

    • Use the Type drop-down to filter by all actions, mutating actions, or read-only actions.

    Note

    Only actions taken during the current session are listed. For more information, see Retained actions.

  5. Select the check box next to each action for which you require code to be generated.

    Note

    Up to 5 actions can be selected at one time.

  6. Choose the Generate {code} code button.

    The button label defaults to the last-selected code format. To select a different code format, choose the arrow next to the button.

  7. Under Review code, choose Copy to copy the code to use in your development tool or Download to download the file for sharing.

  8. Use the code as a starting point for your infrastructure-as-code. You'll need to customize the code to make it production-ready for your specific use case.

    Note

    If you find that the code is not production ready, please provide us with feedback on how it can be improved (see the following step 9). AWS Support can’t assist you with the generated code or your customized code development.

  9. (Optional) Choose the thumbs-up or thumbs-down to let us know if Console-to-Code helped. If you choose the thumbs-down, you can then choose Provide feedback to tell us how we can improve the code to better help you.

This animation shows how to generate code using Console-to-Code in the Amazon EC2 console. For the text version of this animation, see the steps in the preceding procedure.