

# CreateEnvironmentEC2
<a name="API_CreateEnvironmentEC2"></a>

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

**Important**  
 AWS Cloud9 is no longer available to new customers. Existing customers of AWS Cloud9 can continue to use the service as normal. [Learn more"](http://aws.amazon.com/blogs/devops/how-to-migrate-from-aws-cloud9-to-aws-ide-toolkits-or-aws-cloudshell/) 

## Request Syntax
<a name="API_CreateEnvironmentEC2_RequestSyntax"></a>

```
{
   "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
<a name="API_CreateEnvironmentEC2_RequestParameters"></a>

For information about the parameters that are common to all actions, see [Common Parameters](CommonParameters.md).

The request accepts the following data in JSON format.

 ** [automaticStopTimeMinutes](#API_CreateEnvironmentEC2_RequestSyntax) **   <a name="cloud9-CreateEnvironmentEC2-request-automaticStopTimeMinutes"></a>
The number of minutes until the running instance is shut down after the environment has last been used.  
Type: Integer  
Valid Range: Minimum value of 0. Maximum value of 20160.  
Required: No

 ** [clientRequestToken](#API_CreateEnvironmentEC2_RequestSyntax) **   <a name="cloud9-CreateEnvironmentEC2-request-clientRequestToken"></a>
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](https://docs.aws.amazon.com/AWSEC2/latest/APIReference/Run_Instance_Idempotency.html) in the *Amazon EC2 API Reference*.  
Type: String  
Pattern: `[\x20-\x7E]{10,128}`   
Required: No

 ** [connectionType](#API_CreateEnvironmentEC2_RequestSyntax) **   <a name="cloud9-CreateEnvironmentEC2-request-connectionType"></a>
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](https://docs.aws.amazon.com/cloud9/latest/user-guide/ec2-ssm.html) in the * AWS Cloud9 User Guide*.  
Type: String  
Valid Values: `CONNECT_SSH | CONNECT_SSM`   
Required: No

 ** [description](#API_CreateEnvironmentEC2_RequestSyntax) **   <a name="cloud9-CreateEnvironmentEC2-request-description"></a>
The description of the environment to create.  
Type: String  
Length Constraints: Maximum length of 200.  
Required: No

 ** [dryRun](#API_CreateEnvironmentEC2_RequestSyntax) **   <a name="cloud9-CreateEnvironmentEC2-request-dryRun"></a>
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

 ** [imageId](#API_CreateEnvironmentEC2_RequestSyntax) **   <a name="cloud9-CreateEnvironmentEC2-request-imageId"></a>
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.  
  
We recommend using Amazon Linux 2023 as the AMI to create your environment as it is fully supported.  
From December 16, 2024, Ubuntu 18.04 will be removed from the list of available `imageIds` for AWS Cloud9. This change is necessary as Ubuntu 18.04 has ended standard support on May 31, 2023. This change will only affect direct API consumers, and not AWS Cloud9 console users.  
Since Ubuntu 18.04 has ended standard support as of May 31, 2023, we recommend you choose Ubuntu 22.04.  
 **AMI aliases **   
+ Amazon Linux 2: `amazonlinux-2-x86_64` 
+ Amazon Linux 2023 (recommended): `amazonlinux-2023-x86_64` 
+ Ubuntu 22.04: `ubuntu-22.04-x86_64` 
 **SSM paths**   
+ Amazon Linux 2: `resolve:ssm:/aws/service/cloud9/amis/amazonlinux-2-x86_64` 
+ Amazon Linux 2023 (recommended): `resolve:ssm:/aws/service/cloud9/amis/amazonlinux-2023-x86_64` 
+ Ubuntu 22.04: `resolve:ssm:/aws/service/cloud9/amis/ubuntu-22.04-x86_64` 
Type: String  
Length Constraints: Maximum length of 512.  
Required: Yes

 ** [instanceType](#API_CreateEnvironmentEC2_RequestSyntax) **   <a name="cloud9-CreateEnvironmentEC2-request-instanceType"></a>
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

 ** [name](#API_CreateEnvironmentEC2_RequestSyntax) **   <a name="cloud9-CreateEnvironmentEC2-request-name"></a>
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

 ** [ownerArn](#API_CreateEnvironmentEC2_RequestSyntax) **   <a name="cloud9-CreateEnvironmentEC2-request-ownerArn"></a>
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

 ** [subnetId](#API_CreateEnvironmentEC2_RequestSyntax) **   <a name="cloud9-CreateEnvironmentEC2-request-subnetId"></a>
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

 ** [tags](#API_CreateEnvironmentEC2_RequestSyntax) **   <a name="cloud9-CreateEnvironmentEC2-request-tags"></a>
An array of key-value pairs that will be associated with the new AWS Cloud9 development environment.  
Type: Array of [Tag](API_Tag.md) objects  
Array Members: Minimum number of 0 items. Maximum number of 200 items.  
Required: No

## Response Syntax
<a name="API_CreateEnvironmentEC2_ResponseSyntax"></a>

```
{
   "environmentId": "string"
}
```

## Response Elements
<a name="API_CreateEnvironmentEC2_ResponseElements"></a>

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

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

 ** [environmentId](#API_CreateEnvironmentEC2_ResponseSyntax) **   <a name="cloud9-CreateEnvironmentEC2-response-environmentId"></a>
The ID of the environment that was created.  
Type: String  
Pattern: `^[a-zA-Z0-9]{8,32}$` 

## Errors
<a name="API_CreateEnvironmentEC2_Errors"></a>

For information about the errors that are common to all actions, see [Common Error Types](CommonErrors.md).

 ** BadRequestException **   
The target request is invalid.  
HTTP Status Code: 400

 ** ConflictException **   
A conflict occurred.  
HTTP Status Code: 400

 ** ForbiddenException **   
An access permissions issue occurred.  
HTTP Status Code: 400

 ** InternalServerErrorException **   
An internal server error occurred.  
HTTP Status Code: 500

 ** LimitExceededException **   
A service limit was exceeded.  
HTTP Status Code: 400

 ** NotFoundException **   
The target resource cannot be found.  
HTTP Status Code: 400

 ** TooManyRequestsException **   
Too many service requests were made over the given time period.  
HTTP Status Code: 400

## Examples
<a name="API_CreateEnvironmentEC2_Examples"></a>

### Example
<a name="API_CreateEnvironmentEC2_Example_1"></a>

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

#### Sample Request
<a name="API_CreateEnvironmentEC2_Example_1_Request"></a>

```
POST / HTTP/1.1
Host: cloud9.<region>.amazonaws.com
Accept-Encoding: identity
Content-Type: application/x-amz-json-1.1
User-Agent: <UserAgentString>
X-Amz-Date: <Date>
Content-Length: <PayloadSizeBytes>
Authorization: AWS4-HMAC-SHA256 Credential=<Credential>, SignedHeaders=<Headers>, Signature=<Signature>
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/amazonlinux-2023-x86_64",
  "subnetId": "subnet-6300cd1b"
}
```

#### Sample Response
<a name="API_CreateEnvironmentEC2_Example_1_Response"></a>

```
HTTP/1.1 200 OK
Date: <Date>
Content-Type: application/x-amz-json-1.1
Content-Length: <PayloadSizeBytes>
x-amzn-RequestId: <RequestId>
Connection: Keep-alive

{
  "environmentId": "8d9967e2f0624182b74e7690ad69ebEX"
}
```

## See Also
<a name="API_CreateEnvironmentEC2_SeeAlso"></a>

For more information about using this API in one of the language-specific AWS SDKs, see the following:
+  [AWS Command Line Interface V2](https://docs.aws.amazon.com/goto/cli2/cloud9-2017-09-23/CreateEnvironmentEC2) 
+  [AWS SDK for .NET V4](https://docs.aws.amazon.com/goto/DotNetSDKV4/cloud9-2017-09-23/CreateEnvironmentEC2) 
+  [AWS SDK for C\$1\$1](https://docs.aws.amazon.com/goto/SdkForCpp/cloud9-2017-09-23/CreateEnvironmentEC2) 
+  [AWS SDK for Go v2](https://docs.aws.amazon.com/goto/SdkForGoV2/cloud9-2017-09-23/CreateEnvironmentEC2) 
+  [AWS SDK for Java V2](https://docs.aws.amazon.com/goto/SdkForJavaV2/cloud9-2017-09-23/CreateEnvironmentEC2) 
+  [AWS SDK for JavaScript V3](https://docs.aws.amazon.com/goto/SdkForJavaScriptV3/cloud9-2017-09-23/CreateEnvironmentEC2) 
+  [AWS SDK for Kotlin](https://docs.aws.amazon.com/goto/SdkForKotlin/cloud9-2017-09-23/CreateEnvironmentEC2) 
+  [AWS SDK for PHP V3](https://docs.aws.amazon.com/goto/SdkForPHPV3/cloud9-2017-09-23/CreateEnvironmentEC2) 
+  [AWS SDK for Python](https://docs.aws.amazon.com/goto/boto3/cloud9-2017-09-23/CreateEnvironmentEC2) 
+  [AWS SDK for Ruby V3](https://docs.aws.amazon.com/goto/SdkForRubyV3/cloud9-2017-09-23/CreateEnvironmentEC2) 