Creating an EC2 Environment - AWS Cloud9

Creating an EC2 Environment

Note

Completing this procedure might result in charges to your AWS account. These include possible charges for Amazon EC2. For more information, see Amazon EC2 Pricing.

In this procedure, AWS Cloud9 creates an EC2 environment, creates a new Amazon EC2 instance, and then connects the environment to this newly created instance. AWS Cloud9 manages this instance's lifecycle, including starting, stopping, and restarting the instance as needed. If you ever delete this environment, AWS Cloud9 automatically terminates this instance.

You can create an AWS Cloud9 EC2 development environment with the AWS Cloud9 console or with code.

Prerequisites

Complete the steps in Setting up AWS Cloud9 so that you can sign in to the AWS Cloud9 console and create environments.

Create an EC2 environment with the console

  1. Sign in to the AWS Cloud9 console as follows:

  2. After you sign in to the AWS Cloud9 console, in the top navigation bar, choose an AWS Region to create the environment in. For a list of available AWS Regions, see AWS Cloud9 in the AWS General Reference.

    
                AWS Region selector in the AWS Cloud9 console
  3. Choose the large Create environment button in one of the locations shown below.

    If you have no AWS Cloud9 environments yet, the button is shown on a welcome page.

    
                Welcome page in the AWS Cloud9 console

    If you already have AWS Cloud9 environments, the button is shown as follows.

    
                Create environment button in the AWS Cloud9 console
  4. On the Name environment page, for Name, enter a name for your environment.

  5. To add a description to your environment, enter it in Description.

  6. Choose Next step.

  7. On the Configure settings page, for Environment type, choose one of the following options to create an EC2-backed environment:

    • Create a new EC2 instance for environment (direct access) – Launches an Amazon EC2 instance that AWS Cloud9 can connect to directly over SSH.

    • Create a new no-ingress EC2 instance for environment (access via Systems Manager) – Launches an Amazon EC2 instance that doesn't require any open inbound ports. AWS Cloud9 connects to the instance through AWS Systems Manager.

      • If you select the access via Systems Manager option, a service role and an IAM instance profile are automatically created to allow Systems Manager to interact with the EC2 instance on your behalf. You can view the names of both in the Service role and instance profile for Systems Manager access section further down the interface. For more information, see Accessing no-ingress EC2 instances with AWS Systems Manager.

    Warning

    Creating an EC2 instance for your environment might result in possible charges to your AWS account for Amazon EC2. There is no additional cost to use Systems Manager to manage connections to your EC2 instance.

  8. For Instance type, choose an instance type with the amount of RAM and vCPUs you think you need for the kinds of tasks you want to do.

    Warning

    Choosing instance types with more RAM and vCPUs might result in additional charges to your AWS account for Amazon EC2.

  9. For Platform, choose the type of Amazon EC2 instance that you want: Amazon Linux, Amazon Linux 2, or Ubuntu. AWS Cloud9 creates the instance and then connects the environment to it.

    Important

    We recommend that you choose the Amazon Linux 2 option for your EC2 environment. As well as providing a secure, stable, and high-performance execution environment for developing and running cloud and enterprise applications, Amazon Linux 2 AMI includes long-term support through 2023.

    The older Amazon Linux AMI will end-of-life its standard support on December 31, 2020 and enter a maintenance support phase. For more information, see the Amazon Linux 2 page.

  10. Choose a value for Cost-saving setting. When all web browser instances that are connected to the IDE for the environment are closed, AWS Cloud9 waits this amount of time and then shuts down the Amazon EC2 instance for the environment.

    Warning

    Choosing a longer time period might result in more charges to your AWS account.

  11. Expand Network settings (advanced).

  12. AWS Cloud9 uses Amazon Virtual Private Cloud (Amazon VPC) to communicate with the newly created Amazon EC2 instance. Depending on how Amazon VPC is set up, do one of the following.

    If you're not sure what to choose, we recommend that you skip ahead to the next step in this procedure.

    When you skip past Network settings (advanced) and leave the preselected default settings, AWS Cloud9 attempts to automatically use the default VPC with its single subnet in the same AWS account and AWS Region as the new environment.

    Note

    If you selected Create a new no-ingress EC2 instance for environment (access via Systems Manager), an information icon is displayed beside the Create new VPC button. If you pause on the icon, a message states that "For a no-ingress EC2 instance, attach an internet gateway to your new VPC so the instance's SSM Agent can connect to Systems Manager."

    For more information, see VPC settings for AWS Cloud9 Development Environments.

    Does the AWS account have access to an Amazon VPC? Is that VPC in the same AWS account and AWS Region as the new environment? Is that VPC the default VPC for its AWS account? Does that VPC contain a single subnet? Do this

    No

    If no VPC exists, create one.

    To create a VPC in the same AWS account and AWS Region as the new environment, choose Create new VPC, and then follow the on-screen directions. For more information, see Create an Amazon VPC for AWS Cloud9.

    To create a VPC in a different AWS account than the new environment, see Working with Shared VPCs in the Amazon VPC User Guide.

    Yes

    Yes

    Yes

    Yes

    Skip ahead to the next step in this procedure.

    When you skip past Network settings (advanced) and leave the preselected default settings, AWS Cloud9 attempts to automatically use the default VPC with its single subnet in the same account and Region as the new environment.

    Yes

    Yes

    Yes

    No

    If the default VPC has multiple subnets, expand Network settings (advanced). For Subnet, choose the subnet you want AWS Cloud9 to use in the preselected default VPC.

    If the default VPC has no subnets, create one. To do this, choose Create new subnet, and then follow the on-screen directions. For more information, see Create a subnet for AWS Cloud9.

    Yes

    Yes

    No

    Yes

    Expand Network settings. For Network (VPC), choose the VPC that you want AWS Cloud9 to use.

    Yes

    Yes

    No

    No

    Expand Network settings. For Network (VPC), choose the VPC that you want AWS Cloud9 to use.

    If the chosen VPC has multiple subnets, expand Network settings (advanced). For Subnet, choose the subnet you want AWS Cloud9 to use in the chosen VPC.

    If the chosen VPC has no subnets, create one. To do this, choose Create new subnet, and then follow the on-screen directions. For more information, see Create a subnet for AWS Cloud9.

    Yes

    No

    Yes

    AWS Cloud9 cannot use a default VPC in an AWS account than is different than the AWS account for the new environment. Choose a different option in this list.

    Yes

    No

    No

    Yes

    Expand Network settings. For Network (VPC), choose the VPC that you want AWS Cloud9 to use.

    Note

    The VPC must be in the same AWS Region as the new environment, even if the VPC is in a different AWS account.

    Yes

    No

    No

    No

    Expand Network settings. For Network (VPC), choose the VPC that you want AWS Cloud9 to use.

    For Subnet, choose the subnet you want AWS Cloud9 to use in the chosen VPC.

    If the chosen VPC has no subnets, to create a subnet for a VPC in a different AWS account than the new environment, see Working with Shared VPCs in the Amazon VPC User Guide.

    Note

    The VPC and subnet must be in the same AWS Region as the new environment, even if the VPC and subnet are in a different AWS account.

    For more information about these choices, see VPC settings for AWS Cloud9 Development Environments.

  13. Add up to 50 tags by supplying a Key and a Value for each tag. The tags will be attached to the AWS Cloud9 environment as resource tags, and are propagated to the following underlying resources: the AWS CloudFormation stack, the Amazon EC2 instance, and Amazon EC2 security groups. You can find information about tags in Control Access Using AWS Resource Tags in the IAM User Guide. Also see the advanced information about tags.

    Warning

    If you update these tags after you create them, the changes are NOT automatically propagated to the underlying resources. For more information, see Propagating Tag Updates to Underlying Resources in the advanced information about tags.

  14. Choose Next step.

  15. On the Review page, choose Create environment. Wait while AWS Cloud9 creates your environment. This can take several minutes.

    Note

    If account creation fails, a banner is displayed at the top of the console page. Additionally, the card for the environment, if it exists, indicates that environment creation failed.

After AWS Cloud9 creates your environment, it displays the AWS Cloud9 IDE for the environment.

If AWS Cloud9 doesn't display the IDE after at least five minutes, there might be a problem with your web browser, your AWS access permissions, the instance, or the associated virtual private cloud (VPC). For possible fixes, see Cannot open an environment in Troubleshooting.

Creating an environment with code

To use code to create an EC2 environment in AWS Cloud9, call the AWS Cloud9 create EC2 environment operation, as follows.

Important

Currently, only environments connected to Amazon Linux can be created with code. You can't use code to create an Amazon Linux 2-based or an Ubuntu Server-based EC2 environment. (Creating an environment with code refers to using the AWS CLI, AWS CloudFormation, the AWS SDKs, the AWS Tools for PowerShell, or the AWS Cloud9 API.)

We're planning code-creation support for Amazon Linux 2 and are evaluating support for Ubuntu Server. In the meantime, for EC2 environments backed by Amazon Linux 2 or Ubuntu Server, use the console option.