Show / Hide Table of Contents

Class ComputeEnvironment

Creates a AWS Batch compute environment. Compute environments contain the Amazon ECS container instances that are used to run containerized batch jobs.

For information about AWS Batch, see What is AWS Batch? . For information about compute environment, see Compute Environments .

Note: To prevent a race condition during environment deletion, make sure to set depends_on to the related aws.iam.RolePolicyAttachment; otherwise, the policy may be destroyed too soon and the compute environment will then get stuck in the DELETING state, see Troubleshooting AWS Batch .

Example Usage

using Pulumi;
using Aws = Pulumi.Aws;

class MyStack : Stack
{
public MyStack()
{
    var ecsInstanceRoleRole = new Aws.Iam.Role("ecsInstanceRoleRole", new Aws.Iam.RoleArgs
    {
        AssumeRolePolicy = @"{
""Version"": ""2012-10-17"",
""Statement"": [
{
 ""Action"": ""sts:AssumeRole"",
 ""Effect"": ""Allow"",
 ""Principal"": {
""Service"": ""ec2.amazonaws.com""
 }
}
]
}

",
    });
    var ecsInstanceRoleRolePolicyAttachment = new Aws.Iam.RolePolicyAttachment("ecsInstanceRoleRolePolicyAttachment", new Aws.Iam.RolePolicyAttachmentArgs
    {
        PolicyArn = "arn:aws:iam::aws:policy/service-role/AmazonEC2ContainerServiceforEC2Role",
        Role = ecsInstanceRoleRole.Name,
    });
    var ecsInstanceRoleInstanceProfile = new Aws.Iam.InstanceProfile("ecsInstanceRoleInstanceProfile", new Aws.Iam.InstanceProfileArgs
    {
        Role = ecsInstanceRoleRole.Name,
    });
    var awsBatchServiceRoleRole = new Aws.Iam.Role("awsBatchServiceRoleRole", new Aws.Iam.RoleArgs
    {
        AssumeRolePolicy = @"{
""Version"": ""2012-10-17"",
""Statement"": [
{
 ""Action"": ""sts:AssumeRole"",
 ""Effect"": ""Allow"",
 ""Principal"": {
""Service"": ""batch.amazonaws.com""
 }
}
]
}

",
    });
    var awsBatchServiceRoleRolePolicyAttachment = new Aws.Iam.RolePolicyAttachment("awsBatchServiceRoleRolePolicyAttachment", new Aws.Iam.RolePolicyAttachmentArgs
    {
        PolicyArn = "arn:aws:iam::aws:policy/service-role/AWSBatchServiceRole",
        Role = awsBatchServiceRoleRole.Name,
    });
    var sampleSecurityGroup = new Aws.Ec2.SecurityGroup("sampleSecurityGroup", new Aws.Ec2.SecurityGroupArgs
    {
        Egress = 
        {
            new Aws.Ec2.Inputs.SecurityGroupEgressArgs
            {
                CidrBlocks = 
                {
                    "0.0.0.0/0",
                },
                FromPort = 0,
                Protocol = "-1",
                ToPort = 0,
            },
        },
    });
    var sampleVpc = new Aws.Ec2.Vpc("sampleVpc", new Aws.Ec2.VpcArgs
    {
        CidrBlock = "10.1.0.0/16",
    });
    var sampleSubnet = new Aws.Ec2.Subnet("sampleSubnet", new Aws.Ec2.SubnetArgs
    {
        CidrBlock = "10.1.1.0/24",
        VpcId = sampleVpc.Id,
    });
    var sampleComputeEnvironment = new Aws.Batch.ComputeEnvironment("sampleComputeEnvironment", new Aws.Batch.ComputeEnvironmentArgs
    {
        ComputeEnvironmentName = "sample",
        ComputeResources = new Aws.Batch.Inputs.ComputeEnvironmentComputeResourcesArgs
        {
            InstanceRole = ecsInstanceRoleInstanceProfile.Arn,
            InstanceType = 
            {
                "c4.large",
            },
            MaxVcpus = 16,
            MinVcpus = 0,
            SecurityGroupIds = 
            {
                sampleSecurityGroup.Id,
            },
            Subnets = 
            {
                sampleSubnet.Id,
            },
            Type = "EC2",
        },
        ServiceRole = awsBatchServiceRoleRole.Arn,
        Type = "MANAGED",
    });
}

}
Inheritance
System.Object
Resource
CustomResource
ComputeEnvironment
Inherited Members
CustomResource.Id
Resource.GetResourceType()
Resource.GetResourceName()
Resource.Urn
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: Pulumi.Aws.Batch
Assembly: Pulumi.Aws.dll
Syntax
public class ComputeEnvironment : CustomResource

Constructors

View Source

ComputeEnvironment(String, ComputeEnvironmentArgs, CustomResourceOptions)

Create a ComputeEnvironment resource with the given unique name, arguments, and options.

Declaration
public ComputeEnvironment(string name, ComputeEnvironmentArgs args, CustomResourceOptions options = null)
Parameters
Type Name Description
System.String name

The unique name of the resource

ComputeEnvironmentArgs args

The arguments used to populate this resource's properties

CustomResourceOptions options

A bag of options that control this resource's behavior

Properties

View Source

Arn

The Amazon Resource Name (ARN) of the compute environment.

Declaration
public Output<string> Arn { get; }
Property Value
Type Description
Output<System.String>
View Source

ComputeEnvironmentName

The name for your compute environment. Up to 128 letters (uppercase and lowercase), numbers, and underscores are allowed. If omitted, this provider will assign a random, unique name.

Declaration
public Output<string> ComputeEnvironmentName { get; }
Property Value
Type Description
Output<System.String>
View Source

ComputeEnvironmentNamePrefix

Creates a unique compute environment name beginning with the specified prefix. Conflicts with compute_environment_name.

Declaration
public Output<string> ComputeEnvironmentNamePrefix { get; }
Property Value
Type Description
Output<System.String>
View Source

ComputeResources

Details of the compute resources managed by the compute environment. This parameter is required for managed compute environments. See details below.

Declaration
public Output<ComputeEnvironmentComputeResources> ComputeResources { get; }
Property Value
Type Description
Output<ComputeEnvironmentComputeResources>
View Source

EcsClusterArn

The Amazon Resource Name (ARN) of the underlying Amazon ECS cluster used by the compute environment.

Declaration
public Output<string> EcsClusterArn { get; }
Property Value
Type Description
Output<System.String>
View Source

ServiceRole

The full Amazon Resource Name (ARN) of the IAM role that allows AWS Batch to make calls to other AWS services on your behalf.

Declaration
public Output<string> ServiceRole { get; }
Property Value
Type Description
Output<System.String>
View Source

State

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. Valid items are ENABLED or DISABLED. Defaults to ENABLED.

Declaration
public Output<string> State { get; }
Property Value
Type Description
Output<System.String>
View Source

Status

The current status of the compute environment (for example, CREATING or VALID).

Declaration
public Output<string> Status { get; }
Property Value
Type Description
Output<System.String>
View Source

StatusReason

A short, human-readable string to provide additional details about the current status of the compute environment.

Declaration
public Output<string> StatusReason { get; }
Property Value
Type Description
Output<System.String>
View Source

Type

The type of compute environment. Valid items are EC2 or SPOT.

Declaration
public Output<string> Type { get; }
Property Value
Type Description
Output<System.String>

Methods

View Source

Get(String, Input<String>, ComputeEnvironmentState, CustomResourceOptions)

Get an existing ComputeEnvironment resource's state with the given name, ID, and optional extra properties used to qualify the lookup.

Declaration
public static ComputeEnvironment Get(string name, Input<string> id, ComputeEnvironmentState state = null, CustomResourceOptions options = null)
Parameters
Type Name Description
System.String name

The unique name of the resulting resource.

Input<System.String> id

The unique provider ID of the resource to lookup.

ComputeEnvironmentState state

Any extra arguments used during the lookup.

CustomResourceOptions options

A bag of options that control this resource's behavior

Returns
Type Description
ComputeEnvironment
  • View Source
Back to top Copyright 2016-2020, Pulumi Corporation.