CodebuildConfig¶
Bases: BaseModel, AwsTypesValidationMixin
Configuration model for AWS CodeBuild project creation and management.
Defines the structure and validation rules for creating CodeBuild projects with support for different project types (standalone projects vs pipeline projects), various git providers, ECR integration, and comprehensive AWS resource validation.
Attributes:
| Name | Type | Description |
|---|---|---|
vpc |
Any
|
VPC for CodeBuild project execution |
role |
Any
|
IAM role with permissions for CodeBuild operations |
codebuild_type |
CodebuildType
|
Type of CodeBuild project (PROJECT or PIPELINE_PROJECT) |
buildspec_path |
str
|
Path to the buildspec.yml file in the repository |
ecr_repo |
Optional[Any]
|
ECR repository for container image storage (PROJECT type only) |
git_provider |
Optional[GitProvider]
|
Git provider for source code (currently supports CodeCommit only) |
git_repo |
Optional[Any]
|
Git repository containing source code (PROJECT type only) |
git_branch |
Optional[str]
|
Git branch to build from (PROJECT type only) |
pipeline_type |
Optional[PipelineType]
|
Pipeline integration type (PIPELINE_PROJECT type only) |
ami_ecr_repo |
Optional[Any]
|
ECR repository for AMI builds (PIPELINE_PROJECT type only) |
env_vars |
Optional[Dict[str, Any]]
|
Environment variables for build execution (PIPELINE_PROJECT type only) |
usage_context |
Optional[str]
|
Context information for build usage |
logs_bucket |
Optional[Any]
|
S3 bucket for storing build logs |
security_groups |
Optional[List[Any]]
|
A list of security groups to attach to the codebuild |
privileged |
bool
|
Enable privileged mode for Docker builds |
compute_type |
ComputeType
|
CodeBuild compute capacity (SMALL, MEDIUM, LARGE, etc.) |
build_image |
Any
|
Build environment image (Amazon Linux, Ubuntu, Windows, etc.) |
create_build_scheduler |
bool
|
Enable scheduled builds |
build_after_deployment |
bool
|
Trigger build immediately after project creation |
Source code in mare_aws_common_lib/models/codebuild_config.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 | |
typed
property
¶
Access to type-safe AWS CDK resource properties, references the Typed inner class.
Typed
¶
Inner class, type-safe accessor for AWS CDK resources with proper typing.
Provides strongly-typed access to AWS CDK resources for improved IDE support and type checking in CodeBuild project configuration.
Source code in mare_aws_common_lib/models/codebuild_config.py
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 | |
build_image
property
¶
CodeBuild environment image.
ecr_repo
property
¶
ECR repository for container image storage.
git_repo
property
¶
Git repository for source code.
logs_bucket
property
¶
S3 bucket for build logs storage.
role
property
¶
IAM role for CodeBuild project permissions.
vpc
property
¶
VPC for CodeBuild project execution.
validate_build_image_type(value)
classmethod
¶
Validate build image is proper CodeBuild image type.
Source code in mare_aws_common_lib/models/codebuild_config.py
171 172 173 174 175 176 177 | |
validate_codebuild_config()
¶
Validate complete configuration based on CodeBuild project type.
Ensures that required fields are present for each project type and prevents invalid field combinations across different project types.
Returns:
| Type | Description |
|---|---|
CodebuildConfig
|
Self with validated configuration |
Raises:
| Type | Description |
|---|---|
ValueError
|
If required fields are missing for the specified project type |
ValueError
|
If fields specific to other project types are present |
Source code in mare_aws_common_lib/models/codebuild_config.py
179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 | |
validate_ecr_repo(value, info)
classmethod
¶
Validate repository objects implement proper CDK interfaces.
Source code in mare_aws_common_lib/models/codebuild_config.py
139 140 141 142 143 144 145 146 147 | |
validate_env_vars(value)
classmethod
¶
Validate environment variables are proper CodeBuild format.
Source code in mare_aws_common_lib/models/codebuild_config.py
165 166 167 168 169 | |
validate_git_provider(value)
classmethod
¶
Validate git provider is supported (currently CodeCommit only).
Source code in mare_aws_common_lib/models/codebuild_config.py
149 150 151 152 153 154 155 | |
validate_logs_bucket(value)
classmethod
¶
Validate S3 bucket object implements s3.IBucket interface.
Source code in mare_aws_common_lib/models/codebuild_config.py
158 159 160 161 162 | |
validate_role_field(value)
classmethod
¶
Validate IAM role object implements iam.IRole interface.
Source code in mare_aws_common_lib/models/codebuild_config.py
133 134 135 136 137 | |
validate_vpc_field(value)
classmethod
¶
Validate VPC object implements ec2.IVpc interface.
Source code in mare_aws_common_lib/models/codebuild_config.py
127 128 129 130 131 | |
Example
from mare_aws_common_lib.models import CodebuildConfig
from mare_aws_common_lib.enums import CodebuildType, GitProvider
config = CodebuildConfig(
vpc=vpc,
role=codebuild_role,
codebuild_type=CodebuildType.PROJECT,
buildspec_path="buildspec.yml",
ecr_repo=ecr_repository,
git_provider=GitProvider.CODECOMMIT,
git_repo=git_repository,
git_branch="main",
privileged=True,
build_after_deployment=True
)