@pulumi/aws
Version:
A Pulumi package for creating and managing Amazon Web Services (AWS) cloud resources.
229 lines • 9.19 kB
JavaScript
// *** WARNING: this file was generated by pulumi-language-nodejs. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
Object.defineProperty(exports, "__esModule", { value: true });
exports.ComputeEnvironment = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("../utilities");
/**
* 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 `dependsOn` 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
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
*
* const ec2AssumeRole = aws.iam.getPolicyDocument({
* statements: [{
* effect: "Allow",
* principals: [{
* type: "Service",
* identifiers: ["ec2.amazonaws.com"],
* }],
* actions: ["sts:AssumeRole"],
* }],
* });
* const ecsInstanceRole = new aws.iam.Role("ecs_instance_role", {
* name: "ecs_instance_role",
* assumeRolePolicy: ec2AssumeRole.then(ec2AssumeRole => ec2AssumeRole.json),
* });
* const ecsInstanceRoleRolePolicyAttachment = new aws.iam.RolePolicyAttachment("ecs_instance_role", {
* role: ecsInstanceRole.name,
* policyArn: "arn:aws:iam::aws:policy/service-role/AmazonEC2ContainerServiceforEC2Role",
* });
* const ecsInstanceRoleInstanceProfile = new aws.iam.InstanceProfile("ecs_instance_role", {
* name: "ecs_instance_role",
* role: ecsInstanceRole.name,
* });
* const batchAssumeRole = aws.iam.getPolicyDocument({
* statements: [{
* effect: "Allow",
* principals: [{
* type: "Service",
* identifiers: ["batch.amazonaws.com"],
* }],
* actions: ["sts:AssumeRole"],
* }],
* });
* const awsBatchServiceRole = new aws.iam.Role("aws_batch_service_role", {
* name: "aws_batch_service_role",
* assumeRolePolicy: batchAssumeRole.then(batchAssumeRole => batchAssumeRole.json),
* });
* const awsBatchServiceRoleRolePolicyAttachment = new aws.iam.RolePolicyAttachment("aws_batch_service_role", {
* role: awsBatchServiceRole.name,
* policyArn: "arn:aws:iam::aws:policy/service-role/AWSBatchServiceRole",
* });
* const sample = new aws.ec2.SecurityGroup("sample", {
* name: "aws_batch_compute_environment_security_group",
* egress: [{
* fromPort: 0,
* toPort: 0,
* protocol: "-1",
* cidrBlocks: ["0.0.0.0/0"],
* }],
* });
* const sampleVpc = new aws.ec2.Vpc("sample", {cidrBlock: "10.1.0.0/16"});
* const sampleSubnet = new aws.ec2.Subnet("sample", {
* vpcId: sampleVpc.id,
* cidrBlock: "10.1.1.0/24",
* });
* const samplePlacementGroup = new aws.ec2.PlacementGroup("sample", {
* name: "sample",
* strategy: aws.ec2.PlacementStrategy.Cluster,
* });
* const sampleComputeEnvironment = new aws.batch.ComputeEnvironment("sample", {
* name: "sample",
* computeResources: {
* instanceRole: ecsInstanceRoleInstanceProfile.arn,
* instanceTypes: ["c4.large"],
* maxVcpus: 16,
* minVcpus: 0,
* placementGroup: samplePlacementGroup.name,
* securityGroupIds: [sample.id],
* subnets: [sampleSubnet.id],
* type: "EC2",
* },
* serviceRole: awsBatchServiceRole.arn,
* type: "MANAGED",
* }, {
* dependsOn: [awsBatchServiceRoleRolePolicyAttachment],
* });
* ```
*
* ### Fargate Type
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
*
* const sample = new aws.batch.ComputeEnvironment("sample", {
* name: "sample",
* computeResources: {
* maxVcpus: 16,
* securityGroupIds: [sampleAwsSecurityGroup.id],
* subnets: [sampleAwsSubnet.id],
* type: "FARGATE",
* },
* serviceRole: awsBatchServiceRoleAwsIamRole.arn,
* type: "MANAGED",
* }, {
* dependsOn: [awsBatchServiceRole],
* });
* ```
*
* ### Setting Update Policy
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
*
* const sample = new aws.batch.ComputeEnvironment("sample", {
* name: "sample",
* computeResources: {
* allocationStrategy: "BEST_FIT_PROGRESSIVE",
* instanceRole: ecsInstance.arn,
* instanceTypes: ["optimal"],
* maxVcpus: 4,
* minVcpus: 0,
* securityGroupIds: [sampleAwsSecurityGroup.id],
* subnets: [sampleAwsSubnet.id],
* type: "EC2",
* },
* updatePolicy: {
* jobExecutionTimeoutMinutes: 30,
* terminateJobsOnUpdate: false,
* },
* type: "MANAGED",
* });
* ```
*
* ## Import
*
* Using `pulumi import`, import AWS Batch compute using the `name`. For example:
*
* ```sh
* $ pulumi import aws:batch/computeEnvironment:ComputeEnvironment sample sample
* ```
*/
class ComputeEnvironment extends pulumi.CustomResource {
/**
* Get an existing ComputeEnvironment 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 Any extra arguments used during the lookup.
* @param opts Optional settings to control the behavior of the CustomResource.
*/
static get(name, id, state, opts) {
return new ComputeEnvironment(name, state, { ...opts, id: id });
}
/**
* Returns true if the given object is an instance of ComputeEnvironment. This is designed to work even
* when multiple copies of the Pulumi SDK have been loaded into the same process.
*/
static isInstance(obj) {
if (obj === undefined || obj === null) {
return false;
}
return obj['__pulumiType'] === ComputeEnvironment.__pulumiType;
}
constructor(name, argsOrState, opts) {
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["arn"] = state?.arn;
resourceInputs["computeResources"] = state?.computeResources;
resourceInputs["ecsClusterArn"] = state?.ecsClusterArn;
resourceInputs["eksConfiguration"] = state?.eksConfiguration;
resourceInputs["name"] = state?.name;
resourceInputs["namePrefix"] = state?.namePrefix;
resourceInputs["region"] = state?.region;
resourceInputs["serviceRole"] = state?.serviceRole;
resourceInputs["state"] = state?.state;
resourceInputs["status"] = state?.status;
resourceInputs["statusReason"] = state?.statusReason;
resourceInputs["tags"] = state?.tags;
resourceInputs["tagsAll"] = state?.tagsAll;
resourceInputs["type"] = state?.type;
resourceInputs["updatePolicy"] = state?.updatePolicy;
}
else {
const args = argsOrState;
if (args?.type === undefined && !opts.urn) {
throw new Error("Missing required property 'type'");
}
resourceInputs["computeResources"] = args?.computeResources;
resourceInputs["eksConfiguration"] = args?.eksConfiguration;
resourceInputs["name"] = args?.name;
resourceInputs["namePrefix"] = args?.namePrefix;
resourceInputs["region"] = args?.region;
resourceInputs["serviceRole"] = args?.serviceRole;
resourceInputs["state"] = args?.state;
resourceInputs["tags"] = args?.tags;
resourceInputs["type"] = args?.type;
resourceInputs["updatePolicy"] = args?.updatePolicy;
resourceInputs["arn"] = undefined /*out*/;
resourceInputs["ecsClusterArn"] = undefined /*out*/;
resourceInputs["status"] = undefined /*out*/;
resourceInputs["statusReason"] = undefined /*out*/;
resourceInputs["tagsAll"] = undefined /*out*/;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(ComputeEnvironment.__pulumiType, name, resourceInputs, opts);
}
}
exports.ComputeEnvironment = ComputeEnvironment;
/** @internal */
ComputeEnvironment.__pulumiType = 'aws:batch/computeEnvironment:ComputeEnvironment';
//# sourceMappingURL=computeEnvironment.js.map
;