Class Distribution
Creates an Amazon CloudFront web distribution.
For information about CloudFront distributions, see the Amazon CloudFront Developer Guide. For specific information about creating CloudFront web distributions, see the POST Distribution page in the Amazon CloudFront API Reference.
NOTE: CloudFront distributions take about 15 minutes to a deployed state after creation or modification. During this time, deletes to resources will be blocked. If you need to delete a distribution that is enabled and you do not want to wait, you need to use the
retain_on_deleteflag.
Example Usage
using Pulumi;
using Aws = Pulumi.Aws;
class MyStack : Stack
{
public MyStack()
{
var bucket = new Aws.S3.Bucket("bucket", new Aws.S3.BucketArgs
{
Acl = "private",
Tags =
{
{ "Name", "My bucket" },
},
});
var s3OriginId = "myS3Origin";
var s3Distribution = new Aws.CloudFront.Distribution("s3Distribution", new Aws.CloudFront.DistributionArgs
{
Aliases =
{
"mysite.example.com",
"yoursite.example.com",
},
Comment = "Some comment",
DefaultCacheBehavior = new Aws.CloudFront.Inputs.DistributionDefaultCacheBehaviorArgs
{
AllowedMethods =
{
"DELETE",
"GET",
"HEAD",
"OPTIONS",
"PATCH",
"POST",
"PUT",
},
CachedMethods =
{
"GET",
"HEAD",
},
DefaultTtl = 3600,
ForwardedValues = new Aws.CloudFront.Inputs.DistributionDefaultCacheBehaviorForwardedValuesArgs
{
Cookies = new Aws.CloudFront.Inputs.DistributionDefaultCacheBehaviorForwardedValuesCookiesArgs
{
Forward = "none",
},
QueryString = false,
},
MaxTtl = 86400,
MinTtl = 0,
TargetOriginId = s3OriginId,
ViewerProtocolPolicy = "allow-all",
},
DefaultRootObject = "index.html",
Enabled = true,
IsIpv6Enabled = true,
LoggingConfig = new Aws.CloudFront.Inputs.DistributionLoggingConfigArgs
{
Bucket = "mylogs.s3.amazonaws.com",
IncludeCookies = false,
Prefix = "myprefix",
},
OrderedCacheBehaviors =
{
new Aws.CloudFront.Inputs.DistributionOrderedCacheBehaviorArgs
{
AllowedMethods =
{
"GET",
"HEAD",
"OPTIONS",
},
CachedMethods =
{
"GET",
"HEAD",
"OPTIONS",
},
Compress = true,
DefaultTtl = 86400,
ForwardedValues = new Aws.CloudFront.Inputs.DistributionOrderedCacheBehaviorForwardedValuesArgs
{
Cookies = new Aws.CloudFront.Inputs.DistributionOrderedCacheBehaviorForwardedValuesCookiesArgs
{
Forward = "none",
},
Headers =
{
"Origin",
},
QueryString = false,
},
MaxTtl = 31536000,
MinTtl = 0,
PathPattern = "/content/immutable/*",
TargetOriginId = s3OriginId,
ViewerProtocolPolicy = "redirect-to-https",
},
new Aws.CloudFront.Inputs.DistributionOrderedCacheBehaviorArgs
{
AllowedMethods =
{
"GET",
"HEAD",
"OPTIONS",
},
CachedMethods =
{
"GET",
"HEAD",
},
Compress = true,
DefaultTtl = 3600,
ForwardedValues = new Aws.CloudFront.Inputs.DistributionOrderedCacheBehaviorForwardedValuesArgs
{
Cookies = new Aws.CloudFront.Inputs.DistributionOrderedCacheBehaviorForwardedValuesCookiesArgs
{
Forward = "none",
},
QueryString = false,
},
MaxTtl = 86400,
MinTtl = 0,
PathPattern = "/content/*",
TargetOriginId = s3OriginId,
ViewerProtocolPolicy = "redirect-to-https",
},
},
Origins =
{
new Aws.CloudFront.Inputs.DistributionOriginArgs
{
DomainName = bucket.BucketRegionalDomainName,
OriginId = s3OriginId,
S3OriginConfig = new Aws.CloudFront.Inputs.DistributionOriginS3OriginConfigArgs
{
OriginAccessIdentity = "origin-access-identity/cloudfront/ABCDEFG1234567",
},
},
},
PriceClass = "PriceClass_200",
Restrictions = new Aws.CloudFront.Inputs.DistributionRestrictionsArgs
{
GeoRestriction = new Aws.CloudFront.Inputs.DistributionRestrictionsGeoRestrictionArgs
{
Locations =
{
"US",
"CA",
"GB",
"DE",
},
RestrictionType = "whitelist",
},
},
Tags =
{
{ "Environment", "production" },
},
ViewerCertificate = new Aws.CloudFront.Inputs.DistributionViewerCertificateArgs
{
CloudfrontDefaultCertificate = true,
},
});
}
}
Inherited Members
Namespace: Pulumi.Aws.CloudFront
Assembly: Pulumi.Aws.dll
Syntax
public class Distribution : CustomResource
Constructors
View SourceDistribution(String, DistributionArgs, CustomResourceOptions)
Create a Distribution resource with the given unique name, arguments, and options.
Declaration
public Distribution(string name, DistributionArgs args, CustomResourceOptions options = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | The unique name of the resource |
| DistributionArgs | args | The arguments used to populate this resource's properties |
| CustomResourceOptions | options | A bag of options that control this resource's behavior |
Properties
View SourceActiveTrustedSigners
The key pair IDs that CloudFront is aware of for each trusted signer, if the distribution is set up to serve private content with signed URLs.
Declaration
public Output<ImmutableDictionary<string, object>> ActiveTrustedSigners { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.Collections.Immutable.ImmutableDictionary<System.String, System.Object>> |
Aliases
Extra CNAMEs (alternate domain names), if any, for this distribution.
Declaration
public Output<ImmutableArray<string>> Aliases { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.Collections.Immutable.ImmutableArray<System.String>> |
Arn
The ARN (Amazon Resource Name) for the distribution. For example: arn:aws:cloudfront::123456789012:distribution/EDFDVBD632BHDS5, where 123456789012 is your AWS account ID.
Declaration
public Output<string> Arn { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
CallerReference
Internal value used by CloudFront to allow future updates to the distribution configuration.
Declaration
public Output<string> CallerReference { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
Comment
Any comments you want to include about the distribution.
Declaration
public Output<string> Comment { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
CustomErrorResponses
One or more custom error response elements (multiples allowed).
Declaration
public Output<ImmutableArray<DistributionCustomErrorResponse>> CustomErrorResponses { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.Collections.Immutable.ImmutableArray<DistributionCustomErrorResponse>> |
DefaultCacheBehavior
The default cache behavior for this distribution (maximum one).
Declaration
public Output<DistributionDefaultCacheBehavior> DefaultCacheBehavior { get; }
Property Value
| Type | Description |
|---|---|
| Output<DistributionDefaultCacheBehavior> |
DefaultRootObject
The object that you want CloudFront to return (for example, index.html) when an end user requests the root URL.
Declaration
public Output<string> DefaultRootObject { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
DomainName
The DNS domain name of either the S3 bucket, or web site of your custom origin.
Declaration
public Output<string> DomainName { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
Enabled
Whether the distribution is enabled to accept end user requests for content.
Declaration
public Output<bool> Enabled { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.Boolean> |
Etag
The current version of the distribution's information. For example:
E2QWRUHAPOMQZL.
Declaration
public Output<string> Etag { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
HostedZoneId
The CloudFront Route 53 zone ID that can be used to
route an Alias Resource Record Set to. This attribute is simply an
alias for the zone ID Z2FDTNDATAQYW2.
Declaration
public Output<string> HostedZoneId { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
HttpVersion
The maximum HTTP version to support on the
distribution. Allowed values are http1.1 and http2. The default is
http2.
Declaration
public Output<string> HttpVersion { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
InProgressValidationBatches
The number of invalidation batches currently in progress.
Declaration
public Output<int> InProgressValidationBatches { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.Int32> |
IsIpv6Enabled
Whether the IPv6 is enabled for the distribution.
Declaration
public Output<bool?> IsIpv6Enabled { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.Nullable<System.Boolean>> |
LastModifiedTime
The date and time the distribution was last modified.
Declaration
public Output<string> LastModifiedTime { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
LoggingConfig
The logging configuration that controls how logs are written to your distribution (maximum one).
Declaration
public Output<DistributionLoggingConfig> LoggingConfig { get; }
Property Value
| Type | Description |
|---|---|
| Output<DistributionLoggingConfig> |
OrderedCacheBehaviors
An ordered list of cache behaviors resource for this distribution. List from top to bottom in order of precedence. The topmost cache behavior will have precedence 0.
Declaration
public Output<ImmutableArray<DistributionOrderedCacheBehavior>> OrderedCacheBehaviors { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.Collections.Immutable.ImmutableArray<DistributionOrderedCacheBehavior>> |
OriginGroups
One or more origin_group for this distribution (multiples allowed).
Declaration
public Output<ImmutableArray<DistributionOriginGroup>> OriginGroups { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.Collections.Immutable.ImmutableArray<DistributionOriginGroup>> |
Origins
One or more origins for this distribution (multiples allowed).
Declaration
public Output<ImmutableArray<DistributionOrigin>> Origins { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.Collections.Immutable.ImmutableArray<DistributionOrigin>> |
PriceClass
The price class for this distribution. One of
PriceClass_All, PriceClass_200, PriceClass_100
Declaration
public Output<string> PriceClass { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
Restrictions
The restriction configuration for this distribution (maximum one).
Declaration
public Output<DistributionRestrictions> Restrictions { get; }
Property Value
| Type | Description |
|---|---|
| Output<DistributionRestrictions> |
RetainOnDelete
Disables the distribution instead of
deleting it when destroying the resource. If this is set,
the distribution needs to be deleted manually afterwards. Default: false.
Declaration
public Output<bool?> RetainOnDelete { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.Nullable<System.Boolean>> |
Status
The current status of the distribution. Deployed if the
distribution's information is fully propagated throughout the Amazon
CloudFront system.
Declaration
public Output<string> Status { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
Tags
A map of tags to assign to the resource.
Declaration
public Output<ImmutableDictionary<string, object>> Tags { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.Collections.Immutable.ImmutableDictionary<System.String, System.Object>> |
ViewerCertificate
The SSL configuration for this distribution (maximum one).
Declaration
public Output<DistributionViewerCertificate> ViewerCertificate { get; }
Property Value
| Type | Description |
|---|---|
| Output<DistributionViewerCertificate> |
WaitForDeployment
If enabled, the resource will wait for
the distribution status to change from InProgress to Deployed. Setting
this tofalse will skip the process. Default: true.
Declaration
public Output<bool?> WaitForDeployment { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.Nullable<System.Boolean>> |
WebAclId
If you're using AWS WAF to filter CloudFront
requests, the Id of the AWS WAF web ACL that is associated with the
distribution. The WAF Web ACL must exist in the WAF Global (CloudFront)
region and the credentials configuring this argument must have
waf:GetWebACL permissions assigned.
Declaration
public Output<string> WebAclId { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
Methods
View SourceGet(String, Input<String>, DistributionState, CustomResourceOptions)
Get an existing Distribution resource's state with the given name, ID, and optional extra properties used to qualify the lookup.
Declaration
public static Distribution Get(string name, Input<string> id, DistributionState state = null, CustomResourceOptions options = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | The unique name of the resulting resource. |
| Input<System.String> | id | The unique provider ID of the resource to lookup. |
| DistributionState | state | Any extra arguments used during the lookup. |
| CustomResourceOptions | options | A bag of options that control this resource's behavior |
Returns
| Type | Description |
|---|---|
| Distribution |