Skip to content

aws-batch-alpha: unable to import FargateComputeEnvironment with from_fargate_compute_environment_arn #25979

@roketworks

Description

@roketworks

Describe the bug

When importing a fargate compute environment that is created outside of the stack the following error occurs:

jsii.errors.JavaScriptError:
  @jsii/kernel.RuntimeError: TypeError: Cannot read properties of undefined (reading 'vpcId')
      at Kernel._ensureSync (/private/var/folders/01/8c7x7kn954573yk8__rn5d9m0000gn/T/tmpduoq304b/lib/program.js:10369:27)
      at Kernel.sinvoke (/private/var/folders/01/8c7x7kn954573yk8__rn5d9m0000gn/T/tmpduoq304b/lib/program.js:9790:34)
      at KernelHost.processRequest (/private/var/folders/01/8c7x7kn954573yk8__rn5d9m0000gn/T/tmpduoq304b/lib/program.js:11544:36)
      at KernelHost.run (/private/var/folders/01/8c7x7kn954573yk8__rn5d9m0000gn/T/tmpduoq304b/lib/program.js:11504:22)
      at Immediate._onImmediate (/private/var/folders/01/8c7x7kn954573yk8__rn5d9m0000gn/T/tmpduoq304b/lib/program.js:11505:46)
      at process.processImmediate (node:internal/timers:478:21)

Expected Behavior

The resource gets imported and can be referenced

Current Behavior

The error occurs and unable reference resources

Reproduction Steps

  • Create 2 batch compute environments, one fargate and one ECS.
# Works
ecs_compute_arn = 'arn:aws:batch:us-east-1:xxx:compute-environment/ecs-compute'
ecs_compute_env = batch.ManagedEc2EcsComputeEnvironment.from_managed_ec2_ecs_compute_environment_arn(
    self, 'FargateComputeEnv', managed_ec2_ecs_compute_environment_arn=ecs_compute_arn
)
queue = batch.JobQueue(self, 'Queue', job_queue_name='queue')
queue.add_compute_environment(ecs_compute_env, 1)

# Error occurs
fargate_compute_arn = 'arn:aws:batch:us-east-1:xxx:compute-environment/fargate-compute'
fargate_compute_env = batch.FargateComputeEnvironment.from_fargate_compute_environment_arn(
    self, 'FargateComputeEnv', fargate_compute_environment_arn=fargate_compute_arn
)
queue = batch.JobQueue(self, 'Queue', job_queue_name='queue')
queue.add_compute_environment(fargate_compute_env, 1)

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.81.0

Framework Version

2.83.1

Node.js Version

v19.8.1

OS

Mac OS 12.6

Language

Python

Language Version

3.11

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    @aws-cdk/aws-batchRelated to AWS BatchbugThis issue is a bug.effort/smallSmall work item – less than a day of effortgood first issueRelated to contributions. See CONTRIBUTING.mdp1

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions