Skip to content

create_compute_environment

create_compute_environment(
    *,
    config_overrides: Optional[BatchClientConfig] = None,
    compute_environment_name: Optional[String] = None,
    type: Optional[CEType] = None,
    state: Optional[CEState] = None,
    unmanagedv_cpus: Optional[Integer] = None,
    compute_resources: Optional[ComputeResource] = None,
    service_role: Optional[String] = None,
    tags: Optional[TagrisTagsMap] = None,
    eks_configuration: Optional[EksConfiguration] = None,
    context: Optional[String] = None,
    ecs_settings: Optional[EcsSettings] = None,
) -> CreateComputeEnvironmentResponse

Creates an Batch compute environment. You can create MANAGED or UNMANAGED compute environments. MANAGED compute environments can use Amazon EC2 or Fargate resources. UNMANAGED compute environments can only use EC2 resources.

In a managed compute environment, Batch manages the capacity and instance types of the compute resources within the environment. This is based on the compute resource specification that you define or the launch template that you specify when you create the compute environment. Either, you can choose to use EC2 On-Demand Instances and EC2 Spot Instances. Or, you can use Fargate and Fargate Spot capacity in your managed compute environment. You can optionally set a maximum price so that Spot Instances only launch when the Spot Instance price is less than a specified percentage of the On-Demand price.

In an unmanaged compute environment, you can manage your own EC2 compute resources and have flexibility with how you configure your compute resources. For example, you can use custom AMIs. However, you must verify that each of your AMIs meet the Amazon ECS container instance AMI specification. For more information, see container instance AMIs in the Amazon Elastic Container Service Developer Guide. After you created your unmanaged compute environment, you can use the DescribeComputeEnvironments operation to find the Amazon ECS cluster that's associated with it. Then, launch your container instances into that Amazon ECS cluster. For more information, see Launching an Amazon ECS container instance in the Amazon Elastic Container Service Developer Guide.

Batch doesn't automatically upgrade the AMIs in a compute environment after it's created. For more information on how to update a compute environment's AMI, see Updating compute environments in the Batch User Guide.

Parameters:

  • compute_environment_name (Optional[String], default: None ) –

    The name for your compute environment. It can be up to 128 characters long. It can contain uppercase and lowercase letters, numbers, hyphens (-), and underscores (_).

  • type (Optional[CEType], default: None ) –

    The type of the compute environment: MANAGED or UNMANAGED. For more information, see Compute Environments in the Batch User Guide.

  • state (Optional[CEState], default: None ) –

    The state of the compute environment. A compute environment must be created in the ENABLED state.

    If the state is ENABLED, then the compute environment accepts jobs from a queue and can scale out automatically based on queues.

    If the state is ENABLED, then the Batch scheduler can attempt to place jobs from an associated job queue on the compute resources within the environment. If the compute environment is managed, then it can scale its instances out or in automatically, based on the job queue demand.

    If the state is DISABLED, then the Batch scheduler doesn't attempt to place jobs within the environment. Jobs in a STARTING or RUNNING state continue to progress normally. Managed compute environments in the DISABLED state don't scale out.

    Compute environments in a DISABLED state may continue to incur billing charges, for example, if they have running instances due to jobs that are still executing or a non-zero minvCpus setting. To prevent additional charges, disable and delete the compute environment.

    When an instance is idle, the instance scales down to the minvCpus value. However, the instance size doesn't change. For example, consider a c5.8xlarge instance with a minvCpus value of 4 and a desiredvCpus value of 36. This instance doesn't scale down to a c5.large instance.

  • unmanagedv_cpus (Optional[Integer], default: None ) –

    The maximum number of vCPUs for an unmanaged compute environment. This parameter is only used for fair-share scheduling to reserve vCPU capacity for new share identifiers. If this parameter isn't provided for a fair-share job queue, no vCPU capacity is reserved.

    This parameter is only supported when the type parameter is set to UNMANAGED.

  • compute_resources (Optional[ComputeResource], default: None ) –

    Details about the compute resources managed by the compute environment. This parameter is required for managed compute environments. For more information, see Compute Environments in the Batch User Guide.

  • service_role (Optional[String], default: None ) –

    The full Amazon Resource Name (ARN) of the IAM role that allows Batch to make calls to other Amazon Web Services services on your behalf. For more information, see Batch service IAM role in the Batch User Guide.

    If your account already created the Batch service-linked role, that role is used by default for your compute environment unless you specify a different role here. If the Batch service-linked role doesn't exist in your account, and no role is specified here, the service attempts to create the Batch service-linked role in your account.

    This automatic service-linked role creation only applies to MANAGED compute environments. For UNMANAGED compute environments, you must explicitly specify a serviceRole.

    If your specified role has a path other than /, then you must specify either the full role ARN (recommended) or prefix the role name with the path. For example, if a role with the name bar has a path of /foo/, specify /foo/bar as the role name. For more information, see Friendly names and paths in the IAM User Guide.

    Depending on how you created your Batch service role, its ARN might contain the service-role path prefix. When you only specify the name of the service role, Batch assumes that your ARN doesn't use the service-role path prefix. Because of this, we recommend that you specify the full ARN of your service role when you create compute environments.

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

    The tags that you apply to the compute environment to help you categorize and organize your resources. Each tag consists of a key and an optional value. For more information, see Tagging Amazon Web Services Resources in Amazon Web Services General Reference.

    These tags can be updated or removed using the TagResource and UntagResource API operations. These tags don't propagate to the underlying compute resources.

  • eks_configuration (Optional[EksConfiguration], default: None ) –

    The details for the Amazon EKS cluster that supports the compute environment.

    To create a compute environment that uses EKS resources, the caller must have permissions to call eks:DescribeCluster. Additional Amazon EKS permissions are required for Batch to manage an access entry on the cluster; see Amazon EKS access entry authentication in the Batch User Guide.

  • context (Optional[String], default: None ) –

    Reserved.

  • ecs_settings (Optional[EcsSettings], default: None ) –

    The Amazon ECS settings for the compute environment. These settings control CloudWatch Container Insights collection for the compute environment.

Raises:

  • ClientException –

    These errors are usually caused by a client action. One example cause is using an action or resource on behalf of a user that doesn't have permissions to use the action or resource. Another cause is specifying an identifier that's not valid.

  • ServerException –

    These errors are usually caused by a server issue.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Examples:

To create a managed EC2 compute environment This example creates a managed compute environment with specific C4 instance types that are launched on demand. The compute environment is called C4OnDemand.

>>> client.create_compute_environment(compute_environment_name='C4OnDemand', state='ENABLED', type='MANAGED', compute_resources={'subnets': ['subnet-220c0e0a', 'subnet-1a95556d', 'subnet-978f6dce'], 'tags': {'Name': 'Batch Instance - C4OnDemand'}, 'desiredvCpus': 48, 'minvCpus': 0, 'instanceTypes': ['c4.large', 'c4.xlarge', 'c4.2xlarge', 'c4.4xlarge', 'c4.8xlarge'], 'securityGroupIds': ['sg-cf5093b2'], 'instanceRole': 'ecsInstanceRole', 'maxvCpus': 128, 'type': 'EC2', 'ec2KeyPair': 'id_rsa'}, service_role='arn:aws:iam::012345678910:role/AWSBatchServiceRole')
To create a managed EC2 Spot compute environment
This example creates a managed compute environment with the M4 instance type that is launched when the Spot bid price is at or below 20% of the On-Demand price for the instance type. The compute environment is called M4Spot.
>>> client.create_compute_environment(compute_environment_name='M4Spot', state='ENABLED', type='MANAGED', compute_resources={'subnets': ['subnet-220c0e0a', 'subnet-1a95556d', 'subnet-978f6dce'], 'type': 'SPOT', 'spotIamFleetRole': 'arn:aws:iam::012345678910:role/aws-ec2-spot-fleet-role', 'tags': {'Name': 'Batch Instance - M4Spot'}, 'desiredvCpus': 4, 'minvCpus': 0, 'instanceTypes': ['m4'], 'securityGroupIds': ['sg-cf5093b2'], 'instanceRole': 'ecsInstanceRole', 'maxvCpus': 128, 'bidPercentage': 20, 'ec2KeyPair': 'id_rsa'}, service_role='arn:aws:iam::012345678910:role/AWSBatchServiceRole')
To create an ECS Managed Instances compute environment with capacity reservations
This example creates an ECS Managed Instances compute environment that targets On-Demand Capacity Reservations for predictable capacity.
>>> client.create_compute_environment(compute_environment_name='my-reserved-managed-instances-ce', state='ENABLED', type='MANAGED', compute_resources={'type': 'ECS_MANAGED_INSTANCES', 'maxvCpus': 512, 'managedInstancesProvider': {'infrastructureRoleArn': 'arn:aws:iam::123456789012:role/ecsInfrastructureRole', 'instanceLaunchTemplate': {'ec2InstanceProfileArn': 'arn:aws:iam::123456789012:instance-profile/ecsInstanceProfile', 'networkConfiguration': {'subnets': ['subnet-abcde012', 'subnet-bcde012a'], 'securityGroups': ['sg-abcde012']}, 'instanceRequirements': {'allowedInstanceTypes': ['m5.xlarge', 'm5.2xlarge']}, 'capacityReservations': {'reservationGroupArn': 'arn:aws:ec2:us-east-1:123456789012:capacity-reservation-group/my-reservation-group', 'reservationPreference': 'RESERVATIONS_FIRST'}}}})
To create an ECS Managed Instances compute environment
This example creates a managed compute environment that uses ECS Managed Instances.
>>> client.create_compute_environment(compute_environment_name='my-managed-instances-ce', state='ENABLED', type='MANAGED', compute_resources={'type': 'ECS_MANAGED_INSTANCES', 'maxvCpus': 256, 'managedInstancesProvider': {'infrastructureRoleArn': 'arn:aws:iam::123456789012:role/ecsInfrastructureRole', 'instanceLaunchTemplate': {'ec2InstanceProfileArn': 'arn:aws:iam::123456789012:instance-profile/ecsInstanceProfile', 'networkConfiguration': {'subnets': ['subnet-abcde012', 'subnet-bcde012a'], 'securityGroups': ['sg-abcde012']}}}})
To create an ECS Managed Instances Spot compute environment
This example creates a Spot-backed ECS Managed Instances compute environment constrained to specific instance types.
>>> client.create_compute_environment(compute_environment_name='my-spot-managed-instances-ce', state='ENABLED', type='MANAGED', compute_resources={'type': 'ECS_MANAGED_INSTANCES', 'maxvCpus': 1000, 'managedInstancesProvider': {'infrastructureRoleArn': 'arn:aws:iam::123456789012:role/ecsInfrastructureRole', 'instanceLaunchTemplate': {'ec2InstanceProfileArn': 'arn:aws:iam::123456789012:instance-profile/ecsInstanceProfile', 'networkConfiguration': {'subnets': ['subnet-abcde012', 'subnet-bcde012a'], 'securityGroups': ['sg-abcde012']}, 'instanceRequirements': {'allowedInstanceTypes': ['m5.large', 'm5.xlarge', 'm6i.large', 'm6i.xlarge']}, 'capacityOptionType': 'SPOT'}}})
Source code in docs_src/capo_batch/_services/batch.py
def create_compute_environment(
    self,
    *,
    config_overrides: Optional[BatchClientConfig] = None,
    compute_environment_name: Optional["capo_batch.types.string.String"] = None,
    type: Optional["capo_batch.types.ce_type.CEType"] = None,
    state: Optional["capo_batch.types.ce_state.CEState"] = None,
    unmanagedv_cpus: Optional["capo_batch.types.integer.Integer"] = None,
    compute_resources: Optional[
        "capo_batch.types.compute_resource.ComputeResource"
    ] = None,
    service_role: Optional["capo_batch.types.string.String"] = None,
    tags: Optional["capo_batch.types.tagris_tags_map.TagrisTagsMap"] = None,
    eks_configuration: Optional[
        "capo_batch.types.eks_configuration.EksConfiguration"
    ] = None,
    context: Optional["capo_batch.types.string.String"] = None,
    ecs_settings: Optional["capo_batch.types.ecs_settings.EcsSettings"] = None,
) -> "capo_batch.types.create_compute_environment_response.CreateComputeEnvironmentResponse":
    """<p>Creates an Batch compute environment. You can create <code>MANAGED</code> or <code>UNMANAGED</code> compute environments. <code>MANAGED</code> compute environments can use Amazon EC2 or Fargate resources. <code>UNMANAGED</code> compute environments can only use EC2 resources.</p> <p>In a managed compute environment, Batch manages the capacity and instance types of the compute resources within the environment. This is based on the compute resource specification that you define or the <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-launch-templates.html">launch template</a> that you specify when you create the compute environment. Either, you can choose to use EC2 On-Demand Instances and EC2 Spot Instances. Or, you can use Fargate and Fargate Spot capacity in your managed compute environment. You can optionally set a maximum price so that Spot Instances only launch when the Spot Instance price is less than a specified percentage of the On-Demand price.</p> <p>In an unmanaged compute environment, you can manage your own EC2 compute resources and have flexibility with how you configure your compute resources. For example, you can use custom AMIs. However, you must verify that each of your AMIs meet the Amazon ECS container instance AMI specification. For more information, see <a href="https://docs.aws.amazon.com/AmazonECS/latest/developerguide/container_instance_AMIs.html">container instance AMIs</a> in the <i>Amazon Elastic Container Service Developer Guide</i>. After you created your unmanaged compute environment, you can use the <a>DescribeComputeEnvironments</a> operation to find the Amazon ECS cluster that's associated with it. Then, launch your container instances into that Amazon ECS cluster. For more information, see <a href="https://docs.aws.amazon.com/AmazonECS/latest/developerguide/launch_container_instance.html">Launching an Amazon ECS container instance</a> in the <i>Amazon Elastic Container Service Developer Guide</i>.</p> <note> <p>Batch doesn't automatically upgrade the AMIs in a compute environment after it's created. For more information on how to update a compute environment's AMI, see <a href="https://docs.aws.amazon.com/batch/latest/userguide/updating-compute-environments.html">Updating compute environments</a> in the <i>Batch User Guide</i>.</p> </note>

    Args:
        compute_environment_name: <p>The name for your compute environment. It can be up to 128 characters long. It can contain uppercase and lowercase letters, numbers, hyphens (-), and underscores (_).</p>
        type: <p>The type of the compute environment: <code>MANAGED</code> or <code>UNMANAGED</code>. For more information, see <a href="https://docs.aws.amazon.com/batch/latest/userguide/compute_environments.html">Compute Environments</a> in the <i>Batch User Guide</i>.</p>
        state: <p>The state of the compute environment. A compute environment must be created in the <code>ENABLED</code> state.</p> <p>If the state is <code>ENABLED</code>, then the compute environment accepts jobs from a queue and can scale out automatically based on queues.</p> <p>If the state is <code>ENABLED</code>, then the Batch scheduler can attempt to place jobs from an associated job queue on the compute resources within the environment. If the compute environment is managed, then it can scale its instances out or in automatically, based on the job queue demand.</p> <p>If the state is <code>DISABLED</code>, then the Batch scheduler doesn't attempt to place jobs within the environment. Jobs in a <code>STARTING</code> or <code>RUNNING</code> state continue to progress normally. Managed compute environments in the <code>DISABLED</code> state don't scale out. </p> <note> <p>Compute environments in a <code>DISABLED</code> state may continue to incur billing charges, for example, if they have running instances due to jobs that are still executing or a non-zero <code>minvCpus</code> setting. To prevent additional charges, disable and delete the compute environment.</p> </note> <p>When an instance is idle, the instance scales down to the <code>minvCpus</code> value. However, the instance size doesn't change. For example, consider a <code>c5.8xlarge</code> instance with a <code>minvCpus</code> value of <code>4</code> and a <code>desiredvCpus</code> value of <code>36</code>. This instance doesn't scale down to a <code>c5.large</code> instance.</p>
        unmanagedv_cpus: <p>The maximum number of vCPUs for an unmanaged compute environment. This parameter is only used for fair-share scheduling to reserve vCPU capacity for new share identifiers. If this parameter isn't provided for a fair-share job queue, no vCPU capacity is reserved.</p> <note> <p>This parameter is only supported when the <code>type</code> parameter is set to <code>UNMANAGED</code>.</p> </note>
        compute_resources: <p>Details about the compute resources managed by the compute environment. This parameter is required for managed compute environments. For more information, see <a href="https://docs.aws.amazon.com/batch/latest/userguide/compute_environments.html">Compute Environments</a> in the <i>Batch User Guide</i>.</p>
        service_role: <p>The full Amazon Resource Name (ARN) of the IAM role that allows Batch to make calls to other Amazon Web Services services on your behalf. For more information, see <a href="https://docs.aws.amazon.com/batch/latest/userguide/service_IAM_role.html">Batch service IAM role</a> in the <i>Batch User Guide</i>.</p> <important> <p>If your account already created the Batch service-linked role, that role is used by default for your compute environment unless you specify a different role here. If the Batch service-linked role doesn't exist in your account, and no role is specified here, the service attempts to create the Batch service-linked role in your account.</p> <p>This automatic service-linked role creation only applies to <code>MANAGED</code> compute environments. For <code>UNMANAGED</code> compute environments, you must explicitly specify a <code>serviceRole</code>.</p> </important> <p>If your specified role has a path other than <code>/</code>, then you must specify either the full role ARN (recommended) or prefix the role name with the path. For example, if a role with the name <code>bar</code> has a path of <code>/foo/</code>, specify <code>/foo/bar</code> as the role name. For more information, see <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_identifiers.html#identifiers-friendly-names">Friendly names and paths</a> in the <i>IAM User Guide</i>.</p> <note> <p>Depending on how you created your Batch service role, its ARN might contain the <code>service-role</code> path prefix. When you only specify the name of the service role, Batch assumes that your ARN doesn't use the <code>service-role</code> path prefix. Because of this, we recommend that you specify the full ARN of your service role when you create compute environments.</p> </note>
        tags: <p>The tags that you apply to the compute environment to help you categorize and organize your resources. Each tag consists of a key and an optional value. For more information, see <a href="https://docs.aws.amazon.com/general/latest/gr/aws_tagging.html">Tagging Amazon Web Services Resources</a> in <i>Amazon Web Services General Reference</i>.</p> <p>These tags can be updated or removed using the <a href="https://docs.aws.amazon.com/batch/latest/APIReference/API_TagResource.html">TagResource</a> and <a href="https://docs.aws.amazon.com/batch/latest/APIReference/API_UntagResource.html">UntagResource</a> API operations. These tags don't propagate to the underlying compute resources.</p>
        eks_configuration: <p>The details for the Amazon EKS cluster that supports the compute environment.</p> <note> <p>To create a compute environment that uses EKS resources, the caller must have permissions to call <code>eks:DescribeCluster</code>. Additional Amazon EKS permissions are required for Batch to manage an access entry on the cluster; see <a href="https://docs.aws.amazon.com/batch/latest/userguide/eks-access-entries.html">Amazon EKS access entry authentication</a> in the <i>Batch User Guide</i>.</p> </note>
        context: <p>Reserved.</p>
        ecs_settings: <p>The Amazon ECS settings for the compute environment. These settings control CloudWatch Container Insights collection for the compute environment.</p>

    Raises:
        capo_batch.errors.client_exception.ClientException: <p>These errors are usually caused by a client action. One example cause is using an action or resource on behalf of a user that doesn't have permissions to use the action or resource. Another cause is specifying an identifier that's not valid.</p>
        capo_batch.errors.server_exception.ServerException: <p>These errors are usually caused by a server issue.</p>
        capo_batch.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        To create a managed EC2 compute environment
        This example creates a managed compute environment with specific C4 instance types that are launched on demand. The compute environment is called C4OnDemand.

        >>> client.create_compute_environment(compute_environment_name='C4OnDemand', state='ENABLED', type='MANAGED', compute_resources={'subnets': ['subnet-220c0e0a', 'subnet-1a95556d', 'subnet-978f6dce'], 'tags': {'Name': 'Batch Instance - C4OnDemand'}, 'desiredvCpus': 48, 'minvCpus': 0, 'instanceTypes': ['c4.large', 'c4.xlarge', 'c4.2xlarge', 'c4.4xlarge', 'c4.8xlarge'], 'securityGroupIds': ['sg-cf5093b2'], 'instanceRole': 'ecsInstanceRole', 'maxvCpus': 128, 'type': 'EC2', 'ec2KeyPair': 'id_rsa'}, service_role='arn:aws:iam::012345678910:role/AWSBatchServiceRole')
        To create a managed EC2 Spot compute environment
        This example creates a managed compute environment with the M4 instance type that is launched when the Spot bid price is at or below 20% of the On-Demand price for the instance type. The compute environment is called M4Spot.

        >>> client.create_compute_environment(compute_environment_name='M4Spot', state='ENABLED', type='MANAGED', compute_resources={'subnets': ['subnet-220c0e0a', 'subnet-1a95556d', 'subnet-978f6dce'], 'type': 'SPOT', 'spotIamFleetRole': 'arn:aws:iam::012345678910:role/aws-ec2-spot-fleet-role', 'tags': {'Name': 'Batch Instance - M4Spot'}, 'desiredvCpus': 4, 'minvCpus': 0, 'instanceTypes': ['m4'], 'securityGroupIds': ['sg-cf5093b2'], 'instanceRole': 'ecsInstanceRole', 'maxvCpus': 128, 'bidPercentage': 20, 'ec2KeyPair': 'id_rsa'}, service_role='arn:aws:iam::012345678910:role/AWSBatchServiceRole')
        To create an ECS Managed Instances compute environment with capacity reservations
        This example creates an ECS Managed Instances compute environment that targets On-Demand Capacity Reservations for predictable capacity.

        >>> client.create_compute_environment(compute_environment_name='my-reserved-managed-instances-ce', state='ENABLED', type='MANAGED', compute_resources={'type': 'ECS_MANAGED_INSTANCES', 'maxvCpus': 512, 'managedInstancesProvider': {'infrastructureRoleArn': 'arn:aws:iam::123456789012:role/ecsInfrastructureRole', 'instanceLaunchTemplate': {'ec2InstanceProfileArn': 'arn:aws:iam::123456789012:instance-profile/ecsInstanceProfile', 'networkConfiguration': {'subnets': ['subnet-abcde012', 'subnet-bcde012a'], 'securityGroups': ['sg-abcde012']}, 'instanceRequirements': {'allowedInstanceTypes': ['m5.xlarge', 'm5.2xlarge']}, 'capacityReservations': {'reservationGroupArn': 'arn:aws:ec2:us-east-1:123456789012:capacity-reservation-group/my-reservation-group', 'reservationPreference': 'RESERVATIONS_FIRST'}}}})
        To create an ECS Managed Instances compute environment
        This example creates a managed compute environment that uses ECS Managed Instances.

        >>> client.create_compute_environment(compute_environment_name='my-managed-instances-ce', state='ENABLED', type='MANAGED', compute_resources={'type': 'ECS_MANAGED_INSTANCES', 'maxvCpus': 256, 'managedInstancesProvider': {'infrastructureRoleArn': 'arn:aws:iam::123456789012:role/ecsInfrastructureRole', 'instanceLaunchTemplate': {'ec2InstanceProfileArn': 'arn:aws:iam::123456789012:instance-profile/ecsInstanceProfile', 'networkConfiguration': {'subnets': ['subnet-abcde012', 'subnet-bcde012a'], 'securityGroups': ['sg-abcde012']}}}})
        To create an ECS Managed Instances Spot compute environment
        This example creates a Spot-backed ECS Managed Instances compute environment constrained to specific instance types.

        >>> client.create_compute_environment(compute_environment_name='my-spot-managed-instances-ce', state='ENABLED', type='MANAGED', compute_resources={'type': 'ECS_MANAGED_INSTANCES', 'maxvCpus': 1000, 'managedInstancesProvider': {'infrastructureRoleArn': 'arn:aws:iam::123456789012:role/ecsInfrastructureRole', 'instanceLaunchTemplate': {'ec2InstanceProfileArn': 'arn:aws:iam::123456789012:instance-profile/ecsInstanceProfile', 'networkConfiguration': {'subnets': ['subnet-abcde012', 'subnet-bcde012a'], 'securityGroups': ['sg-abcde012']}, 'instanceRequirements': {'allowedInstanceTypes': ['m5.large', 'm5.xlarge', 'm6i.large', 'm6i.xlarge']}, 'capacityOptionType': 'SPOT'}}})
    """

    def _handler(
        req: "OperationRequest[capo_batch.types.create_compute_environment_request.CreateComputeEnvironmentRequest]",
    ) -> OperationResponse[
        "capo_batch.types.create_compute_environment_response.CreateComputeEnvironmentResponse"
    ]:
        import capo_batch._operations.aws_batch_v20160810.create_compute_environment

        output, http_response = (
            capo_batch._operations.aws_batch_v20160810.create_compute_environment.create_compute_environment(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateComputeEnvironment")
    )
    input_: capo_batch.types.create_compute_environment_request.CreateComputeEnvironmentRequest = {}
    if compute_environment_name is not None:
        input_["compute_environment_name"] = compute_environment_name
    if type is not None:
        input_["type"] = type
    if state is not None:
        input_["state"] = state
    if unmanagedv_cpus is not None:
        input_["unmanagedv_cpus"] = unmanagedv_cpus
    if compute_resources is not None:
        input_["compute_resources"] = compute_resources
    if service_role is not None:
        input_["service_role"] = service_role
    if tags is not None:
        input_["tags"] = tags
    if eks_configuration is not None:
        input_["eks_configuration"] = eks_configuration
    if context is not None:
        input_["context"] = context
    if ecs_settings is not None:
        input_["ecs_settings"] = ecs_settings

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