Step 1: Create an environment - AWS Cloud9

Step 1: Create an environment

(First step of Tutorial: Hello AWS Cloud9 (CLI))

In this step, you use the AWS CLI to create an AWS Cloud9 development environment.

In AWS Cloud9, a development environment, or environment, is somewhere where you store your development project's files and run the tools to develop your applications. In this tutorial, you create an EC2 environment, and work with the files and tools in that environment.

Create an EC2 environment with the AWS CLI

  1. Install and configure the AWS CLI, if you have not done so already. To do this, see the following in the AWS Command Line Interface User Guide:

    You can configure the AWS CLI using credentials for one of the following:

    • The IAM user you created in Team setup for AWS Cloud9.

    • An IAM administrator in your AWS account, if you will be working regularly with AWS Cloud9 resources for multiple users across the account. If you cannot configure the AWS CLI as an IAM administrator, check with your AWS account administrator. For more information, see Creating your first IAM admin user and group in the IAM User Guide.

    • An AWS account root user, but only if you will always be the only one using your own AWS account, and you don't need to share your environments with anyone else. We don't recommend this option as it isn't an AWS security best practice. For more information, see Creating, Disabling, and Deleting Access Keys for Your AWS Account in the Amazon Web Services General Reference.

    • For other options, see your AWS account administrator or classroom instructor.

  2. In the following AWS Cloud9 command, provide a value for --region and --subnet-id. Then run the command and make a note of the "environmentId" value for later cleanup.

    aws cloud9 create-environment-ec2 --name my-demo-environment --description "This environment is for the AWS Cloud9 tutorial." --instance-type t2.micro --image-id resolve:ssm:/aws/service/cloud9/amis/amazonlinux-2-x86_64 --region MY-REGION --connection-type CONNECT_SSM --subnet-id subnet-12a3456b

    In the preceding command:

    • --name represents the name of the environment. In this tutorial, we use the name my-demo-environment.

    • --description represents an optional description for the environment.

    • --instance-type represents the type of Amazon EC2 instance AWS Cloud9 will launch and connect to the new environment. This example specifies t2.micro, which has relatively low RAM and vCPUs and is sufficient for this tutorial. Specifying instance types with more RAM and vCPUs might result in additional charges to your AWS account for Amazon EC2. For a list of available instance types, see the create environment wizard in the AWS Cloud9 console.

    • --image-id specifies the identifier for the Amazon Machine Image (AMI) that's used to create the EC2 instance. To choose an AMI for the instance, you must specify a valid AMI alias or a valid AWS Systems Manager (SSM) path. In the example above, an SSM path for an Amazon Linux 2 AMI is specified.

      For more information, see create-environment-ec2 in the AWS CLI Command Reference.

    • --region represents the ID of the AWS Region for AWS Cloud9 to create the environment in. For a list of available AWS Regions, see AWS Cloud9 in the Amazon Web Services General Reference.

    • --connection-type CONNECT_SSM specifies that AWS Cloud9 connects to its Amazon EC2 instance through Systems Manager. This option ensures no inbound traffic to the instance is allowed. For more information, see Accessing no-ingress EC2 instances with AWS Systems Manager.

      Note

      When using this option, you need to create the AWSCloud9SSMAccessRole service role and AWSCloud9SSMInstanceProfile if they aren't already created. For more information, see Managing instance profiles for Systems Manager with the AWS CLI.

    • --subnet-id represents the subnet you want AWS Cloud9 to use. Replace subnet-12a3456b with the ID of the subnet of an Amazon Virtual Private Cloud (VPC), which must be compatible with AWS Cloud9. For more information, see Create a VPC plus other VPC resources in VPC settings for AWS Cloud9 Development Environments.

    • AWS Cloud9 shuts down the Amazon EC2 instance for the environment after all web browser instances that are connected to the IDE for the environment have been closed. To configure this time period, add --automatic-stop-time-minutes and the number of minutes. A shorter time period might result in fewer charges to your AWS account. Likewise, a longer time might result in more charges.

    • By default, the entity that calls this command owns the environment. To change this, add --owner-id and the Amazon Resource Name (ARN) of the owning entity.

  3. After you successfully run this command, open the AWS Cloud9 IDE for the newly created environment. To do this, see Opening an environment in AWS Cloud9. Then return to this topic and continue with Step 2: Basic tour of the IDE to learn how to use the AWS Cloud9 IDE to work with your new environment.

    If you try to open the environment, but 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 VPC. For possible fixes, see Can't open an environment.

Next Step

Step 2: Basic tour of the IDE