Skip to content

Conversation

@stephnr
Copy link
Contributor

@stephnr stephnr commented Oct 28, 2019

WORK IN PROGRESS - Submitted for early review

This PR includes 3 pattern constructs under the @aws-cdk/batch package:

  • JobDefinition
  • JobQueue
  • ComputeEnvironment

Each of them expanding upon the existing underlying Cfn generated classes to help construct AWS Batch resources. A few caveats worth noticing:

  1. Creating a Batch Job Queue with no config will create a batch compute environment for you based on the default settings in the AWS Console UI
  2. Creating a Batch Compute Environment with no provided properties will also create a default compute environment for you based on the default AWS VPC.

☝️ These points were introduced to mimic the functionality of the ec2.Vpc(...) construct.


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@stephnr stephnr requested a review from skinny85 as a code owner October 28, 2019 23:21
@mergify
Copy link
Contributor

mergify bot commented Oct 28, 2019

Thanks so much for taking the time to contribute to the AWS CDK ❤️

We will shortly assign someone to review this pull request and help get it
merged. In the meantime, please take a minute to make sure you follow this
checklist
:

  • PR title type(scope): text
    • type: fix, feat, refactor go into CHANGELOG, chore is hidden
    • scope: name of module without aws- or cdk- prefix or postfix (e.g. s3 instead of aws-s3-deployment)
    • text: use all lower-case, do not end with a period, do not include issue refs
  • PR Description
    • Rationale: describe rationale of change and approach taken
    • Issues: indicate issues fixed via: fixes #xxx or closes #xxx
    • Breaking?: last paragraph: BREAKING CHANGE: <describe what changed + link for details>
  • Testing
    • Unit test added. Prefer to add a new test rather than modify existing tests
    • CLI or init templates change? Re-run/add CLI integration tests
  • Documentation
    • README: update module README to describe new features
    • API docs: public APIs must be documented. Copy from official AWS docs when possible
    • Design: for significant features, follow design process

@stephnr stephnr changed the title Close #3536 - Add Batch Pattern Constructs close #3536 - add batch pattern constructs Oct 28, 2019
@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

Copy link
Contributor

@skinny85 skinny85 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great first draft!

/**
* The IAM role applied to EC2 resources in the compute environment.
*/
readonly instanceRole: iam.IRole;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We always create Roles by default if a customer doesn't pass one. This should be optional (readonly instanceRole?: iam.IRole).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect, I will go ahead and fix this.

*
* @default optimal
*/
readonly instanceTypes?: ec2.InstanceType[];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you clarify why does this need to be an array? (This is an honest question, maybe I'm missing something)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A very good question, its because of the instance types property type here in the Cloudformation documentation for the AWS::Batch::ComputeEnvironment resource.


/**
* The minimum number of EC2 vCPUs that an environment should maintain (even if the compute environment state is DISABLED).
* Each vCPU is equivalent to 1,024 CPU shares. You must specify at least one vCPU.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment ("You must specify at least one vCPU.") is in direction contradiction to the default of 0.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good eye 👍 I will adjust it.

/**
* The VPC subnets into which the compute resources are launched.
*/
readonly subnets: ec2.ISubnet[];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be consistent with the rest of the Construct Library, this should be instead a pair of properties:

readonly vpc: ec2.IVpc;

readonly vpcSubnets?: ec2.SubnetSelection;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect, I didn't see this earlier but this makes a lot of sense.

/**
* The desired number of EC2 vCPUS in the compute environment. Each vCPU
* is equivalent to 1,024 CPU shares. You must specify at least one vCPU.
*/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Default description missing.

});

const jobQueue = new CfnJobQueue(this, 'Resource', {
computeEnvironmentOrder: props.computeEnvironmentOrder ? props.computeEnvironmentOrder.map(cp => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation is off here:

            computeEnvironmentOrder: props.computeEnvironmentOrder
              ? props.computeEnvironmentOrder.map(cp => ({
                    computeEnvironment: cp.computeEnvironment.computeEnvironmentArn,
                    order: cp.order,
                } as CfnJobQueue.ComputeEnvironmentOrderProperty)
              ) 
              : [
                {
                    computeEnvironment: new ComputeEnvironment(this, 'Resource-Batch-Compute-Environment').computeEnvironmentArn,
                    order: 1,
                },
              ],

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it 👍

computeEnvironment: cp.computeEnvironment.computeEnvironmentArn,
order: cp.order,
} as CfnJobQueue.ComputeEnvironmentOrderProperty;
}) : [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here (indent of the ?: expression.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it. I copied out your recommendation from another conversation here but lets review it after you take a look again.

"@aws-cdk/aws-ec2": "1.14.0",
"@aws-cdk/aws-iam": "1.14.0",
"@aws-cdk/core": "1.14.0",
"@aws-cdk/aws-ecs": "1.14.0"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try to have dependencies and peerDependencies in the same, alphabetical, order.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright 👍

};

const app = new cdk.App();
const stack = new cdk.Stack(app, 'test-batch-job-queue', { env });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think neither env nor app are needed for this test.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it 👍

},
},
}
}; No newline at end of file
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, since this is adding the first L2 code, can you use Jest instead of NodeUnit? You have examples in the repo of other packages using Jest (like IAM).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Jest would be perfect! I am much more comfortable testing using that.

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@stephnr
Copy link
Contributor Author

stephnr commented Nov 13, 2019

@skinny85 the updates based on your comments have been published now

@skinny85
Copy link
Contributor

Thanks @stephnr - I'll take a look this week!

Copy link
Contributor

@skinny85 skinny85 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the update @stephnr -- we're getting closer!

Can you change the indentation to 2 spaces please?

Thanks,
Adam

* the jobs in the queue, with a preference for instance types that are less
* likely to be interrupted
*/
SPOT_CAPACITY_OPTIMIZED = 'SPOT_CAPACITY_OPTIMIZED',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Empty lines here:

export enum AllocationStrategy {
    /**
     * Batch will use the best fitting instance type will be used
     * when assigning a batch job in this compute environment
     */
    BEST_FIT = 'BEST_FIT',

    /**
     * Batch will select additional instance types that are large enough to
     * meet the requirements of the jobs in the queue, with a preference for
     * instance types with a lower cost per unit vCPU
     */
    BEST_FIT_PROGRESSIVE = 'BEST_FIT_PROGRESSIVE',

    /**
     * This is only available for Spot Instance compute resources and will select
     * additional instance types that are large enough to meet the requirements of
     * the jobs in the queue, with a preference for instance types that are less
     * likely to be interrupted
     */
    SPOT_CAPACITY_OPTIMIZED = 'SPOT_CAPACITY_OPTIMIZED',
}

Same comment for all enums above.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it 👍

/**
* AWS Batch manages your compute resources
*/
MANAGED = 'MANAGED',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't align these. It's just not worth it (adding a third value that's longer than the previous ones would make for a horrible diff). Just have MANAGED = 'MANAGED'.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, I have an alignment tool but good point.

/**
* Resources will be EC2 On-Demand resources
*/
EC2 = 'EC2',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't ON_DEMAND be a better name for this then?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It woulddddddd. Lets enforce some naming practices :P haha. I will swap this out.

* Property to determine if AWS Batch
* should manage your compute resources
*/
export enum ComputeEnvironmentType {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering whether this enum is worth it. Wouldn't it be simpler to just have managed?: boolean as a creation property of ComputeEnvironment? I think we're trying to mirror the API too closely, instead of aiming for simplicity.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, that is a better idea. I agree. I will swap this out.

/**
* Property to specify how compute resources will be provisioned based
*/
export enum ComputeEnvironmentStatus {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same exact comment. To me, this is simply an enabled?: boolean creation property.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it 👍

});

// THEN
const expectedProps = expectedUnmanagedDefaultComputeProps({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here (inline expectedProps).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it

test.ok(true, 'No tests are specified for this package.');
test.done();
}
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need at least one integ test as well.

Copy link
Contributor Author

@stephnr stephnr Nov 24, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will write one up. Just a basic one for SPOT & ON_DEMAND. Will we need more?

import { ResourcePart } from '@aws-cdk/assert/lib/assertions/have-resource';
import { InstanceClass, InstanceSize, InstanceType } from '@aws-cdk/aws-ec2';
import { Repository } from '@aws-cdk/aws-ecr';
import { EcrImage, LinuxParameters, MountPoint, Ulimit, Volume } from '@aws-cdk/aws-ecs';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, don't import any classes (other than from the @aws-cdk/core package) directly. Always refer to them with a prefix.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it 👍

// THEN
expect(job.jobDefinitionArn).toEqual(existingJob.jobDefinitionArn);
});
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

General comment: I'm not a fan of helper methods in tests. I think it's better to use before to set things up:

describe('Batch Job Definition', () => {
    let stack: cdk.Stack;
    let jobDefProps: batch.JobDefinitionProps;

    beforeEach(() => {
        stack = new cdk.Stack();

        const jobRepo = new Repository(stack, 'job-repo');

        const role = new iam.Role(stack, 'job-role', {
            assumedBy: new iam.ServicePrincipal('batch.amazonaws.com'),
        });

        const linuxParams = new LinuxParameters(stack, 'job-linux-params', {
            initProcessEnabled: true,
            sharedMemorySize: 1,
        });

        jobDefProps = {
            jobDefinitionName: 'test-job',
            containerProps: {
                command: [ 'echo "Hello World"' ],
                environment: {
                    foo: 'bar',
                },
                jobRole: role,
                gpuCount: 1,
                image: EcrImage.fromEcrRepository(jobRepo),
                instanceType: InstanceType.of(InstanceClass.T2, InstanceSize.MICRO),
                linuxParams,
                memoryLimitMiB: 1,
                mountPoints: new Array<MountPoint>(),
                privileged: true,
                readOnly: true,
                ulimits: new Array<Ulimit>(),
                user: 'root',
                vcpus: 2,
                volumes: new Array<Volume>(),
            },
            nodeProps: {
                count: 2,
                mainNode: 1,
                rangeProps: new Array<batch.INodeRangeProps>(),
            },
            parameters: {
                foo: 'bar',
            },
            retryAttempts: 2,
            timeout: Duration.seconds(30),
        };
    });

    test('renders the correct CloudFormation resource', () => {
        new batch.JobDefinition(stack, 'JobDefinition', jobDefProps);

        expect(stack).toHaveResourceLike('AWS::Batch::JobDefinition', {
            JobDefinitionName: jobDefProps.jobDefinitionName,
            ContainerProperties: jobDefProps.containerProps ? {
                Command: jobDefProps.containerProps.command,
                Environment: [
                    {
                        Name: 'foo',
                        Value: 'bar',
                    },
                ],
                InstanceType: jobDefProps.containerProps.instanceType.toString(),
                LinuxParameters: {},
                Memory: jobDefProps.containerProps.memoryLimitMiB,
                MountPoints: [],
                Privileged: jobDefProps.containerProps.privileged,
                ReadonlyRootFilesystem: jobDefProps.containerProps.readOnly,
                Ulimits: [],
                User: jobDefProps.containerProps.user,
                Vcpus: jobDefProps.containerProps.vcpus,
                Volumes: [],
            } : undefined,
            NodeProperties: jobDefProps.nodeProps ? {
                MainNode: jobDefProps.nodeProps.mainNode,
                NodeRangeProperties: [],
                NumNodes: jobDefProps.nodeProps.count,
            } : undefined,
            Parameters: {
                foo: 'bar',
            },
            RetryStrategy: {
                Attempts: jobDefProps.retryAttempts,
            },
            Timeout: {
                AttemptDurationSeconds: jobDefProps.timeout ? jobDefProps.timeout.toSeconds() : -1,
            },
            Type: 'container',
        });
    });

    test('can be imported from an ARN', () => {
        const importedJob = batch.JobDefinition.fromJobDefinitionArn(stack, 'job-def-clone',
          'arn:aws:batch:us-east-1:123456789012:job-definition/job-def-name:1');

        // THEN
        expect(importedJob.jobDefinitionName).toEqual('job-def-name');
        expect(importedJob.jobDefinitionArn).toEqual('arn:aws:batch:us-east-1:123456789012:job-definition/job-def-name:1');
    });
});

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it 👌

@stephnr
Copy link
Contributor Author

stephnr commented Nov 28, 2019 via email

Comment on lines 342 to 346
instanceRole: props.computeResources.instanceRole ?
props.computeResources.instanceRole.roleArn :
new iam.Role(this, 'Resource-Role', {
assumedBy: new iam.ServicePrincipal('batch.amazonaws.com'),
}).roleArn,
Copy link
Contributor

@bweigel bweigel Nov 29, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey. Ran into another hickup. This will fail, because Cloudformation expects an Instance Profile, not a role:

5/7 | 1:08:40 PM | CREATE_FAILED        | AWS::Batch::ComputeEnvironment | compute-env (computeenv5B70C65C)
    Operation failed, ComputeEnvironment went INVALID with error: 
    CLIENT_ERROR - Invalid IamInstanceProfile: arn:aws:iam::0123456789:role/batch-compute-env-stack-computeenvResourceRole92B0-Q4UIZBETE6B1

You will need to create a new iam.CfnInstanceProfile.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good eye, I fixed this up now. We needed to make sure to use the service-role/AWSBatchServiceRole.

I didn't need to end up using that L0 construct.

@stephnr
Copy link
Contributor Author

stephnr commented Nov 29, 2019

@skinny85 next round of updates is update. Thanks to some things @bweigel noticed, I made adjustments to use the correct service role for the batch compute environment.

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

Copy link
Contributor

@skinny85 skinny85 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @stephnr ! Before I review - can you please please change the indentation to 2 spaces? This is the standard we use in the entire CDK project.

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify mergify bot dismissed skinny85’s stale review December 2, 2019 00:17

Pull request has been modified.

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@stephnr
Copy link
Contributor Author

stephnr commented Dec 5, 2019

@skinny85 next round of updates is ready w/ updated integration tests 👍 I made it work this time around with using Container images from any registry, ECR, or even a local asset image.

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@skinny85
Copy link
Contributor

skinny85 commented Dec 7, 2019

@skinny85 next round of updates is ready w/ updated integration tests 👍 I made it work this time around with using Container images from any registry, ECR, or even a local asset image.

Thanks @stephnr ! I'm at re:Invent this week, so I'll look at the PR next week.

@mergify
Copy link
Contributor

mergify bot commented Dec 16, 2019

Thanks so much for taking the time to contribute to the AWS CDK ❤️

We will shortly assign someone to review this pull request and help get it
merged. In the meantime, please take a minute to make sure you follow this
checklist
:

  • PR title type(scope): text
    • type: fix, feat, refactor go into CHANGELOG, chore is hidden
    • scope: name of module without aws- or cdk- prefix or postfix (e.g. s3 instead of aws-s3-deployment)
    • text: use all lower-case, do not end with a period, do not include issue refs
  • PR Description
    • Rationale: describe rationale of change and approach taken
    • Issues: indicate issues fixed via: fixes #xxx or closes #xxx
    • Breaking?: last paragraph: BREAKING CHANGE: <describe what changed + link for details>
  • Testing
    • Unit test added. Prefer to add a new test rather than modify existing tests
    • CLI or init templates change? Re-run/add CLI integration tests
  • Documentation
    • README: update module README to describe new features
    • API docs: public APIs must be documented. Copy from official AWS docs when possible
    • Design: for significant features, follow design process

2 similar comments
@mergify
Copy link
Contributor

mergify bot commented Dec 16, 2019

Thanks so much for taking the time to contribute to the AWS CDK ❤️

We will shortly assign someone to review this pull request and help get it
merged. In the meantime, please take a minute to make sure you follow this
checklist
:

  • PR title type(scope): text
    • type: fix, feat, refactor go into CHANGELOG, chore is hidden
    • scope: name of module without aws- or cdk- prefix or postfix (e.g. s3 instead of aws-s3-deployment)
    • text: use all lower-case, do not end with a period, do not include issue refs
  • PR Description
    • Rationale: describe rationale of change and approach taken
    • Issues: indicate issues fixed via: fixes #xxx or closes #xxx
    • Breaking?: last paragraph: BREAKING CHANGE: <describe what changed + link for details>
  • Testing
    • Unit test added. Prefer to add a new test rather than modify existing tests
    • CLI or init templates change? Re-run/add CLI integration tests
  • Documentation
    • README: update module README to describe new features
    • API docs: public APIs must be documented. Copy from official AWS docs when possible
    • Design: for significant features, follow design process

@mergify
Copy link
Contributor

mergify bot commented Dec 16, 2019

Thanks so much for taking the time to contribute to the AWS CDK ❤️

We will shortly assign someone to review this pull request and help get it
merged. In the meantime, please take a minute to make sure you follow this
checklist
:

  • PR title type(scope): text
    • type: fix, feat, refactor go into CHANGELOG, chore is hidden
    • scope: name of module without aws- or cdk- prefix or postfix (e.g. s3 instead of aws-s3-deployment)
    • text: use all lower-case, do not end with a period, do not include issue refs
  • PR Description
    • Rationale: describe rationale of change and approach taken
    • Issues: indicate issues fixed via: fixes #xxx or closes #xxx
    • Breaking?: last paragraph: BREAKING CHANGE: <describe what changed + link for details>
  • Testing
    • Unit test added. Prefer to add a new test rather than modify existing tests
    • CLI or init templates change? Re-run/add CLI integration tests
  • Documentation
    • README: update module README to describe new features
    • API docs: public APIs must be documented. Copy from official AWS docs when possible
    • Design: for significant features, follow design process

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@stephnr
Copy link
Contributor Author

stephnr commented Feb 9, 2020

@skinny85 are the build failures above due to other peoples work? I don't see what is wrong 🤔

@skinny85
Copy link
Contributor

skinny85 commented Feb 10, 2020

@stephnr I think you need to rebase/merge once more, now that 1.23.0 has been released.

I would do it myself, but GitHub shows some conflicts.

(The problem is that the newest version is now 1.23.0, and your changes based on 1.22.0 make our compatibility checker report errors for "removing" things that were added between 1.22.0 and 1.23.0 - the check is happening in the opposite direction)

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: ad19323
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: 9268345
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: 0fb5aca
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: 15f5e79
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: ebcca67
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@skinny85
Copy link
Contributor

Thanks @stephnr ! I addressed a few cosmetic comments from the PR that you missed, and resolved the conflicts with latest. I have no further comments, so I'm merging the PR.

Thanks so much for your perseverance with sticking with this PR for so long!

@skinny85 skinny85 merged commit c8a22b1 into aws:master Feb 24, 2020
@skinny85
Copy link
Contributor

@stephnr actually, there's one more thing. Would you open another PR, updating the ReadMe of the module, explaining how to use the new beautiful constructs?

@stephnr
Copy link
Contributor Author

stephnr commented Feb 29, 2020 via email

@wleepang
Copy link

wleepang commented Mar 1, 2020

This is a great addition to the CDK and something I'll be using in the near term.

Quick question - is there a reason that specifying a Launch Template for a Compute Environment is missing?
(See: https://docs.aws.amazon.com/batch/latest/userguide/launch-templates.html)

It is a capability of AWS Batch that I prefer to use over custom AMIs.

@stephnr
Copy link
Contributor Author

stephnr commented Mar 2, 2020

@wleepang good question! I believe the reason why we didn't add this support yet is because that feature is not yet implemented in Cloudformation.

Once it has been added to the Cloudformation spec for Batch, we can then update these constructs to match.

@wleepang
Copy link

wleepang commented Mar 2, 2020

Can you clarify? I have created CloudFormation templates for Batch Compute Environments with Launch Templates for a while now.

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-batch-computeenvironment-launchtemplatespecification.html

@andrestone
Copy link
Contributor

andrestone commented Mar 2, 2020

Thanks for the PR.

This implementation needs further review.

The concept of "Managed Compute Environments" is misinterpreted and there are many silent unexpected behaviours happening because of that.

I'll be working on a patch to fix these things and an implementation for the Launch Template. Is there any API design rule that prevents requiring dev interaction with L0 constructs? It would be for the launch template. I can't think of any useful abstraction for it since it's already super simple.

The usage would be something like this:

    const myLaunchTemplate = new ec2.CfnLaunchTemplate(this, 'LaunchTemplate', {
      launchTemplateName: 'extra-storage-template',
      launchTemplateData: {
        blockDeviceMappings: [
          {
            deviceName: '/dev/xvdcz',
            ebs: {
              encrypted: true,
              volumeSize: 100,
              volumeType: 'gp2'
            }
          }
        ]
      }
    });

and then

    const myComputeEnv = new batch.ComputeEnvironment(this, 'ComputeEnv', {
      computeResources: {
        launchTemplate: {
          launchTemplateName: myLaunchTemplate.launchTemplateName as string,
        },
        vpc,
      },
      computeEnvironmentName: 'MyStorageCapableComputeEnvironment',
    });

cc @skinny85 @bweigel

@stephnr
Copy link
Contributor Author

stephnr commented Mar 2, 2020 via email

@stephnr
Copy link
Contributor Author

stephnr commented Mar 5, 2020

Thanks for the PR.

This implementation needs further review.

The concept of "Managed Compute Environments" is misinterpreted and there are many silent unexpected behaviours happening because of that.

I'll be working on a patch to fix these things and an implementation for the Launch Template. Is there any API design rule that prevents requiring dev interaction with L0 constructs? It would be for the launch template. I can't think of any useful abstraction for it since it's already super simple.

The usage would be something like this:

    const myLaunchTemplate = new ec2.CfnLaunchTemplate(this, 'LaunchTemplate', {
      launchTemplateName: 'extra-storage-template',
      launchTemplateData: {
        blockDeviceMappings: [
          {
            deviceName: '/dev/xvdcz',
            ebs: {
              encrypted: true,
              volumeSize: 100,
              volumeType: 'gp2'
            }
          }
        ]
      }
    });

and then

    const myComputeEnv = new batch.ComputeEnvironment(this, 'ComputeEnv', {
      computeResources: {
        launchTemplate: {
          launchTemplateName: myLaunchTemplate.launchTemplateName as string,
        },
        vpc,
      },
      computeEnvironmentName: 'MyStorageCapableComputeEnvironment',
    });

cc @skinny85 @bweigel

This looks promising! Would you be interested in whipping together a PR to get this supported? I can help you review and develop it further as well.

@andrestone
Copy link
Contributor

This looks promising! Would you be interested in whipping together a PR to get this supported? I can help you review and develop it further as well.

It's done. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants