Skip to content

/AWS1/IF_BTC=>CREATECOMPUTEENVIRONMENT()

About CreateComputeEnvironment

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.

Method Signature

METHODS /AWS1/IF_BTC~CREATECOMPUTEENVIRONMENT
  IMPORTING
    !IV_COMPUTEENVIRONMENTNAME TYPE /AWS1/BTCSTRING OPTIONAL
    !IV_TYPE TYPE /AWS1/BTCCETYPE OPTIONAL
    !IV_STATE TYPE /AWS1/BTCCESTATE OPTIONAL
    !IV_UNMANAGEDVCPUS TYPE /AWS1/BTCINTEGER OPTIONAL
    !IO_COMPUTERESOURCES TYPE REF TO /AWS1/CL_BTCCOMPUTERESOURCE OPTIONAL
    !IV_SERVICEROLE TYPE /AWS1/BTCSTRING OPTIONAL
    !IT_TAGS TYPE /AWS1/CL_BTCTAGRISTAGSMAP_W=>TT_TAGRISTAGSMAP OPTIONAL
    !IO_EKSCONFIGURATION TYPE REF TO /AWS1/CL_BTCEKSCONFIGURATION OPTIONAL
    !IV_CONTEXT TYPE /AWS1/BTCSTRING OPTIONAL
  RETURNING
    VALUE(OO_OUTPUT) TYPE REF TO /aws1/cl_btccrecomputeenviro01
  RAISING
    /AWS1/CX_BTCCLIENTEXCEPTION
    /AWS1/CX_BTCSERVEREXCEPTION
    /AWS1/CX_BTCCLIENTEXC
    /AWS1/CX_BTCSERVEREXC
    /AWS1/CX_RT_TECHNICAL_GENERIC
    /AWS1/CX_RT_SERVICE_GENERIC.

IMPORTING

Required arguments:

iv_computeenvironmentname TYPE /AWS1/BTCSTRING /AWS1/BTCSTRING

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 (_).

iv_type TYPE /AWS1/BTCCETYPE /AWS1/BTCCETYPE

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

Optional arguments:

iv_state TYPE /AWS1/BTCCESTATE /AWS1/BTCCESTATE

The state of the compute environment. 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. To prevent additional charges, turn off and then delete the compute environment. For more information, see State in the Batch User Guide.

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.

iv_unmanagedvcpus TYPE /AWS1/BTCINTEGER /AWS1/BTCINTEGER

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.

io_computeresources TYPE REF TO /AWS1/CL_BTCCOMPUTERESOURCE /AWS1/CL_BTCCOMPUTERESOURCE

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.

iv_servicerole TYPE /AWS1/BTCSTRING /AWS1/BTCSTRING

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.

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.

it_tags TYPE /AWS1/CL_BTCTAGRISTAGSMAP_W=>TT_TAGRISTAGSMAP TT_TAGRISTAGSMAP

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.

io_eksconfiguration TYPE REF TO /AWS1/CL_BTCEKSCONFIGURATION /AWS1/CL_BTCEKSCONFIGURATION

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.

iv_context TYPE /AWS1/BTCSTRING /AWS1/BTCSTRING

Reserved.

RETURNING

oo_output TYPE REF TO /aws1/cl_btccrecomputeenviro01 /AWS1/CL_BTCCRECOMPUTEENVIRO01

Domain /AWS1/RT_ACCOUNT_ID
Primitive Type NUMC

Examples

Syntax Example

This is an example of the syntax for calling the method. It includes every possible argument and initializes every possible value. The data provided is not necessarily semantically accurate (for example the value "string" may be provided for something that is intended to be an instance ID, or in some cases two arguments may be mutually exclusive). The syntax shows the ABAP syntax for creating the various data structures.

DATA(lo_result) = lo_client->createcomputeenvironment(
  io_computeresources = new /aws1/cl_btccomputeresource(
    io_launchtemplate = new /aws1/cl_btclaunchtemplatespec(
      it_overrides = VALUE /aws1/cl_btclaunchtmplspecov00=>tt_launchtmplspecoverridelist(
        (
          new /aws1/cl_btclaunchtmplspecov00(
            it_targetinstancetypes = VALUE /aws1/cl_btcstringlist_w=>tt_stringlist(
              ( new /aws1/cl_btcstringlist_w( |string| ) )
            )
            iv_launchtemplateid = |string|
            iv_launchtemplatename = |string|
            iv_userdatatype = |string|
            iv_version = |string|
          )
        )
      )
      iv_launchtemplateid = |string|
      iv_launchtemplatename = |string|
      iv_userdatatype = |string|
      iv_version = |string|
    )
    it_ec2configuration = VALUE /aws1/cl_btcec2configuration=>tt_ec2configurationlist(
      (
        new /aws1/cl_btcec2configuration(
          iv_imageidoverride = |string|
          iv_imagekubernetesversion = |string|
          iv_imagetype = |string|
        )
      )
    )
    it_instancetypes = VALUE /aws1/cl_btcstringlist_w=>tt_stringlist(
      ( new /aws1/cl_btcstringlist_w( |string| ) )
    )
    it_securitygroupids = VALUE /aws1/cl_btcstringlist_w=>tt_stringlist(
      ( new /aws1/cl_btcstringlist_w( |string| ) )
    )
    it_subnets = VALUE /aws1/cl_btcstringlist_w=>tt_stringlist(
      ( new /aws1/cl_btcstringlist_w( |string| ) )
    )
    it_tags = VALUE /aws1/cl_btctagsmap_w=>tt_tagsmap(
      (
        VALUE /aws1/cl_btctagsmap_w=>ts_tagsmap_maprow(
          key = |string|
          value = new /aws1/cl_btctagsmap_w( |string| )
        )
      )
    )
    iv_allocationstrategy = |string|
    iv_bidpercentage = 123
    iv_desiredvcpus = 123
    iv_ec2keypair = |string|
    iv_imageid = |string|
    iv_instancerole = |string|
    iv_maxvcpus = 123
    iv_minvcpus = 123
    iv_placementgroup = |string|
    iv_spotiamfleetrole = |string|
    iv_type = |string|
  )
  io_eksconfiguration = new /aws1/cl_btceksconfiguration(
    iv_eksclusterarn = |string|
    iv_kubernetesnamespace = |string|
  )
  it_tags = VALUE /aws1/cl_btctagristagsmap_w=>tt_tagristagsmap(
    (
      VALUE /aws1/cl_btctagristagsmap_w=>ts_tagristagsmap_maprow(
        value = new /aws1/cl_btctagristagsmap_w( |string| )
        key = |string|
      )
    )
  )
  iv_computeenvironmentname = |string|
  iv_context = |string|
  iv_servicerole = |string|
  iv_state = |string|
  iv_type = |string|
  iv_unmanagedvcpus = 123
).

This is an example of reading all possible response values

lo_result = lo_result.
IF lo_result IS NOT INITIAL.
  lv_string = lo_result->get_computeenvironmentname( ).
  lv_string = lo_result->get_computeenvironmentarn( ).
ENDIF.

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.

DATA(lo_result) = lo_client->createcomputeenvironment(
  io_computeresources = new /aws1/cl_btccomputeresource(
    it_instancetypes = VALUE /aws1/cl_btcstringlist_w=>tt_stringlist(
      ( new /aws1/cl_btcstringlist_w( |c4.large| ) )
      ( new /aws1/cl_btcstringlist_w( |c4.xlarge| ) )
      ( new /aws1/cl_btcstringlist_w( |c4.2xlarge| ) )
      ( new /aws1/cl_btcstringlist_w( |c4.4xlarge| ) )
      ( new /aws1/cl_btcstringlist_w( |c4.8xlarge| ) )
    )
    it_securitygroupids = VALUE /aws1/cl_btcstringlist_w=>tt_stringlist(
      ( new /aws1/cl_btcstringlist_w( |sg-cf5093b2| ) )
    )
    it_subnets = VALUE /aws1/cl_btcstringlist_w=>tt_stringlist(
      ( new /aws1/cl_btcstringlist_w( |subnet-220c0e0a| ) )
      ( new /aws1/cl_btcstringlist_w( |subnet-1a95556d| ) )
      ( new /aws1/cl_btcstringlist_w( |subnet-978f6dce| ) )
    )
    it_tags = VALUE /aws1/cl_btctagsmap_w=>tt_tagsmap(
      (
        VALUE /aws1/cl_btctagsmap_w=>ts_tagsmap_maprow(
          key = |Name|
          value = new /aws1/cl_btctagsmap_w( |Batch Instance - C4OnDemand| )
        )
      )
    )
    iv_desiredvcpus = 48
    iv_ec2keypair = |id_rsa|
    iv_instancerole = |ecsInstanceRole|
    iv_maxvcpus = 128
    iv_minvcpus = 0
    iv_type = |EC2|
  )
  iv_computeenvironmentname = |C4OnDemand|
  iv_servicerole = |arn:aws:iam::012345678910:role/AWSBatchServiceRole|
  iv_state = |ENABLED|
  iv_type = |MANAGED|
).

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.

DATA(lo_result) = lo_client->createcomputeenvironment(
  io_computeresources = new /aws1/cl_btccomputeresource(
    it_instancetypes = VALUE /aws1/cl_btcstringlist_w=>tt_stringlist(
      ( new /aws1/cl_btcstringlist_w( |m4| ) )
    )
    it_securitygroupids = VALUE /aws1/cl_btcstringlist_w=>tt_stringlist(
      ( new /aws1/cl_btcstringlist_w( |sg-cf5093b2| ) )
    )
    it_subnets = VALUE /aws1/cl_btcstringlist_w=>tt_stringlist(
      ( new /aws1/cl_btcstringlist_w( |subnet-220c0e0a| ) )
      ( new /aws1/cl_btcstringlist_w( |subnet-1a95556d| ) )
      ( new /aws1/cl_btcstringlist_w( |subnet-978f6dce| ) )
    )
    it_tags = VALUE /aws1/cl_btctagsmap_w=>tt_tagsmap(
      (
        VALUE /aws1/cl_btctagsmap_w=>ts_tagsmap_maprow(
          key = |Name|
          value = new /aws1/cl_btctagsmap_w( |Batch Instance - M4Spot| )
        )
      )
    )
    iv_bidpercentage = 20
    iv_desiredvcpus = 4
    iv_ec2keypair = |id_rsa|
    iv_instancerole = |ecsInstanceRole|
    iv_maxvcpus = 128
    iv_minvcpus = 0
    iv_spotiamfleetrole = |arn:aws:iam::012345678910:role/aws-ec2-spot-fleet-role|
    iv_type = |SPOT|
  )
  iv_computeenvironmentname = |M4Spot|
  iv_servicerole = |arn:aws:iam::012345678910:role/AWSBatchServiceRole|
  iv_state = |ENABLED|
  iv_type = |MANAGED|
).