All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.pulumi.aws.batch.ComputeEnvironment Maven / Gradle / Ivy

Go to download

A Pulumi package for creating and managing Amazon Web Services (AWS) cloud resources.

There is a newer version: 6.72.0
Show newest version
// *** WARNING: this file was generated by pulumi-java-gen. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***

package com.pulumi.aws.batch;

import com.pulumi.aws.Utilities;
import com.pulumi.aws.batch.ComputeEnvironmentArgs;
import com.pulumi.aws.batch.inputs.ComputeEnvironmentState;
import com.pulumi.aws.batch.outputs.ComputeEnvironmentComputeResources;
import com.pulumi.aws.batch.outputs.ComputeEnvironmentEksConfiguration;
import com.pulumi.aws.batch.outputs.ComputeEnvironmentUpdatePolicy;
import com.pulumi.core.Output;
import com.pulumi.core.annotations.Export;
import com.pulumi.core.annotations.ResourceType;
import com.pulumi.core.internal.Codegen;
import java.lang.String;
import java.util.Map;
import java.util.Optional;
import javax.annotation.Nullable;

/**
 * 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?](http://docs.aws.amazon.com/batch/latest/userguide/what-is-batch.html) .
 * For information about compute environment, see [Compute Environments](http://docs.aws.amazon.com/batch/latest/userguide/compute_environments.html) .
 * 
 * > **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](http://docs.aws.amazon.com/batch/latest/userguide/troubleshooting.html) .
 * 
 * ## Example Usage
 * 
 * ### EC2 Type
 * 
 * <!--Start PulumiCodeChooser -->
 * 
 * {@code
 * package generated_program;
 * 
 * import com.pulumi.Context;
 * import com.pulumi.Pulumi;
 * import com.pulumi.core.Output;
 * import com.pulumi.aws.iam.IamFunctions;
 * import com.pulumi.aws.iam.inputs.GetPolicyDocumentArgs;
 * import com.pulumi.aws.iam.Role;
 * import com.pulumi.aws.iam.RoleArgs;
 * import com.pulumi.aws.iam.RolePolicyAttachment;
 * import com.pulumi.aws.iam.RolePolicyAttachmentArgs;
 * import com.pulumi.aws.iam.InstanceProfile;
 * import com.pulumi.aws.iam.InstanceProfileArgs;
 * import com.pulumi.aws.ec2.SecurityGroup;
 * import com.pulumi.aws.ec2.SecurityGroupArgs;
 * import com.pulumi.aws.ec2.inputs.SecurityGroupEgressArgs;
 * import com.pulumi.aws.ec2.Vpc;
 * import com.pulumi.aws.ec2.VpcArgs;
 * import com.pulumi.aws.ec2.Subnet;
 * import com.pulumi.aws.ec2.SubnetArgs;
 * import com.pulumi.aws.ec2.PlacementGroup;
 * import com.pulumi.aws.ec2.PlacementGroupArgs;
 * import com.pulumi.aws.batch.ComputeEnvironment;
 * import com.pulumi.aws.batch.ComputeEnvironmentArgs;
 * import com.pulumi.aws.batch.inputs.ComputeEnvironmentComputeResourcesArgs;
 * import com.pulumi.resources.CustomResourceOptions;
 * import java.util.List;
 * import java.util.ArrayList;
 * import java.util.Map;
 * import java.io.File;
 * import java.nio.file.Files;
 * import java.nio.file.Paths;
 * 
 * public class App {
 *     public static void main(String[] args) {
 *         Pulumi.run(App::stack);
 *     }
 * 
 *     public static void stack(Context ctx) {
 *         final var ec2AssumeRole = IamFunctions.getPolicyDocument(GetPolicyDocumentArgs.builder()
 *             .statements(GetPolicyDocumentStatementArgs.builder()
 *                 .effect("Allow")
 *                 .principals(GetPolicyDocumentStatementPrincipalArgs.builder()
 *                     .type("Service")
 *                     .identifiers("ec2.amazonaws.com")
 *                     .build())
 *                 .actions("sts:AssumeRole")
 *                 .build())
 *             .build());
 * 
 *         var ecsInstanceRole = new Role("ecsInstanceRole", RoleArgs.builder()
 *             .name("ecs_instance_role")
 *             .assumeRolePolicy(ec2AssumeRole.applyValue(getPolicyDocumentResult -> getPolicyDocumentResult.json()))
 *             .build());
 * 
 *         var ecsInstanceRoleRolePolicyAttachment = new RolePolicyAttachment("ecsInstanceRoleRolePolicyAttachment", RolePolicyAttachmentArgs.builder()
 *             .role(ecsInstanceRole.name())
 *             .policyArn("arn:aws:iam::aws:policy/service-role/AmazonEC2ContainerServiceforEC2Role")
 *             .build());
 * 
 *         var ecsInstanceRoleInstanceProfile = new InstanceProfile("ecsInstanceRoleInstanceProfile", InstanceProfileArgs.builder()
 *             .name("ecs_instance_role")
 *             .role(ecsInstanceRole.name())
 *             .build());
 * 
 *         final var batchAssumeRole = IamFunctions.getPolicyDocument(GetPolicyDocumentArgs.builder()
 *             .statements(GetPolicyDocumentStatementArgs.builder()
 *                 .effect("Allow")
 *                 .principals(GetPolicyDocumentStatementPrincipalArgs.builder()
 *                     .type("Service")
 *                     .identifiers("batch.amazonaws.com")
 *                     .build())
 *                 .actions("sts:AssumeRole")
 *                 .build())
 *             .build());
 * 
 *         var awsBatchServiceRole = new Role("awsBatchServiceRole", RoleArgs.builder()
 *             .name("aws_batch_service_role")
 *             .assumeRolePolicy(batchAssumeRole.applyValue(getPolicyDocumentResult -> getPolicyDocumentResult.json()))
 *             .build());
 * 
 *         var awsBatchServiceRoleRolePolicyAttachment = new RolePolicyAttachment("awsBatchServiceRoleRolePolicyAttachment", RolePolicyAttachmentArgs.builder()
 *             .role(awsBatchServiceRole.name())
 *             .policyArn("arn:aws:iam::aws:policy/service-role/AWSBatchServiceRole")
 *             .build());
 * 
 *         var sample = new SecurityGroup("sample", SecurityGroupArgs.builder()
 *             .name("aws_batch_compute_environment_security_group")
 *             .egress(SecurityGroupEgressArgs.builder()
 *                 .fromPort(0)
 *                 .toPort(0)
 *                 .protocol("-1")
 *                 .cidrBlocks("0.0.0.0/0")
 *                 .build())
 *             .build());
 * 
 *         var sampleVpc = new Vpc("sampleVpc", VpcArgs.builder()
 *             .cidrBlock("10.1.0.0/16")
 *             .build());
 * 
 *         var sampleSubnet = new Subnet("sampleSubnet", SubnetArgs.builder()
 *             .vpcId(sampleVpc.id())
 *             .cidrBlock("10.1.1.0/24")
 *             .build());
 * 
 *         var samplePlacementGroup = new PlacementGroup("samplePlacementGroup", PlacementGroupArgs.builder()
 *             .name("sample")
 *             .strategy("cluster")
 *             .build());
 * 
 *         var sampleComputeEnvironment = new ComputeEnvironment("sampleComputeEnvironment", ComputeEnvironmentArgs.builder()
 *             .computeEnvironmentName("sample")
 *             .computeResources(ComputeEnvironmentComputeResourcesArgs.builder()
 *                 .instanceRole(ecsInstanceRoleInstanceProfile.arn())
 *                 .instanceTypes("c4.large")
 *                 .maxVcpus(16)
 *                 .minVcpus(0)
 *                 .placementGroup(samplePlacementGroup.name())
 *                 .securityGroupIds(sample.id())
 *                 .subnets(sampleSubnet.id())
 *                 .type("EC2")
 *                 .build())
 *             .serviceRole(awsBatchServiceRole.arn())
 *             .type("MANAGED")
 *             .build(), CustomResourceOptions.builder()
 *                 .dependsOn(awsBatchServiceRoleRolePolicyAttachment)
 *                 .build());
 * 
 *     }
 * }
 * }
 * 
* <!--End PulumiCodeChooser --> * * ### Fargate Type * * <!--Start PulumiCodeChooser --> *
 * {@code
 * package generated_program;
 * 
 * import com.pulumi.Context;
 * import com.pulumi.Pulumi;
 * import com.pulumi.core.Output;
 * import com.pulumi.aws.batch.ComputeEnvironment;
 * import com.pulumi.aws.batch.ComputeEnvironmentArgs;
 * import com.pulumi.aws.batch.inputs.ComputeEnvironmentComputeResourcesArgs;
 * import com.pulumi.resources.CustomResourceOptions;
 * import java.util.List;
 * import java.util.ArrayList;
 * import java.util.Map;
 * import java.io.File;
 * import java.nio.file.Files;
 * import java.nio.file.Paths;
 * 
 * public class App {
 *     public static void main(String[] args) {
 *         Pulumi.run(App::stack);
 *     }
 * 
 *     public static void stack(Context ctx) {
 *         var sample = new ComputeEnvironment("sample", ComputeEnvironmentArgs.builder()
 *             .computeEnvironmentName("sample")
 *             .computeResources(ComputeEnvironmentComputeResourcesArgs.builder()
 *                 .maxVcpus(16)
 *                 .securityGroupIds(sampleAwsSecurityGroup.id())
 *                 .subnets(sampleAwsSubnet.id())
 *                 .type("FARGATE")
 *                 .build())
 *             .serviceRole(awsBatchServiceRoleAwsIamRole.arn())
 *             .type("MANAGED")
 *             .build(), CustomResourceOptions.builder()
 *                 .dependsOn(awsBatchServiceRole)
 *                 .build());
 * 
 *     }
 * }
 * }
 * 
* <!--End PulumiCodeChooser --> * * ### Setting Update Policy * * <!--Start PulumiCodeChooser --> *
 * {@code
 * package generated_program;
 * 
 * import com.pulumi.Context;
 * import com.pulumi.Pulumi;
 * import com.pulumi.core.Output;
 * import com.pulumi.aws.batch.ComputeEnvironment;
 * import com.pulumi.aws.batch.ComputeEnvironmentArgs;
 * import com.pulumi.aws.batch.inputs.ComputeEnvironmentComputeResourcesArgs;
 * import com.pulumi.aws.batch.inputs.ComputeEnvironmentUpdatePolicyArgs;
 * import java.util.List;
 * import java.util.ArrayList;
 * import java.util.Map;
 * import java.io.File;
 * import java.nio.file.Files;
 * import java.nio.file.Paths;
 * 
 * public class App {
 *     public static void main(String[] args) {
 *         Pulumi.run(App::stack);
 *     }
 * 
 *     public static void stack(Context ctx) {
 *         var sample = new ComputeEnvironment("sample", ComputeEnvironmentArgs.builder()
 *             .computeEnvironmentName("sample")
 *             .computeResources(ComputeEnvironmentComputeResourcesArgs.builder()
 *                 .allocationStrategy("BEST_FIT_PROGRESSIVE")
 *                 .instanceRole(ecsInstance.arn())
 *                 .instanceTypes("optimal")
 *                 .maxVcpus(4)
 *                 .minVcpus(0)
 *                 .securityGroupIds(sampleAwsSecurityGroup.id())
 *                 .subnets(sampleAwsSubnet.id())
 *                 .type("EC2")
 *                 .build())
 *             .updatePolicy(ComputeEnvironmentUpdatePolicyArgs.builder()
 *                 .jobExecutionTimeoutMinutes(30)
 *                 .terminateJobsOnUpdate(false)
 *                 .build())
 *             .type("MANAGED")
 *             .build());
 * 
 *     }
 * }
 * }
 * 
* <!--End PulumiCodeChooser --> * * ## Import * * Using `pulumi import`, import AWS Batch compute using the `compute_environment_name`. For example: * * ```sh * $ pulumi import aws:batch/computeEnvironment:ComputeEnvironment sample sample * ``` * */ @ResourceType(type="aws:batch/computeEnvironment:ComputeEnvironment") public class ComputeEnvironment extends com.pulumi.resources.CustomResource { /** * The Amazon Resource Name (ARN) of the compute environment. * */ @Export(name="arn", refs={String.class}, tree="[0]") private Output arn; /** * @return The Amazon Resource Name (ARN) of the compute environment. * */ public Output arn() { return this.arn; } /** * The name for your compute environment. Up to 128 letters (uppercase and lowercase), numbers, and underscores are allowed. If omitted, the provider will assign a random, unique name. * */ @Export(name="computeEnvironmentName", refs={String.class}, tree="[0]") private Output computeEnvironmentName; /** * @return The name for your compute environment. Up to 128 letters (uppercase and lowercase), numbers, and underscores are allowed. If omitted, the provider will assign a random, unique name. * */ public Output computeEnvironmentName() { return this.computeEnvironmentName; } /** * Creates a unique compute environment name beginning with the specified prefix. Conflicts with `compute_environment_name`. * */ @Export(name="computeEnvironmentNamePrefix", refs={String.class}, tree="[0]") private Output computeEnvironmentNamePrefix; /** * @return Creates a unique compute environment name beginning with the specified prefix. Conflicts with `compute_environment_name`. * */ public Output computeEnvironmentNamePrefix() { return this.computeEnvironmentNamePrefix; } /** * Details of the compute resources managed by the compute environment. This parameter is required for managed compute environments. See details below. * */ @Export(name="computeResources", refs={ComputeEnvironmentComputeResources.class}, tree="[0]") private Output computeResources; /** * @return Details of the compute resources managed by the compute environment. This parameter is required for managed compute environments. See details below. * */ public Output> computeResources() { return Codegen.optional(this.computeResources); } /** * The Amazon Resource Name (ARN) of the underlying Amazon ECS cluster used by the compute environment. * */ @Export(name="ecsClusterArn", refs={String.class}, tree="[0]") private Output ecsClusterArn; /** * @return The Amazon Resource Name (ARN) of the underlying Amazon ECS cluster used by the compute environment. * */ public Output ecsClusterArn() { return this.ecsClusterArn; } /** * Details for the Amazon EKS cluster that supports the compute environment. See details below. * */ @Export(name="eksConfiguration", refs={ComputeEnvironmentEksConfiguration.class}, tree="[0]") private Output eksConfiguration; /** * @return Details for the Amazon EKS cluster that supports the compute environment. See details below. * */ public Output> eksConfiguration() { return Codegen.optional(this.eksConfiguration); } /** * The full Amazon Resource Name (ARN) of the IAM role that allows AWS Batch to make calls to other AWS services on your behalf. * */ @Export(name="serviceRole", refs={String.class}, tree="[0]") private Output serviceRole; /** * @return The full Amazon Resource Name (ARN) of the IAM role that allows AWS Batch to make calls to other AWS services on your behalf. * */ public Output serviceRole() { return this.serviceRole; } /** * 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`. * */ @Export(name="state", refs={String.class}, tree="[0]") private Output state; /** * @return 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`. * */ public Output> state() { return Codegen.optional(this.state); } /** * The current status of the compute environment (for example, CREATING or VALID). * */ @Export(name="status", refs={String.class}, tree="[0]") private Output status; /** * @return The current status of the compute environment (for example, CREATING or VALID). * */ public Output status() { return this.status; } /** * A short, human-readable string to provide additional details about the current status of the compute environment. * */ @Export(name="statusReason", refs={String.class}, tree="[0]") private Output statusReason; /** * @return A short, human-readable string to provide additional details about the current status of the compute environment. * */ public Output statusReason() { return this.statusReason; } /** * Key-value map of resource tags. If configured with a provider `default_tags` configuration block present, tags with matching keys will overwrite those defined at the provider-level. * */ @Export(name="tags", refs={Map.class,String.class}, tree="[0,1,1]") private Output> tags; /** * @return Key-value map of resource tags. If configured with a provider `default_tags` configuration block present, tags with matching keys will overwrite those defined at the provider-level. * */ public Output>> tags() { return Codegen.optional(this.tags); } /** * A map of tags assigned to the resource, including those inherited from the provider `default_tags` configuration block. * * @deprecated * Please use `tags` instead. * */ @Deprecated /* Please use `tags` instead. */ @Export(name="tagsAll", refs={Map.class,String.class}, tree="[0,1,1]") private Output> tagsAll; /** * @return A map of tags assigned to the resource, including those inherited from the provider `default_tags` configuration block. * */ public Output> tagsAll() { return this.tagsAll; } /** * The type of the compute environment. Valid items are `MANAGED` or `UNMANAGED`. * */ @Export(name="type", refs={String.class}, tree="[0]") private Output type; /** * @return The type of the compute environment. Valid items are `MANAGED` or `UNMANAGED`. * */ public Output type() { return this.type; } /** * Specifies the infrastructure update policy for the compute environment. See details below. * */ @Export(name="updatePolicy", refs={ComputeEnvironmentUpdatePolicy.class}, tree="[0]") private Output updatePolicy; /** * @return Specifies the infrastructure update policy for the compute environment. See details below. * */ public Output> updatePolicy() { return Codegen.optional(this.updatePolicy); } /** * * @param name The _unique_ name of the resulting resource. */ public ComputeEnvironment(java.lang.String name) { this(name, ComputeEnvironmentArgs.Empty); } /** * * @param name The _unique_ name of the resulting resource. * @param args The arguments to use to populate this resource's properties. */ public ComputeEnvironment(java.lang.String name, ComputeEnvironmentArgs args) { this(name, args, null); } /** * * @param name The _unique_ name of the resulting resource. * @param args The arguments to use to populate this resource's properties. * @param options A bag of options that control this resource's behavior. */ public ComputeEnvironment(java.lang.String name, ComputeEnvironmentArgs args, @Nullable com.pulumi.resources.CustomResourceOptions options) { super("aws:batch/computeEnvironment:ComputeEnvironment", name, makeArgs(args, options), makeResourceOptions(options, Codegen.empty()), false); } private ComputeEnvironment(java.lang.String name, Output id, @Nullable ComputeEnvironmentState state, @Nullable com.pulumi.resources.CustomResourceOptions options) { super("aws:batch/computeEnvironment:ComputeEnvironment", name, state, makeResourceOptions(options, id), false); } private static ComputeEnvironmentArgs makeArgs(ComputeEnvironmentArgs args, @Nullable com.pulumi.resources.CustomResourceOptions options) { if (options != null && options.getUrn().isPresent()) { return null; } return args == null ? ComputeEnvironmentArgs.Empty : args; } private static com.pulumi.resources.CustomResourceOptions makeResourceOptions(@Nullable com.pulumi.resources.CustomResourceOptions options, @Nullable Output id) { var defaultOptions = com.pulumi.resources.CustomResourceOptions.builder() .version(Utilities.getVersion()) .build(); return com.pulumi.resources.CustomResourceOptions.merge(defaultOptions, options, id); } /** * Get an existing Host resource's state with the given name, ID, and optional extra * properties used to qualify the lookup. * * @param name The _unique_ name of the resulting resource. * @param id The _unique_ provider ID of the resource to lookup. * @param state * @param options Optional settings to control the behavior of the CustomResource. */ public static ComputeEnvironment get(java.lang.String name, Output id, @Nullable ComputeEnvironmentState state, @Nullable com.pulumi.resources.CustomResourceOptions options) { return new ComputeEnvironment(name, id, state, options); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy