Skip to content

create_environment_ec2

create_environment_ec2(
    name: EnvironmentName,
    instance_type: InstanceType,
    image_id: ImageId,
    *,
    config_overrides: Optional[Cloud9ClientConfig] = None,
    description: Optional[EnvironmentDescription] = None,
    client_request_token: Optional[ClientRequestToken] = None,
    subnet_id: Optional[SubnetId] = None,
    automatic_stop_time_minutes: Optional[AutomaticStopTimeMinutes] = None,
    owner_arn: Optional[UserArn] = None,
    tags: Optional[TagList] = None,
    connection_type: Optional[ConnectionType] = None,
    dry_run: Optional[NullableBoolean] = None,
) -> CreateEnvironmentEC2Result

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

Cloud9 is no longer available to new customers. Existing customers of Cloud9 can continue to use the service as normal. Learn more"

Parameters:

  • name (EnvironmentName) –

    The name of the environment to create.

    This name is visible to other IAM users in the same Amazon Web Services account.

  • description (Optional[EnvironmentDescription], default: None ) –

    The description of the environment to create.

  • client_request_token (Optional[ClientRequestToken], default: None ) –

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

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

  • instance_type (InstanceType) –

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

  • subnet_id (Optional[SubnetId], default: None ) –

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

  • image_id (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.

    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 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 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 2023 (recommended): amazonlinux-2023-x86_64

    • Ubuntu 22.04: ubuntu-22.04-x86_64

    SSM paths

    • 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

  • automatic_stop_time_minutes (Optional[AutomaticStopTimeMinutes], default: None ) –

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

  • owner_arn (Optional[UserArn], default: None ) –

    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.

  • tags (Optional[TagList], default: None ) –

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

  • connection_type (Optional[ConnectionType], default: None ) –

    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 Cloud9 User Guide.

  • dry_run (Optional[NullableBoolean], default: None ) –

    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.

Raises:

Examples:

CreateEnvironmentEC2

>>> client.create_environment_ec2(name='my-demo-environment', description='This is my demonstration environment.', instance_type='t2.micro', image_id='amazonlinux-2023-x86_64', subnet_id='subnet-6300cd1b', automatic_stop_time_minutes=60, owner_arn='arn:aws:iam::123456789012:user/MyDemoUser')
Source code in docs_src/capo_cloud9/_services/cloud9.py
def create_environment_ec2(
    self,
    name: "capo_cloud9.types.environment_name.EnvironmentName",
    instance_type: "capo_cloud9.types.instance_type.InstanceType",
    image_id: "capo_cloud9.types.image_id.ImageId",
    *,
    config_overrides: Optional[Cloud9ClientConfig] = None,
    description: Optional[
        "capo_cloud9.types.environment_description.EnvironmentDescription"
    ] = None,
    client_request_token: Optional[
        "capo_cloud9.types.client_request_token.ClientRequestToken"
    ] = None,
    subnet_id: Optional["capo_cloud9.types.subnet_id.SubnetId"] = None,
    automatic_stop_time_minutes: Optional[
        "capo_cloud9.types.automatic_stop_time_minutes.AutomaticStopTimeMinutes"
    ] = None,
    owner_arn: Optional["capo_cloud9.types.user_arn.UserArn"] = None,
    tags: Optional["capo_cloud9.types.tag_list.TagList"] = None,
    connection_type: Optional[
        "capo_cloud9.types.connection_type.ConnectionType"
    ] = None,
    dry_run: Optional["capo_cloud9.types.nullable_boolean.NullableBoolean"] = None,
) -> "capo_cloud9.types.create_environment_ec2_result.CreateEnvironmentEC2Result":
    """<p>Creates an Cloud9 development environment, launches an Amazon Elastic Compute Cloud (Amazon EC2) instance, and then connects from the instance to the environment.</p> <important> <p>Cloud9 is no longer available to new customers. Existing customers of Cloud9 can continue to use the service as normal. <a href="http://aws.amazon.com/blogs/devops/how-to-migrate-from-aws-cloud9-to-aws-ide-toolkits-or-aws-cloudshell/">Learn more"</a> </p> </important>

    Args:
        name: <p>The name of the environment to create.</p> <p>This name is visible to other IAM users in the same Amazon Web Services account.</p>
        description: <p>The description of the environment to create.</p>
        client_request_token: <p>A unique, case-sensitive string that helps Cloud9 to ensure this operation completes no more than one time.</p> <p>For more information, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/APIReference/Run_Instance_Idempotency.html">Client Tokens</a> in the <i>Amazon EC2 API Reference</i>.</p>
        instance_type: <p>The type of instance to connect to the environment (for example, <code>t2.micro</code>).</p>
        subnet_id: <p>The ID of the subnet in Amazon VPC that Cloud9 will use to communicate with the Amazon EC2 instance.</p>
        image_id: <p>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.</p> <p></p> <p>We recommend using Amazon Linux 2023 as the AMI to create your environment as it is fully supported.</p> <p>From December 16, 2024, Ubuntu 18.04 will be removed from the list of available <code>imageIds</code> for 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 Cloud9 console users.</p> <p>Since Ubuntu 18.04 has ended standard support as of May 31, 2023, we recommend you choose Ubuntu 22.04.</p> <p> <b>AMI aliases </b> </p> <ul> <li> <p>Amazon Linux 2023 (recommended): <code>amazonlinux-2023-x86_64</code> </p> </li> <li> <p>Ubuntu 22.04: <code>ubuntu-22.04-x86_64</code> </p> </li> </ul> <p> <b>SSM paths</b> </p> <ul> <li> <p>Amazon Linux 2023 (recommended): <code>resolve:ssm:/aws/service/cloud9/amis/amazonlinux-2023-x86_64</code> </p> </li> <li> <p>Ubuntu 22.04: <code>resolve:ssm:/aws/service/cloud9/amis/ubuntu-22.04-x86_64</code> </p> </li> </ul>
        automatic_stop_time_minutes: <p>The number of minutes until the running instance is shut down after the environment has last been used.</p>
        owner_arn: <p>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.</p>
        tags: <p>An array of key-value pairs that will be associated with the new Cloud9 development environment.</p>
        connection_type: <p>The connection type used for connecting to an Amazon EC2 environment. Valid values are <code>CONNECT_SSH</code> (default) and <code>CONNECT_SSM</code> (connected through Amazon EC2 Systems Manager).</p> <p>For more information, see <a href="https://docs.aws.amazon.com/cloud9/latest/user-guide/ec2-ssm.html">Accessing no-ingress EC2 instances with Amazon EC2 Systems Manager</a> in the <i>Cloud9 User Guide</i>.</p>
        dry_run: <p>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 <code>DryRunOperation</code>. Otherwise, it is <code>UnauthorizedOperation</code>.</p>

    Raises:
        capo_cloud9.errors.bad_request_exception.BadRequestException: <p>The target request is invalid.</p>
        capo_cloud9.errors.conflict_exception.ConflictException: <p>A conflict occurred.</p>
        capo_cloud9.errors.forbidden_exception.ForbiddenException: <p>An access permissions issue occurred.</p>
        capo_cloud9.errors.internal_server_error_exception.InternalServerErrorException: <p>An internal server error occurred.</p>
        capo_cloud9.errors.limit_exceeded_exception.LimitExceededException: <p>A service limit was exceeded.</p>
        capo_cloud9.errors.not_found_exception.NotFoundException: <p>The target resource cannot be found.</p>
        capo_cloud9.errors.too_many_requests_exception.TooManyRequestsException: <p>Too many service requests were made over the given time period.</p>
        capo_cloud9.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        CreateEnvironmentEC2

        >>> client.create_environment_ec2(name='my-demo-environment', description='This is my demonstration environment.', instance_type='t2.micro', image_id='amazonlinux-2023-x86_64', subnet_id='subnet-6300cd1b', automatic_stop_time_minutes=60, owner_arn='arn:aws:iam::123456789012:user/MyDemoUser')
    """

    def _handler(
        req: "OperationRequest[capo_cloud9.types.create_environment_ec2_request.CreateEnvironmentEC2Request]",
    ) -> OperationResponse[
        "capo_cloud9.types.create_environment_ec2_result.CreateEnvironmentEC2Result"
    ]:
        import capo_cloud9._operations.aws_cloud9_workspace_management_service.create_environment_ec2

        output, http_response = (
            capo_cloud9._operations.aws_cloud9_workspace_management_service.create_environment_ec2.create_environment_ec2(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_cloud9.types.create_environment_ec2_request.CreateEnvironmentEC2Request",
    ) -> dict[str, Any]:
        import capo_cloud9.types.create_environment_ec2_request

        return capo_cloud9.types.create_environment_ec2_request.redact_sensitive(
            input_
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging("CreateEnvironmentEC2", redact_input=_redact_input),
    )
    input_: capo_cloud9.types.create_environment_ec2_request.CreateEnvironmentEC2Request = {
        "name": name,
        "instance_type": instance_type,
        "image_id": image_id,
    }
    if description is not None:
        input_["description"] = description
    if client_request_token is not None:
        input_["client_request_token"] = client_request_token
    if subnet_id is not None:
        input_["subnet_id"] = subnet_id
    if automatic_stop_time_minutes is not None:
        input_["automatic_stop_time_minutes"] = automatic_stop_time_minutes
    if owner_arn is not None:
        input_["owner_arn"] = owner_arn
    if tags is not None:
        input_["tags"] = tags
    if connection_type is not None:
        input_["connection_type"] = connection_type
    if dry_run is not None:
        input_["dry_run"] = dry_run

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output