Skip to content

Commit

Permalink
fix(codecommit): take the region and account of an imported Repositor…
Browse files Browse the repository at this point in the history
…y 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*
  • Loading branch information
skinny85 authored Feb 16, 2021
1 parent 8d51ac9 commit 5f0ee88
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/@aws-cdk/aws-codecommit/lib/repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 3 additions & 0 deletions packages/@aws-cdk/aws-codecommit/test/test.codecommit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
},

Expand Down

0 comments on commit 5f0ee88

Please sign in to comment.