Skip to content

Conversation

@droguljic
Copy link
Contributor

Exposing CloudFront as a independent component adds flexibility and supports use cases such as multiple origins per distribution. Three types of behaviors are supported:

  • S3, tailored for S3 origins with auto-configuration including cache policy oriented towards static assets and response headers policy with security headers.
  • LB, tailored for ALB origins with auto-configuration including cache policy for dynamic content and response headers policy with security headers.
  • Custom, configurable option with by default disabled caching.

Exposing CloudFront as a independent component adds flexibility and
supports use cases such as multiple origins per distribution.
Three types of behaviors are supported:
- S3, tailored for S3 origins with auto-configuration including cache
policy oriented towards static assets and response headers policy with
security headers.
- LB, tailored for ALB origins with auto-configuration including cache
policy for dynamic content and response headers policy with security
headers.
- Custom, configurable option with by default disabled caching.
@droguljic droguljic added the Don't merge Do not merge this PR label Jan 9, 2026
export class CloudFront extends pulumi.ComponentResource {
name: string;
distribution: aws.cloudfront.Distribution;
acmCertificate?: AcmCertificate;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we are exposing the acmCertificate prop but in a case where we send a certificate, this prop will be undefined. Would it be better to unify them both under one prop?

Comment on lines +8 to +12
export enum BehaviorType {
S3 = 's3',
LB = 'lb',
CUSTOM = 'custom',
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to move this to types.ts?

cachePolicy: aws.cloudfront.CachePolicy;
originRequestPolicy?: aws.cloudfront.OriginRequestPolicy;
responseHeadersPolicy?: aws.cloudfront.ResponseHeadersPolicy;
getPathConfig: () => aws.types.input.cloudfront.DistributionOrderedCacheBehavior;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need this method, i don't see it being used anywhere?

pathPattern: string;
config: aws.types.input.cloudfront.DistributionDefaultCacheBehavior;
cachePolicy: aws.cloudfront.CachePolicy;
originRequestPolicy?: aws.cloudfront.OriginRequestPolicy;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this since it’s not being set anywhere?
I see we already have an originRequestPolicyId though.

orderedCaches,
domain,
certificate,
defaultRoot,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we name this defaultRootObject as the prop name?

private createDistributionOrigins(
behaviors: CloudFront.Args['behaviors'],
): pulumi.Output<aws.types.input.cloudfront.DistributionOrigin[]> {
return pulumi.all(behaviors.map(b => pulumi.output(b))).apply(entries => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return pulumi.all(behaviors.map(b => pulumi.output(b))).apply(entries => {
return pulumi.output(behaviors).apply(entries => {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Don't merge Do not merge this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants