Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CloudFront] Distribution - Advanced cache behavior control #9107

Closed
2 tasks
njlynch opened this issue Jul 16, 2020 · 6 comments
Closed
2 tasks

[CloudFront] Distribution - Advanced cache behavior control #9107

njlynch opened this issue Jul 16, 2020 · 6 comments
Assignees
Labels
@aws-cdk/aws-cloudfront Related to Amazon CloudFront effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. needs-cfn This issue is waiting on changes to CloudFormation before it can be addressed. p1

Comments

@njlynch
Copy link
Contributor

njlynch commented Jul 16, 2020

Expand the new Distribution behaviors to support custom TTLs, configuring forwarded values, and other caching properties.

For completeness, the following are the set of L1 properties that are missing from the current L2:

  • cachedMethods
  • compress
  • defaultTtl
  • fieldLevelEncryptionId
  • maxTtl
  • minTtl
  • smoothStreaming
  • trustedSigners
  • viewerProtocolPolicy
  • forwardedValues
    • cookies
    • headers

(This ignores Lambda, which is being tracked separately in #9108)

Proposed Solution

See aws/aws-cdk-rfcs#171.

  • 👋 I may be able to implement this feature request
  • ⚠️ This feature might incur a breaking change

This is a 🚀 Feature Request

@njlynch njlynch added feature-request A feature should be added or improved. effort/medium Medium work item – several days of effort labels Jul 16, 2020
@njlynch njlynch self-assigned this Jul 16, 2020
@github-actions github-actions bot added the @aws-cdk/aws-cloudfront Related to Amazon CloudFront label Jul 16, 2020
@skinny85 skinny85 assigned skinny85 and unassigned njlynch Jul 22, 2020
@skinny85 skinny85 assigned njlynch and unassigned skinny85 and iliapolo Jul 22, 2020
@ivawzh
Copy link

ivawzh commented Jul 27, 2020

I think this is a bug (at least a documentation bug).

allowedMethods, defaultTtl and viewerProtocolPolicy are documented everywhere at https://docs.aws.amazon.com/cdk/api/latest/docs/aws-cloudfront-readme.html. E.g.

const myWebDistribution = new cloudfront.Distribution(this, 'myDist', {
  defaultBehavior: {
    origin: cloudfront.Origin.fromBucket(myBucket),
    allowedMethods: AllowedMethods.ALLOW_ALL,
    viewerProtocolPolicy: ViewerProtocolPolicy.REDIRECT_TO_HTTPS,
  }
});

But it's not in type declarations

export interface AddBehaviorOptions {
    /**
     * HTTP methods to allow for this behavior.
     *
     * @default - GET and HEAD
     */
    readonly allowedMethods?: AllowedMethods;
    /**
     * Whether CloudFront will forward query strings to the origin.
     * If this is set to true, CloudFront will forward all query parameters to the origin, and cache
     * based on all parameters. See `forwardQueryStringCacheKeys` for a way to limit the query parameters
     * CloudFront caches on.
     *
     * @default false
     */
    readonly forwardQueryString?: boolean;
    /**
     * A set of query string parameter names to use for caching if `forwardQueryString` is set to true.
     *
     * @default []
     */
    readonly forwardQueryStringCacheKeys?: string[];
}
/**
 * Options for creating a new behavior.
 *
 * @experimental
 */
export interface BehaviorOptions extends AddBehaviorOptions {
    /**
     * The origin that you want CloudFront to route requests to when they match this behavior.
     */
    readonly origin: Origin;
}

njlynch added a commit that referenced this issue Aug 3, 2020
…er protocol, and smooth streaming

Adds support for many of the missing properties for controlling behaviors on
the new Distribution construct. Also removed (currently unavailable) properties
from the README.

The remaining properties will come in a follow-up PR. They were not included
in this PR due to either being blocked by the latest CloudFormation spec merge,
or are still being prioritized (e.g., fieldLevelEncryption).

related #7086
related #9107
@njlynch
Copy link
Contributor Author

njlynch commented Aug 3, 2020

This work is going to be split into 2 (or 3) different PRs:

  1. Add the "simple" top-level properties: cachedMethods, compress, smoothStreaming, and viewerProtocolPolicy (feat(cloudfront): Behaviors support cached methods, compression, viewer protocol, and smooth streaming #9411).
  2. Add support for the new cache policies and origin request policies. These two new features (released July 21) replace many of the cache control properties (e.g., ttls, forwarded values) and origin behaviors (e.g., origin headers). This may be better suited to two different PRs.

The remaining two properties (trustedSigners and fieldLevelEncryptionId) require pre-work in the console or SDK to create and manage public keys prior to associating them with a Distribution. Supporting this in a high-quality way is significantly more work and research suggests this are not widely used properties; this are currently considered out of scope for dev preview.

mergify bot pushed a commit that referenced this issue Aug 3, 2020
…er protocol, and smooth streaming (#9411)

Adds support for many of the missing properties for controlling behaviors on
the new Distribution construct. Also removed (currently unavailable) properties
from the README.

The remaining properties will come in a follow-up PR. They were not included
in this PR due to either being blocked by the latest CloudFormation spec merge,
or are still being prioritized (e.g., fieldLevelEncryption).

related #7086
related #9107


----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@njlynch njlynch added the p1 label Aug 4, 2020
eladb pushed a commit that referenced this issue Aug 10, 2020
…er protocol, and smooth streaming (#9411)

Adds support for many of the missing properties for controlling behaviors on
the new Distribution construct. Also removed (currently unavailable) properties
from the README.

The remaining properties will come in a follow-up PR. They were not included
in this PR due to either being blocked by the latest CloudFormation spec merge,
or are still being prioritized (e.g., fieldLevelEncryption).

related #7086
related #9107


----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
curtiseppel pushed a commit to curtiseppel/aws-cdk that referenced this issue Aug 11, 2020
…er protocol, and smooth streaming (aws#9411)

Adds support for many of the missing properties for controlling behaviors on
the new Distribution construct. Also removed (currently unavailable) properties
from the README.

The remaining properties will come in a follow-up PR. They were not included
in this PR due to either being blocked by the latest CloudFormation spec merge,
or are still being prioritized (e.g., fieldLevelEncryption).

related aws#7086
related aws#9107


----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@njlynch njlynch added the needs-cfn This issue is waiting on changes to CloudFormation before it can be addressed. label Aug 11, 2020
@njlynch
Copy link
Contributor Author

njlynch commented Aug 12, 2020

Related to #9644 and #9647, which will add support for the new policies.

@nabedge
Copy link

nabedge commented Sep 30, 2020

I would be very happy if "forwarded cookies" configuration method support !
Regards.

@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

@salihoglu87
Copy link

@njlynch is it possible forward QueryStrings or Cookies? as the @nabedge mentioned.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-cloudfront Related to Amazon CloudFront effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. needs-cfn This issue is waiting on changes to CloudFormation before it can be addressed. p1
Projects
None yet
Development

No branches or pull requests

6 participants