From 5f0ee88ff1e618a3f3c50dec7308c4da279e42ac Mon Sep 17 00:00:00 2001 From: Adam Ruka Date: Tue, 16 Feb 2021 01:19:04 -0800 Subject: [PATCH] fix(codecommit): take the region and account of an imported Repository from its ARN (#13066) To align it with how other resources work, for example [S3 Buckets](https://github.com/aws/aws-cdk/blob/c6256992902fc4237ceb9f965e970e2c2ef00777/packages/%40aws-cdk/aws-s3/lib/bucket.ts#L1285-L1286). Fixes #13025 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- packages/@aws-cdk/aws-codecommit/lib/repository.ts | 5 ++++- packages/@aws-cdk/aws-codecommit/test/test.codecommit.ts | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/@aws-cdk/aws-codecommit/lib/repository.ts b/packages/@aws-cdk/aws-codecommit/lib/repository.ts index c1bd88ff6d4f6..495be2f981d86 100644 --- a/packages/@aws-cdk/aws-codecommit/lib/repository.ts +++ b/packages/@aws-cdk/aws-codecommit/lib/repository.ts @@ -310,7 +310,10 @@ export class Repository extends RepositoryBase { public readonly repositoryCloneUrlGrc = makeCloneUrl(stack, repositoryName, 'grc', region); } - return new Import(scope, id); + return new Import(scope, id, { + account: arn.account, + region, + }); } public static fromRepositoryName(scope: Construct, id: string, repositoryName: string): IRepository { diff --git a/packages/@aws-cdk/aws-codecommit/test/test.codecommit.ts b/packages/@aws-cdk/aws-codecommit/test/test.codecommit.ts index 954c48561758a..1f49f852b1e57 100644 --- a/packages/@aws-cdk/aws-codecommit/test/test.codecommit.ts +++ b/packages/@aws-cdk/aws-codecommit/test/test.codecommit.ts @@ -104,6 +104,9 @@ export = { test.deepEqual(stack.resolve(repo.repositoryCloneUrlGrc), 'codecommit::us-west-2://my-repo'); + test.deepEqual(repo.env.account, '585695036304'); + test.deepEqual(repo.env.region, 'us-west-2'); + test.done(); },