@@ -41,6 +41,7 @@ class EcrRepoDataClass:
4141 cdk_id : str
4242 ecr_name : str
4343 allow_scrutinice_pull : bool = False
44+ allow_codebuild_pull : bool = False
4445
4546
4647class PrivateEcrStackV2 (Stack ):
@@ -89,20 +90,25 @@ def __init__(self,
8990 for x in [
9091 EcrRepoDataClass ("aws-lc-ecr-ubuntu" , UBUNTU_ECR_REPO ),
9192 EcrRepoDataClass ("aws-lc-ecr-amazonlinux" ,
92- AMAZONLINUX_ECR_REPO , allow_scrutinice_pull = True ),
93+ AMAZONLINUX_ECR_REPO ,
94+ allow_scrutinice_pull = True ,
95+ allow_codebuild_pull = True ),
9396 EcrRepoDataClass ("aws-lc-ecr-fedora" , FEDORA_ECR_REPO ),
9497 EcrRepoDataClass ("aws-lc-ecr-centos" , CENTOS_ECR_REPO ),
9598 EcrRepoDataClass ("aws-lc-ecr-windows" , WINDOWS_ECR_REPO ),
9699 EcrRepoDataClass ("aws-lc-ecr-verification" , VERIFICATION_ECR_REPO ),
97100 EcrRepoDataClass ("aws-lc-ecr-android" , ANDROID_ECR_REPO ),
98101 ]:
99- EcrPrivateRepo (self , x .cdk_id , repo_name = x .ecr_name , allow_scrutinice_pull = x .allow_scrutinice_pull )
102+ EcrPrivateRepo (self , x .cdk_id , repo_name = x .ecr_name ,
103+ allow_scrutinice_pull = x .allow_scrutinice_pull ,
104+ allow_codebuild_pull = x .allow_codebuild_pull )
100105
101106
102107class EcrPrivateRepo (Construct ):
103108 """Define private ECR repository to store container images."""
104109
105- def __init__ (self , scope : Construct , id : str , repo_name : str , * , allow_scrutinice_pull : bool , ** kwargs ) -> None :
110+ def __init__ (self , scope : Construct , id : str , repo_name : str , * , allow_scrutinice_pull : bool ,
111+ allow_codebuild_pull : bool , ** kwargs ) -> None :
106112 super ().__init__ (scope , id , ** kwargs )
107113
108114 self .repo = ecr .Repository (
@@ -114,3 +120,5 @@ def __init__(self, scope: Construct, id: str, repo_name: str, *, allow_scrutinic
114120 )
115121 if allow_scrutinice_pull :
116122 self .repo .grant_pull (iam .ArnPrincipal (SCRUTINICE_PRINCIPAL_ROLE_ARN ))
123+ if allow_codebuild_pull :
124+ self .repo .grant_pull (iam .ServicePrincipal ("codebuild.amazonaws.com" ))
0 commit comments