Class Distribution
A CloudFront distribution with associated origin(s) and caching behavior(s).
Inherited Members
Namespace: Amazon.CDK.AWS.CloudFront
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public class Distribution : Resource, IDistribution, IResource
Syntax (vb)
Public Class Distribution
Inherits Resource
Implements IDistribution, IResource
Remarks
ExampleMetadata: infused
Examples
// Adding an existing Lambda@Edge function created in a different stack
// to a CloudFront distribution.
Bucket s3Bucket;
var functionVersion = Version.FromVersionArn(this, "Version", "arn:aws:lambda:us-east-1:123456789012:function:functionName:1");
new Distribution(this, "distro", new DistributionProps {
DefaultBehavior = new BehaviorOptions {
Origin = new S3Origin(s3Bucket),
EdgeLambdas = new [] { new EdgeLambda {
FunctionVersion = functionVersion,
EventType = LambdaEdgeEventType.VIEWER_REQUEST
} }
}
});
Synopsis
Constructors
Distribution(ByRefValue) | Used by jsii to construct an instance of this class from a Javascript-owned object reference |
Distribution(DeputyBase.DeputyProps) | Used by jsii to construct an instance of this class from DeputyProps |
Distribution(Construct, String, IDistributionProps) |
Properties
DistributionDomainName | The domain name of the Distribution, such as d111111abcdef8.cloudfront.net. |
DistributionId | The distribution ID for this distribution. |
DomainName | The domain name of the Distribution, such as d111111abcdef8.cloudfront.net. |
Methods
AddBehavior(String, IOrigin, IAddBehaviorOptions) | Adds a new behavior to this distribution for the given pathPattern. |
FromDistributionAttributes(Construct, String, IDistributionAttributes) | Creates a Distribution construct that represents an external (imported) distribution. |
Grant(IGrantable, String[]) | Adds an IAM policy statement associated with this distribution to an IAM principal's policy. |
GrantCreateInvalidation(IGrantable) | Grant to create invalidations for this bucket to an IAM principal (Role/Group/User). |
Metric(String, IMetricOptions) | Return the given named metric for this Distribution. |
Metric401ErrorRate(IMetricOptions) | Metric for the percentage of all viewer requests for which the response's HTTP status code is 401. |
Metric403ErrorRate(IMetricOptions) | Metric for the percentage of all viewer requests for which the response's HTTP status code is 403. |
Metric404ErrorRate(IMetricOptions) | Metric for the percentage of all viewer requests for which the response's HTTP status code is 404. |
Metric4xxErrorRate(IMetricOptions) | Metric for the percentage of all viewer requests for which the response's HTTP status code is 4xx. |
Metric502ErrorRate(IMetricOptions) | Metric for the percentage of all viewer requests for which the response's HTTP status code is 502. |
Metric503ErrorRate(IMetricOptions) | Metric for the percentage of all viewer requests for which the response's HTTP status code is 503. |
Metric504ErrorRate(IMetricOptions) | Metric for the percentage of all viewer requests for which the response's HTTP status code is 504. |
Metric5xxErrorRate(IMetricOptions) | Metric for the percentage of all viewer requests for which the response's HTTP status code is 5xx. |
MetricBytesDownloaded(IMetricOptions) | Metric for the total number of bytes downloaded by viewers for GET, HEAD, and OPTIONS requests. |
MetricBytesUploaded(IMetricOptions) | Metric for the total number of bytes that viewers uploaded to your origin with CloudFront, using POST and PUT requests. |
MetricCacheHitRate(IMetricOptions) | Metric for the percentage of all cacheable requests for which CloudFront served the content from its cache. |
MetricOriginLatency(IMetricOptions) | Metric for the total time spent from when CloudFront receives a request to when it starts providing a response to the network (not the viewer), for requests that are served from the origin, not the CloudFront cache. |
MetricRequests(IMetricOptions) | Metric for the total number of viewer requests received by CloudFront, for all HTTP methods and for both HTTP and HTTPS requests. |
MetricTotalErrorRate(IMetricOptions) | Metric for the percentage of all viewer requests for which the response's HTTP status code is 4xx or 5xx. |
Constructors
Distribution(ByRefValue)
Used by jsii to construct an instance of this class from a Javascript-owned object reference
protected Distribution(ByRefValue reference)
Parameters
- reference Amazon.JSII.Runtime.Deputy.ByRefValue
The Javascript-owned object reference
Distribution(DeputyBase.DeputyProps)
Used by jsii to construct an instance of this class from DeputyProps
protected Distribution(DeputyBase.DeputyProps props)
Parameters
- props Amazon.JSII.Runtime.Deputy.DeputyBase.DeputyProps
The deputy props
Distribution(Construct, String, IDistributionProps)
public Distribution(Construct scope, string id, IDistributionProps props)
Parameters
- scope Constructs.Construct
- id System.String
- props IDistributionProps
Properties
DistributionDomainName
The domain name of the Distribution, such as d111111abcdef8.cloudfront.net.
public virtual string DistributionDomainName { get; }
Property Value
System.String
DistributionId
The distribution ID for this distribution.
public virtual string DistributionId { get; }
Property Value
System.String
DomainName
The domain name of the Distribution, such as d111111abcdef8.cloudfront.net.
public virtual string DomainName { get; }
Property Value
System.String
Methods
AddBehavior(String, IOrigin, IAddBehaviorOptions)
Adds a new behavior to this distribution for the given pathPattern.
public virtual void AddBehavior(string pathPattern, IOrigin origin, IAddBehaviorOptions behaviorOptions = null)
Parameters
- pathPattern System.String
the path pattern (e.g., 'images/*') that specifies which requests to apply the behavior to.
- origin IOrigin
the origin to use for this behavior.
- behaviorOptions IAddBehaviorOptions
the options for the behavior at this path.
FromDistributionAttributes(Construct, String, IDistributionAttributes)
Creates a Distribution construct that represents an external (imported) distribution.
public static IDistribution FromDistributionAttributes(Construct scope, string id, IDistributionAttributes attrs)
Parameters
- scope Constructs.Construct
- id System.String
- attrs IDistributionAttributes
Returns
Grant(IGrantable, String[])
Adds an IAM policy statement associated with this distribution to an IAM principal's policy.
public virtual Grant Grant(IGrantable identity, params string[] actions)
Parameters
- identity IGrantable
The principal.
- actions System.String[]
The set of actions to allow (i.e. "cloudfront:ListInvalidations").
Returns
GrantCreateInvalidation(IGrantable)
Grant to create invalidations for this bucket to an IAM principal (Role/Group/User).
public virtual Grant GrantCreateInvalidation(IGrantable identity)
Parameters
- identity IGrantable
The principal.
Returns
Metric(String, IMetricOptions)
Return the given named metric for this Distribution.
public virtual Metric Metric(string metricName, IMetricOptions props = null)
Parameters
- metricName System.String
- props IMetricOptions
Returns
Metric401ErrorRate(IMetricOptions)
Metric for the percentage of all viewer requests for which the response's HTTP status code is 401.
public virtual Metric Metric401ErrorRate(IMetricOptions props = null)
Parameters
- props IMetricOptions
Returns
Remarks
To obtain this metric, you need to set publishAdditionalMetrics
to true
.
Default: - average over 5 minutes
Metric403ErrorRate(IMetricOptions)
Metric for the percentage of all viewer requests for which the response's HTTP status code is 403.
public virtual Metric Metric403ErrorRate(IMetricOptions props = null)
Parameters
- props IMetricOptions
Returns
Remarks
To obtain this metric, you need to set publishAdditionalMetrics
to true
.
Default: - average over 5 minutes
Metric404ErrorRate(IMetricOptions)
Metric for the percentage of all viewer requests for which the response's HTTP status code is 404.
public virtual Metric Metric404ErrorRate(IMetricOptions props = null)
Parameters
- props IMetricOptions
Returns
Remarks
To obtain this metric, you need to set publishAdditionalMetrics
to true
.
Default: - average over 5 minutes
Metric4xxErrorRate(IMetricOptions)
Metric for the percentage of all viewer requests for which the response's HTTP status code is 4xx.
public virtual Metric Metric4xxErrorRate(IMetricOptions props = null)
Parameters
- props IMetricOptions
Returns
Remarks
Default: - average over 5 minutes
Metric502ErrorRate(IMetricOptions)
Metric for the percentage of all viewer requests for which the response's HTTP status code is 502.
public virtual Metric Metric502ErrorRate(IMetricOptions props = null)
Parameters
- props IMetricOptions
Returns
Remarks
To obtain this metric, you need to set publishAdditionalMetrics
to true
.
Default: - average over 5 minutes
Metric503ErrorRate(IMetricOptions)
Metric for the percentage of all viewer requests for which the response's HTTP status code is 503.
public virtual Metric Metric503ErrorRate(IMetricOptions props = null)
Parameters
- props IMetricOptions
Returns
Remarks
To obtain this metric, you need to set publishAdditionalMetrics
to true
.
Default: - average over 5 minutes
Metric504ErrorRate(IMetricOptions)
Metric for the percentage of all viewer requests for which the response's HTTP status code is 504.
public virtual Metric Metric504ErrorRate(IMetricOptions props = null)
Parameters
- props IMetricOptions
Returns
Remarks
To obtain this metric, you need to set publishAdditionalMetrics
to true
.
Default: - average over 5 minutes
Metric5xxErrorRate(IMetricOptions)
Metric for the percentage of all viewer requests for which the response's HTTP status code is 5xx.
public virtual Metric Metric5xxErrorRate(IMetricOptions props = null)
Parameters
- props IMetricOptions
Returns
Remarks
Default: - average over 5 minutes
MetricBytesDownloaded(IMetricOptions)
Metric for the total number of bytes downloaded by viewers for GET, HEAD, and OPTIONS requests.
public virtual Metric MetricBytesDownloaded(IMetricOptions props = null)
Parameters
- props IMetricOptions
Returns
Remarks
Default: - sum over 5 minutes
MetricBytesUploaded(IMetricOptions)
Metric for the total number of bytes that viewers uploaded to your origin with CloudFront, using POST and PUT requests.
public virtual Metric MetricBytesUploaded(IMetricOptions props = null)
Parameters
- props IMetricOptions
Returns
Remarks
Default: - sum over 5 minutes
MetricCacheHitRate(IMetricOptions)
Metric for the percentage of all cacheable requests for which CloudFront served the content from its cache.
public virtual Metric MetricCacheHitRate(IMetricOptions props = null)
Parameters
- props IMetricOptions
Returns
Remarks
HTTP POST and PUT requests, and errors, are not considered cacheable requests.
To obtain this metric, you need to set publishAdditionalMetrics
to true
.
Default: - average over 5 minutes
MetricOriginLatency(IMetricOptions)
Metric for the total time spent from when CloudFront receives a request to when it starts providing a response to the network (not the viewer), for requests that are served from the origin, not the CloudFront cache.
public virtual Metric MetricOriginLatency(IMetricOptions props = null)
Parameters
- props IMetricOptions
Returns
Remarks
This is also known as first byte latency, or time-to-first-byte.
To obtain this metric, you need to set publishAdditionalMetrics
to true
.
Default: - average over 5 minutes
MetricRequests(IMetricOptions)
Metric for the total number of viewer requests received by CloudFront, for all HTTP methods and for both HTTP and HTTPS requests.
public virtual Metric MetricRequests(IMetricOptions props = null)
Parameters
- props IMetricOptions
Returns
Remarks
Default: - sum over 5 minutes
MetricTotalErrorRate(IMetricOptions)
Metric for the percentage of all viewer requests for which the response's HTTP status code is 4xx or 5xx.
public virtual Metric MetricTotalErrorRate(IMetricOptions props = null)
Parameters
- props IMetricOptions
Returns
Remarks
Default: - average over 5 minutes