Use CreateEnvironmentEc2 with a CLI - AWS SDK Code Examples

There are more AWS SDK examples available in the AWS Doc SDK Examples GitHub repo.

Use CreateEnvironmentEc2 with a CLI

The following code examples show how to use CreateEnvironmentEc2.

CLI
AWS CLI

To create an AWS Cloud9 EC2 development environment

This following create-environment-ec2 example creates an AWS Cloud9 development environment with the specified settings, launches an Amazon Elastic Compute Cloud (Amazon EC2) instance, and then connects from the instance to the environment.

aws cloud9 create-environment-ec2 \ --name my-demo-env \ --description "My demonstration development environment." \ --instance-type t2.micro --image-id amazonlinux-2023-x86_64 \ --subnet-id subnet-1fab8aEX \ --automatic-stop-time-minutes 60 \ --owner-arn arn:aws:iam::123456789012:user/MyDemoUser

Output:

{ "environmentId": "8a34f51ce1e04a08882f1e811bd706EX" }

For more information, see Creating an EC2 Environment in the AWS Cloud9 User Guide.

PowerShell
Tools for PowerShell

Example 1: This example creates an AWS Cloud9 development environment with the specified settings, launches an Amazon Elastic Compute Cloud (Amazon EC2) instance, and then connects from the instance to the environment.

New-C9EnvironmentEC2 -Name my-demo-env -AutomaticStopTimeMinutes 60 -Description "My demonstration development environment." -InstanceType t2.micro -OwnerArn arn:aws:iam::123456789012:user/MyDemoUser -SubnetId subnet-d43a46EX

Output:

ffd88420d4824eeeaeaa8a04bfde8cEX