CreateEnvironmentEC2
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"
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.
- automaticStopTimeMinutes
-
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
-
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
- connectionType
-
The connection type used for connecting to an Amazon EC2 environment. Valid values are
CONNECT_SSH
(default) andCONNECT_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
Valid Values:
CONNECT_SSH | CONNECT_SSM
Required: No
- description
-
The description of the environment to create.
Type: String
Length Constraints: Maximum length of 200.
Required: No
- dryRun
-
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 isUnauthorizedOperation
.Type: Boolean
Required: No
- imageId
-
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.
From December 04, 2023, you will be required to include the
imageId
parameter for theCreateEnvironmentEC2
action. This change will be reflected across all direct methods of communicating with the API, such as AWS SDK, AWS CLI and AWS CloudFormation. This change will only affect direct API consumers, and not AWS Cloud9 console users.We recommend using Amazon Linux 2023 as the AMI to create your environment as it is fully supported.
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 18.04:
ubuntu-18.04-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 18.04:
resolve:ssm:/aws/service/cloud9/amis/ubuntu-18.04-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
-
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
-
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
-
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
-
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.
- environmentId
-
The ID of the environment that was created.
Type: String
Pattern:
^[a-zA-Z0-9]{8,32}$
Errors
For information about the errors that are common to all actions, see Common Errors.
- 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
Example
The following example creates an AWS Cloud9 development environment with the specified settings.
Sample Request
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
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
For more information about using this API in one of the language-specific AWS SDKs, see the following: