From 6c1d7f01149370754cea2b0281d3c0928f1c76b2 Mon Sep 17 00:00:00 2001 From: Luca Pizzini Date: Thu, 15 Jun 2023 10:46:22 +0200 Subject: [PATCH] fix(batch-alpha): cannot import FargateComputeEnvironment with fromFargateComputeEnvironmentArn --- .../aws-batch-alpha/lib/managed-compute-environment.ts | 10 ++++++---- .../test/managed-compute-environment.test.ts | 8 ++++++++ 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/packages/@aws-cdk/aws-batch-alpha/lib/managed-compute-environment.ts b/packages/@aws-cdk/aws-batch-alpha/lib/managed-compute-environment.ts index d5474bf0a9bf3..42308bb025919 100644 --- a/packages/@aws-cdk/aws-batch-alpha/lib/managed-compute-environment.ts +++ b/packages/@aws-cdk/aws-batch-alpha/lib/managed-compute-environment.ts @@ -1068,15 +1068,17 @@ export class FargateComputeEnvironment extends ManagedComputeEnvironmentBase imp const stack = Stack.of(scope); const computeEnvironmentName = stack.splitArn(fargateComputeEnvironmentArn, ArnFormat.SLASH_RESOURCE_NAME).resourceName!; - class Import extends ManagedComputeEnvironmentBase implements IFargateComputeEnvironment { + class Import extends Resource implements IFargateComputeEnvironment { public readonly computeEnvironmentArn = fargateComputeEnvironmentArn; public readonly computeEnvironmentName = computeEnvironmentName; public readonly enabled = true; + public readonly maxvCpus = 1; + public readonly connections = { } as any; + public readonly securityGroups = []; + public readonly tags: TagManager = new TagManager(TagType.MAP, 'AWS::Batch::ComputeEnvironment'); } - return new Import(scope, id, { - vpc: undefined as any, - }); + return new Import(scope, id); } public readonly computeEnvironmentName: string; diff --git a/packages/@aws-cdk/aws-batch-alpha/test/managed-compute-environment.test.ts b/packages/@aws-cdk/aws-batch-alpha/test/managed-compute-environment.test.ts index de649bfe3daee..37fa4113934c2 100644 --- a/packages/@aws-cdk/aws-batch-alpha/test/managed-compute-environment.test.ts +++ b/packages/@aws-cdk/aws-batch-alpha/test/managed-compute-environment.test.ts @@ -935,4 +935,12 @@ describe('FargateComputeEnvironment', () => { ComputeEnvironmentName: 'maxPropsFargateCE', }); }); + + test('can be imported from arn', () => { + // WHEN + const ce = FargateComputeEnvironment.fromFargateComputeEnvironmentArn(stack, 'import', 'arn:aws:batch:us-east-1:123456789012:compute-environment/ce-name'); + + // THEN + expect(ce.computeEnvironmentArn).toEqual('arn:aws:batch:us-east-1:123456789012:compute-environment/ce-name'); + }); });