Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(aws-batch): create fargate environment with Cfn classes #12329

Closed
mazerte opened this issue Jan 4, 2021 · 2 comments
Closed

(aws-batch): create fargate environment with Cfn classes #12329

mazerte opened this issue Jan 4, 2021 · 2 comments
Assignees
Labels
@aws-cdk/aws-batch Related to AWS Batch bug This issue is a bug. duplicate This issue is a duplicate.

Comments

@mazerte
Copy link

mazerte commented Jan 4, 2021

Hello,

I got a lot of trouble to create a Fargate environment in AWS Batch with the CDK. The problem is only linked to a type issues. When you when to create a Fargate compute environment you shouldn't provide instanceRole, instanceTypes and minvCpu but the CDK enforce it.

Reproduction Steps

    const batchRole = new iam.Role(this, 'BatchRole', {
      assumedBy: new iam.ServicePrincipal('batch.amazonaws.com'),
      managedPolicies: [
        iam.ManagedPolicy.fromAwsManagedPolicyName('service-role/AWSBatchServiceRole')
      ],
    });

    const sg = new ec2.CfnSecurityGroup(this, 'ComputeEnvironmentSG', {
      vpcId: vpcId.valueAsString,
      groupDescription: 'Bust Tests Environment Security Group'
    })
    
    const computeEnvironment = new batch.CfnComputeEnvironment(this, 'ComputeEnvironment', {
      type: 'MANAGED',
      serviceRole: batchRole.roleArn,
      computeResources: {
        type: 'FARGATE_SPOT',
        subnets: subnets.valueAsList,
        maxvCpus: 256,
        securityGroupIds: [
          sg.ref
        ]
      }
    });

What did you expect to happen?

I don't expect to see type errors

What actually happened?

The CDK isn't able to compile the stack due to the errors

Environment

  • CDK CLI Version : 1.82
  • Framework Version:
  • Node.js Version: v12.19.0
  • OS : MacOS
  • Language (Version): TypeScript (3.8.3) (guessing all)

Other

I try to fix the error locally by manually editing @aws-cdk/aws-batch/lib/batch.generated.d.ts by adding ? to the concerned porperties and @aws-cdk/aws-batch/lib/batch.generated.ts by commenting the lines errors.collect(cdk.propertyValidator('instanceRole', cdk.requiredValidator)(properties.instanceRole)); (and the others). After that everything work fine on CloudFormation side.


This is 🐛 Bug Report

@mazerte mazerte added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jan 4, 2021
@github-actions github-actions bot added the @aws-cdk/aws-batch Related to AWS Batch label Jan 4, 2021
@iliapolo
Copy link
Contributor

iliapolo commented Jan 4, 2021

Closing as duplicate of #12028.

See #12028 (comment) for a workaround.

@iliapolo iliapolo closed this as completed Jan 4, 2021
@iliapolo iliapolo added duplicate This issue is a duplicate. and removed needs-triage This issue or PR still needs to be triaged. labels Jan 4, 2021
@github-actions
Copy link

github-actions bot commented Jan 4, 2021

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-batch Related to AWS Batch bug This issue is a bug. duplicate This issue is a duplicate.
Projects
None yet
Development

No branches or pull requests

2 participants