DistributionArgs

data class DistributionArgs(val aliases: Output<List<String>>? = null, val comment: Output<String>? = null, val customErrorResponses: Output<List<DistributionCustomErrorResponseArgs>>? = null, val defaultCacheBehavior: Output<DistributionDefaultCacheBehaviorArgs>? = null, val defaultRootObject: Output<String>? = null, val enabled: Output<Boolean>? = null, val httpVersion: Output<String>? = null, val isIpv6Enabled: Output<Boolean>? = null, val loggingConfig: Output<DistributionLoggingConfigArgs>? = null, val orderedCacheBehaviors: Output<List<DistributionOrderedCacheBehaviorArgs>>? = null, val originGroups: Output<List<DistributionOriginGroupArgs>>? = null, val origins: Output<List<DistributionOriginArgs>>? = null, val priceClass: Output<String>? = null, val restrictions: Output<DistributionRestrictionsArgs>? = null, val retainOnDelete: Output<Boolean>? = null, val tags: Output<Map<String, String>>? = null, val viewerCertificate: Output<DistributionViewerCertificateArgs>? = null, val waitForDeployment: Output<Boolean>? = null, val webAclId: Output<String>? = null) : ConvertibleToJava<DistributionArgs>

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 reach 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_delete flag.

Example Usage

The following example below creates a CloudFront distribution with an S3 origin.

package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.s3.BucketV2;
import com.pulumi.aws.s3.BucketV2Args;
import com.pulumi.aws.s3.BucketAclV2;
import com.pulumi.aws.s3.BucketAclV2Args;
import com.pulumi.aws.cloudfront.Distribution;
import com.pulumi.aws.cloudfront.DistributionArgs;
import com.pulumi.aws.cloudfront.inputs.DistributionOriginArgs;
import com.pulumi.aws.cloudfront.inputs.DistributionLoggingConfigArgs;
import com.pulumi.aws.cloudfront.inputs.DistributionDefaultCacheBehaviorArgs;
import com.pulumi.aws.cloudfront.inputs.DistributionDefaultCacheBehaviorForwardedValuesArgs;
import com.pulumi.aws.cloudfront.inputs.DistributionDefaultCacheBehaviorForwardedValuesCookiesArgs;
import com.pulumi.aws.cloudfront.inputs.DistributionOrderedCacheBehaviorArgs;
import com.pulumi.aws.cloudfront.inputs.DistributionOrderedCacheBehaviorForwardedValuesArgs;
import com.pulumi.aws.cloudfront.inputs.DistributionOrderedCacheBehaviorForwardedValuesCookiesArgs;
import com.pulumi.aws.cloudfront.inputs.DistributionRestrictionsArgs;
import com.pulumi.aws.cloudfront.inputs.DistributionRestrictionsGeoRestrictionArgs;
import com.pulumi.aws.cloudfront.inputs.DistributionViewerCertificateArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var bucketV2 = new BucketV2("bucketV2", BucketV2Args.builder()
.tags(Map.of("Name", "My bucket"))
.build());
var bAcl = new BucketAclV2("bAcl", BucketAclV2Args.builder()
.bucket(bucketV2.id())
.acl("private")
.build());
final var s3OriginId = "myS3Origin";
var s3Distribution = new Distribution("s3Distribution", DistributionArgs.builder()
.origins(DistributionOriginArgs.builder()
.domainName(bucketV2.bucketRegionalDomainName())
.originAccessControlId(aws_cloudfront_origin_access_control.default().id())
.originId(s3OriginId)
.build())
.enabled(true)
.isIpv6Enabled(true)
.comment("Some comment")
.defaultRootObject("index.html")
.loggingConfig(DistributionLoggingConfigArgs.builder()
.includeCookies(false)
.bucket("mylogs.s3.amazonaws.com")
.prefix("myprefix")
.build())
.aliases(
"mysite.example.com",
"yoursite.example.com")
.defaultCacheBehavior(DistributionDefaultCacheBehaviorArgs.builder()
.allowedMethods(
"DELETE",
"GET",
"HEAD",
"OPTIONS",
"PATCH",
"POST",
"PUT")
.cachedMethods(
"GET",
"HEAD")
.targetOriginId(s3OriginId)
.forwardedValues(DistributionDefaultCacheBehaviorForwardedValuesArgs.builder()
.queryString(false)
.cookies(DistributionDefaultCacheBehaviorForwardedValuesCookiesArgs.builder()
.forward("none")
.build())
.build())
.viewerProtocolPolicy("allow-all")
.minTtl(0)
.defaultTtl(3600)
.maxTtl(86400)
.build())
.orderedCacheBehaviors(
DistributionOrderedCacheBehaviorArgs.builder()
.pathPattern("/content/immutable/*")
.allowedMethods(
"GET",
"HEAD",
"OPTIONS")
.cachedMethods(
"GET",
"HEAD",
"OPTIONS")
.targetOriginId(s3OriginId)
.forwardedValues(DistributionOrderedCacheBehaviorForwardedValuesArgs.builder()
.queryString(false)
.headers("Origin")
.cookies(DistributionOrderedCacheBehaviorForwardedValuesCookiesArgs.builder()
.forward("none")
.build())
.build())
.minTtl(0)
.defaultTtl(86400)
.maxTtl(31536000)
.compress(true)
.viewerProtocolPolicy("redirect-to-https")
.build(),
DistributionOrderedCacheBehaviorArgs.builder()
.pathPattern("/content/*")
.allowedMethods(
"GET",
"HEAD",
"OPTIONS")
.cachedMethods(
"GET",
"HEAD")
.targetOriginId(s3OriginId)
.forwardedValues(DistributionOrderedCacheBehaviorForwardedValuesArgs.builder()
.queryString(false)
.cookies(DistributionOrderedCacheBehaviorForwardedValuesCookiesArgs.builder()
.forward("none")
.build())
.build())
.minTtl(0)
.defaultTtl(3600)
.maxTtl(86400)
.compress(true)
.viewerProtocolPolicy("redirect-to-https")
.build())
.priceClass("PriceClass_200")
.restrictions(DistributionRestrictionsArgs.builder()
.geoRestriction(DistributionRestrictionsGeoRestrictionArgs.builder()
.restrictionType("whitelist")
.locations(
"US",
"CA",
"GB",
"DE")
.build())
.build())
.tags(Map.of("Environment", "production"))
.viewerCertificate(DistributionViewerCertificateArgs.builder()
.cloudfrontDefaultCertificate(true)
.build())
.build());
}
}

Import

CloudFront Distributions can be imported using the id, e.g.,

$ pulumi import aws:cloudfront/distribution:Distribution distribution E74FTE3EXAMPLE

Constructors

Link copied to clipboard
constructor(aliases: Output<List<String>>? = null, comment: Output<String>? = null, customErrorResponses: Output<List<DistributionCustomErrorResponseArgs>>? = null, defaultCacheBehavior: Output<DistributionDefaultCacheBehaviorArgs>? = null, defaultRootObject: Output<String>? = null, enabled: Output<Boolean>? = null, httpVersion: Output<String>? = null, isIpv6Enabled: Output<Boolean>? = null, loggingConfig: Output<DistributionLoggingConfigArgs>? = null, orderedCacheBehaviors: Output<List<DistributionOrderedCacheBehaviorArgs>>? = null, originGroups: Output<List<DistributionOriginGroupArgs>>? = null, origins: Output<List<DistributionOriginArgs>>? = null, priceClass: Output<String>? = null, restrictions: Output<DistributionRestrictionsArgs>? = null, retainOnDelete: Output<Boolean>? = null, tags: Output<Map<String, String>>? = null, viewerCertificate: Output<DistributionViewerCertificateArgs>? = null, waitForDeployment: Output<Boolean>? = null, webAclId: Output<String>? = null)

Properties

Link copied to clipboard
val aliases: Output<List<String>>? = null

Extra CNAMEs (alternate domain names), if any, for this distribution.

Link copied to clipboard
val comment: Output<String>? = null

Any comments you want to include about the distribution.

Link copied to clipboard

One or more custom error response elements (multiples allowed).

Link copied to clipboard

Default cache behavior for this distribution (maximum one). Requires either cache_policy_id (preferred) or forwarded_values (deprecated) be set.

Link copied to clipboard
val defaultRootObject: Output<String>? = null

Object that you want CloudFront to return (for example, index.html) when an end user requests the root URL.

Link copied to clipboard
val enabled: Output<Boolean>? = null

Whether the distribution is enabled to accept end user requests for content.

Link copied to clipboard
val httpVersion: Output<String>? = null

Maximum HTTP version to support on the distribution. Allowed values are http1.1, http2, http2and3 and http3. The default is http2.

Link copied to clipboard
val isIpv6Enabled: Output<Boolean>? = null

Whether the IPv6 is enabled for the distribution.

Link copied to clipboard

The logging configuration that controls how logs are written to your distribution (maximum one).

Link copied to clipboard

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.

Link copied to clipboard

One or more origin_group for this distribution (multiples allowed).

Link copied to clipboard
val origins: Output<List<DistributionOriginArgs>>? = null

One or more origins for this distribution (multiples allowed).

Link copied to clipboard
val priceClass: Output<String>? = null

Price class for this distribution. One of PriceClass_All, PriceClass_200, PriceClass_100.

Link copied to clipboard

The restriction configuration for this distribution (maximum one).

Link copied to clipboard
val retainOnDelete: Output<Boolean>? = null

Disables the distribution instead of deleting it when destroying the resource through the provider. If this is set, the distribution needs to be deleted manually afterwards. Default: false.

Link copied to clipboard
val tags: Output<Map<String, String>>? = null

A map of tags to assign to the resource. If configured with a provider default_tags configuration block present, tags with matching keys will overwrite those defined at the provider-level.

Link copied to clipboard

The SSL configuration for this distribution (maximum one).

Link copied to clipboard
val waitForDeployment: Output<Boolean>? = null

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.

Link copied to clipboard
val webAclId: Output<String>? = null

Unique identifier that specifies the AWS WAF web ACL, if any, to associate with this distribution. To specify a web ACL created using the latest version of AWS WAF (WAFv2), use the ACL ARN, for example aws_wafv2_web_acl.example.arn. To specify a web ACL created using AWS WAF Classic, use the ACL ID, for example aws_waf_web_acl.example.id. The WAF Web ACL must exist in the WAF Global (CloudFront) region and the credentials configuring this argument must have waf:GetWebACL permissions assigned. //

Functions

Link copied to clipboard
open override fun toJava(): DistributionArgs