CreateEnvironmentEC2 - AWS Cloud9


Creates an AWS Cloud9 development environment, launches an Amazon Elastic Compute Cloud (Amazon EC2) instance, and then connects from the instance to the environment.

Request Syntax

{ "automaticStopTimeMinutes": number, "clientRequestToken": "string", "connectionType": "string", "description": "string", "dryRun": boolean, "imageId": "string", "instanceType": "string", "name": "string", "ownerArn": "string", "subnetId": "string", "tags": [ { "Key": "string", "Value": "string" } ] }

Request Parameters

For information about the parameters that are common to all actions, see Common Parameters.

The request accepts the following data in JSON format.


The number of minutes until the running instance is shut down after the environment has last been used.

Type: Integer

Valid Range: Maximum value of 20160.

Required: No


A unique, case-sensitive string that helps AWS Cloud9 to ensure this operation completes no more than one time.

For more information, see Client Tokens in the Amazon EC2 API Reference.

Type: String

Pattern: [\x20-\x7E]{10,128}

Required: No


The connection type used for connecting to an Amazon EC2 environment. Valid values are CONNECT_SSH (default) and CONNECT_SSM (connected through Amazon EC2 Systems Manager).

For more information, see Accessing no-ingress EC2 instances with Amazon EC2 Systems Manager in the AWS Cloud9 User Guide.

Type: String


Required: No


The description of the environment to create.

Type: String

Length Constraints: Maximum length of 200.

Required: No


Checks whether you have the required permissions for the action, without actually making the request, and provides an error response. If you have the required permissions, the error response is DryRunOperation. Otherwise, it is UnauthorizedOperation.

Type: Boolean

Required: No


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 Amazon EC2 Systems Manager (SSM) path.

The default Amazon Linux AMI is currently used if the parameter isn't explicitly assigned a value in the request. Because Amazon Linux AMI has ended standard support as of December 31, 2020, we recommend you choose Amazon Linux 2, which includes long term support through 2023.

From July 1, 2022, the parameter for Amazon Linux will no longer be available when you specify an AMI for your instance. Amazon Linux 2 will then become the default AMI, which is used to launch your instance if no parameter is explicity defined.

AMI aliases

  • Amazon Linux (default): amazonlinux-1-x86_64

  • Amazon Linux 2: amazonlinux-2-x86_64

  • Ubuntu 18.04: ubuntu-18.04-x86_64

SSM paths

  • Amazon Linux (default): resolve:ssm:/aws/service/cloud9/amis/amazonlinux-1-x86_64

  • Amazon Linux 2: resolve:ssm:/aws/service/cloud9/amis/amazonlinux-2-x86_64

  • Ubuntu 18.04: resolve:ssm:/aws/service/cloud9/amis/ubuntu-18.04-x86_64

Type: String

Length Constraints: Maximum length of 512.

Required: No


The type of instance to connect to the environment (for example, t2.micro).

Type: String

Length Constraints: Minimum length of 5. Maximum length of 20.

Pattern: ^[a-z][1-9][.][a-z0-9]+$

Required: Yes


The name of the environment to create.

This name is visible to other IAM users in the same AWS account.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 60.

Required: Yes


The Amazon Resource Name (ARN) of the environment owner. This ARN can be the ARN of any IAM principal. If this value is not specified, the ARN defaults to this environment's creator.

Type: String

Pattern: ^arn:(aws|aws-cn|aws-us-gov|aws-iso|aws-iso-b):(iam|sts)::\d+:(root|(user\/[\w+=/:,.@-]{1,64}|federated-user\/[\w+=/:,.@-]{2,32}|assumed-role\/[\w+=:,.@-]{1,64}\/[\w+=,.@-]{1,64}))$

Required: No


The ID of the subnet in Amazon VPC that AWS Cloud9 will use to communicate with the Amazon EC2 instance.

Type: String

Length Constraints: Minimum length of 15. Maximum length of 24.

Pattern: ^(subnet-[0-9a-f]{8}|subnet-[0-9a-f]{17})$

Required: No


An array of key-value pairs that will be associated with the new AWS Cloud9 development environment.

Type: Array of Tag objects

Array Members: Minimum number of 0 items. Maximum number of 200 items.

Required: No

Response Syntax

{ "environmentId": "string" }

Response Elements

If the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.


The ID of the environment that was created.

Type: String

Pattern: ^[a-zA-Z0-9]{8,32}$


For information about the errors that are common to all actions, see Common Errors.


The target request is invalid.

HTTP Status Code: 400


A conflict occurred.

HTTP Status Code: 400


An access permissions issue occurred.

HTTP Status Code: 400


An internal server error occurred.

HTTP Status Code: 500


A service limit was exceeded.

HTTP Status Code: 400


The target resource cannot be found.

HTTP Status Code: 400


Too many service requests were made over the given time period.

HTTP Status Code: 400



The following example creates an AWS Cloud9 development environment with the specified settings.

Sample Request

POST / HTTP/1.1 Host: Accept-Encoding: identity Content-Type: application/x-amz-json-1.1 User-Agent: aws-cli/1.14.29 Python/3.5.2 Windows/10 botocore/1.8.33 X-Amz-Date: 20180123T224817Z Content-Length: ... Authorization: AWS4-HMAC-SHA256 Credential=AKIAJ32OEXAMPLE/20180123/us-east-2/cloud9/aws4_request, SignedHeaders=content-type;host;x-amz-date;x-amz-target, Signature=6d4c1a32EXAMPLE X-Amz-Target: AWSCloud9WorkspaceManagementService.CreateEnvironmentEC2 { "ownerArn": "arn:aws:iam::123456789012:user/MyDemoUser", "name": "my-demo-environment", "automaticStopTimeMinutes": 60, "description": "This is my demonstration environment.", "instanceType": "t2.micro", "imageId": "resolve:ssm:/aws/service/cloud9/amis/ubuntu-18.04-x86_64", "subnetId": "subnet-6300cd1b" }

Sample Response

HTTP/1.1 200 OK Date: Tue, 23 Jan 2018 22:48:20 GMT Content-Type: application/x-amz-json-1.1 Content-Length: 52 x-amzn-RequestId: 814f962e-008f-11e8-9a37-1ba143abb2EX Connection: Keep-alive { "environmentId": "8d9967e2f0624182b74e7690ad69ebEX" }

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following: