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

fix(batch-alpha): cannot import FargateComputeEnvironment with fromFargateComputeEnvironmentArn #25985

Merged
merged 3 commits into from
Jun 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});
});