CloudfrontConfig¶
Bases: BaseModel, NameValidationMixin, AwsTypesValidationMixin
Configuration model for AWS CloudFront distribution with multi-origin support.
Defines the complete structure and validation rules for CloudFront distributions supporting multiple origin types including S3 buckets, Application Load Balancers, and VPC origins. Enforces AWS requirements for SSL certificates, WAF integration, and Route53 DNS management with comprehensive origin validation.
The configuration requires a 'default' S3 origin and supports additional origins with unique path patterns for content routing and delivery optimization.
Attributes:
| Name | Type | Description |
|---|---|---|
origins |
Dict[str, CloudfrontOrigin]
|
Dictionary of origin configurations with required 'default' S3 origin |
ssl_certificate_id |
str
|
SSL certificate ID located in us-east-1 for CloudFront |
web_acl_id |
Optional[str]
|
Optional AWS WAF Web ACL ID for security protection |
logs_bucket |
Optional[Any]
|
Optional S3 bucket for CloudFront access logging |
route53 |
Route53Config
|
Route53 configuration for domain and DNS record management |
activate_additional_metrics |
bool
|
Wheter to enable additional metrics for the distribution |
Source code in mare_aws_common_lib/models/cloudfront_config.py
309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 | |
typed
property
¶
Access to type-safe AWS CDK resource properties.
Provides access to the Typed inner class for strongly-typed CDK resource references, improving IDE support and type checking capabilities.
Returns:
| Type | Description |
|---|---|
Typed
|
Typed accessor instance for CDK resource properties |
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 CloudFront distribution configuration.
Source code in mare_aws_common_lib/models/cloudfront_config.py
339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 | |
logs_bucket
property
¶
S3 bucket for CloudFront access logs storage.
Returns:
| Type | Description |
|---|---|
IBucket
|
Strongly-typed S3 bucket interface for logging configuration |
validate_logs_bucket(value)
classmethod
¶
Validate S3 logs bucket CDK construct compatibility.
Ensures the provided logs bucket object implements the required s3.IBucket interface for proper CloudFront logging integration and access control.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
Any
|
S3 bucket CDK construct for logging |
required |
Returns:
| Type | Description |
|---|---|
Any
|
Validated S3 bucket construct or None if not provided |
Raises:
| Type | Description |
|---|---|
ValueError
|
If bucket doesn't implement required interface |
Source code in mare_aws_common_lib/models/cloudfront_config.py
372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 | |
validate_origins_structure()
¶
Validate origins configuration structure and uniqueness constraints.
Ensures the origins dictionary contains a required 'default' S3 origin and validates that all origin path patterns are unique to prevent routing conflicts in the CloudFront distribution configuration.
Returns:
| Type | Description |
|---|---|
CloudfrontConfig
|
Self after validation |
Raises:
| Type | Description |
|---|---|
ValueError
|
If default S3 origin is missing, has wrong type, or path patterns conflict |
Source code in mare_aws_common_lib/models/cloudfront_config.py
391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 | |
Example
from mare_aws_common_lib.models import CloudfrontConfig, S3OriginConfig, LoadBalancerOriginConfig, VpcOriginConfig, Route53Config
config = CloudfrontConfig(
origins={
# Required default S3 origin for static content
"default": S3OriginConfig(
name="static-assets",
bucket=static_bucket,
path="/assets",
default_root_object="index.html"
),
# API origin via Application Load Balancer
"api": LoadBalancerOriginConfig(
name="api-backend",
path="/api/*",
alb=api_alb,
timeout=45
),
# Private VPC origin for internal services
"internal": VpcOriginConfig(
name="internal-services",
path="/internal/*",
alb=api_alb,
timeout=30
)
},
ssl_certificate_id="12345678-1234-1234-1234-123456789012",
web_acl_id="arn:aws:wafv2:us-east-1:123456789012:global/webacl/example/12345678-1234-1234-1234-123456789012",
logs_bucket=logs_bucket,
route53=Route53Config(
hosted_zone_id="Z1234567890ABC",
domain_name="mycompany.com"
)
CloudfrontOrigin¶
CloudFront distributions support multiple origin types through a discriminated union:
S3OriginConfig
¶
Bases: BaseModel, AwsTypesValidationMixin, PathValidationMixin, NameValidationMixin
Configuration model for CloudFront S3 bucket origin.
Defines the structure and validation rules for S3 bucket origins in CloudFront distributions, supporting static content delivery with configurable path patterns and default root object settings for web applications and content hosting.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
Origin identifier for CloudFront distribution configuration |
origin_type |
Literal['S3']
|
Fixed literal value identifying this as an S3 origin |
bucket |
Any
|
S3 bucket CDK construct reference for content storage |
path |
Optional[str]
|
Optional path pattern for content routing within the bucket |
default_root_object |
str
|
Default file served for root requests to the origin |
Source code in mare_aws_common_lib/models/cloudfront_config.py
13 14 15 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 | |
validate_origin_name(value)
classmethod
¶
Validate the origin name using organizational naming standards.
Applies origin-specific naming validation to ensure the name meets CloudFront origin identification requirements and organizational standards.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
str
|
Raw origin name from configuration |
required |
Returns:
| Type | Description |
|---|---|
str
|
Validated origin name |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the origin name fails validation rules |
Source code in mare_aws_common_lib/models/cloudfront_config.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | |
validate_path(value)
classmethod
¶
Validate the path pattern format for S3 content routing.
Ensures that any provided path pattern follows proper URL path conventions and CloudFront routing requirements for S3 bucket content access.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
str
|
Raw path pattern from configuration |
required |
Returns:
| Type | Description |
|---|---|
str
|
Validated path pattern or None if not provided |
Raises:
| Type | Description |
|---|---|
ValueError
|
If path pattern format is invalid |
Source code in mare_aws_common_lib/models/cloudfront_config.py
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | |
validate_s3_bucket(value)
classmethod
¶
Validate S3 bucket CDK construct compatibility.
Ensures the provided bucket object implements the required s3.IBucket interface for proper CloudFront origin integration and access control.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
Any
|
S3 bucket CDK construct |
required |
Returns:
| Type | Description |
|---|---|
Any
|
Validated S3 bucket construct |
Raises:
| Type | Description |
|---|---|
ValueError
|
If bucket doesn't implement required interface |
Source code in mare_aws_common_lib/models/cloudfront_config.py
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | |
Example
from mare_aws_common_lib.models import S3OriginConfig
config = S3OriginConfig(
name="static-assets",
bucket=static_bucket,
path="/assets",
default_root_object="index.html"
)
LoadBalancerOriginConfig
¶
Bases: BaseModel, AwsTypesValidationMixin, PathValidationMixin, NameValidationMixin
Configuration model for CloudFront Application Load Balancer origin.
Defines the structure and validation rules for ALB origins in CloudFront distributions, enabling dynamic content delivery through load balancer endpoints with configurable timeout settings and path-based routing.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
Origin identifier for CloudFront distribution configuration |
origin_type |
Literal['LOAD_BALANCER']
|
Fixed literal value identifying this as a load balancer origin |
path |
str
|
Path pattern for routing requests to this origin (e.g., '/api/*') |
alb |
Any
|
Application Load Balancer CDK construct reference |
timeout |
int
|
Origin response timeout in seconds (1-180, warnings >60) |
Source code in mare_aws_common_lib/models/cloudfront_config.py
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 | |
validate_alb(value)
classmethod
¶
Validate Application Load Balancer CDK construct compatibility.
Ensures the provided ALB object implements the required interface for proper CloudFront origin integration and traffic forwarding.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
Any
|
Application Load Balancer CDK construct |
required |
Returns:
| Type | Description |
|---|---|
Any
|
Validated ALB construct |
Raises:
| Type | Description |
|---|---|
ValueError
|
If ALB doesn't implement required interface |
Source code in mare_aws_common_lib/models/cloudfront_config.py
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 | |
validate_origin_name(value)
classmethod
¶
Validate the origin name using organizational naming standards.
Applies origin-specific naming validation to ensure the name meets CloudFront origin identification requirements and organizational standards.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
str
|
Raw origin name from configuration |
required |
Returns:
| Type | Description |
|---|---|
str
|
Validated origin name |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the origin name fails validation rules |
Source code in mare_aws_common_lib/models/cloudfront_config.py
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | |
validate_path(value)
classmethod
¶
Validate the path pattern format for load balancer routing.
Ensures the path pattern follows proper URL path conventions and CloudFront routing requirements for ALB backend integration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
str
|
Raw path pattern from configuration |
required |
Returns:
| Type | Description |
|---|---|
str
|
Validated path pattern |
Raises:
| Type | Description |
|---|---|
ValueError
|
If path pattern format is invalid |
Source code in mare_aws_common_lib/models/cloudfront_config.py
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 | |
validate_timeout(value)
classmethod
¶
Validate origin response timeout settings and AWS quota compliance.
Ensures timeout values are within AWS CloudFront limits and provides warnings for values that require quota increase requests in the target AWS account for successful deployment.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
int
|
Origin response timeout in seconds |
required |
Returns:
| Type | Description |
|---|---|
int
|
Validated timeout value |
Raises:
| Type | Description |
|---|---|
ValueError
|
If timeout is outside allowed range (1-180 seconds) |
Source code in mare_aws_common_lib/models/cloudfront_config.py
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 | |
Example
from mare_aws_common_lib.models import LoadBalancerOriginConfig
config = LoadBalancerOriginConfig(
name="api-backend",
path="/api/*",
alb=api_alb,
timeout=45
)
VpcOriginConfig
¶
Bases: BaseModel, AwsTypesValidationMixin, PathValidationMixin, NameValidationMixin
Configuration model for CloudFront VPC origin with private load balancer.
Defines the structure and validation rules for VPC-based origins in CloudFront distributions, enabling private network integration through VPC origins for secure communication with internal load balancers and services.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
Origin identifier for CloudFront distribution configuration |
origin_type |
Literal['VPC_ORIGIN']
|
Fixed literal value identifying this as a VPC origin |
path |
str
|
Path pattern for routing requests to this origin (e.g., '/api/*') |
alb |
Any
|
Application Load Balancer CDK construct reference within VPC |
timeout |
int
|
Origin response timeout in seconds (1-180, warnings >60) |
Source code in mare_aws_common_lib/models/cloudfront_config.py
198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 | |
validate_alb(value)
classmethod
¶
Validate Application Load Balancer CDK construct compatibility.
Ensures the provided ALB object implements the required interface for proper CloudFront VPC origin integration and private traffic routing.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
Any
|
Application Load Balancer CDK construct |
required |
Returns:
| Type | Description |
|---|---|
Any
|
Validated ALB construct |
Raises:
| Type | Description |
|---|---|
ValueError
|
If ALB doesn't implement required interface |
Source code in mare_aws_common_lib/models/cloudfront_config.py
258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 | |
validate_origin_name(value)
classmethod
¶
Validate the origin name using organizational naming standards.
Applies origin-specific naming validation to ensure the name meets CloudFront origin identification requirements and organizational standards.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
str
|
Raw origin name from configuration |
required |
Returns:
| Type | Description |
|---|---|
str
|
Validated origin name |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the origin name fails validation rules |
Source code in mare_aws_common_lib/models/cloudfront_config.py
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 | |
validate_path(value)
classmethod
¶
Validate the path pattern format for VPC origin routing.
Ensures the path pattern follows proper URL path conventions and CloudFront routing requirements for VPC-based backend integration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
str
|
Raw path pattern from configuration |
required |
Returns:
| Type | Description |
|---|---|
str
|
Validated path pattern |
Raises:
| Type | Description |
|---|---|
ValueError
|
If path pattern format is invalid |
Source code in mare_aws_common_lib/models/cloudfront_config.py
239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 | |
validate_timeout(value)
classmethod
¶
Validate origin response timeout settings and AWS quota compliance.
Ensures timeout values are within AWS CloudFront limits and provides warnings for values that require quota increase requests in the target AWS account for successful deployment.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
int
|
Origin response timeout in seconds |
required |
Returns:
| Type | Description |
|---|---|
int
|
Validated timeout value |
Raises:
| Type | Description |
|---|---|
ValueError
|
If timeout is outside allowed range (1-180 seconds) |
Source code in mare_aws_common_lib/models/cloudfront_config.py
277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 | |
Example
from mare_aws_common_lib.models import VpcOriginConfig
config = VpcOriginConfig(
name="internal-services",
path="/internal/*",
alb=api_alb,
timeout=30
)