OriginRequestPolicy class

Example Usage

The following example below creates a CloudFront origin request policy.

import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const example = new aws.cloudfront.OriginRequestPolicy("example", {
    cookiesConfig: {
        cookies: {
            items: ["example"],
        },
        cookieBehavior: "whitelist",
    },
    headersConfig: {
        headers: {
            items: ["example"],
        },
        headerBehavior: "whitelist",
    },
    queryStringsConfig: {
        queryStrings: {
            items: ["example"],
        },
        queryStringBehavior: "whitelist",
    },
    name: "example-policy",
    comment: "example comment",
});
import pulumi
import pulumi_aws as aws

example = aws.cloudfront.OriginRequestPolicy("example",
    cookies_config={
        "cookies": {
            "items": ["example"],
        },
        "cookie_behavior": "whitelist",
    },
    headers_config={
        "headers": {
            "items": ["example"],
        },
        "header_behavior": "whitelist",
    },
    query_strings_config={
        "query_strings": {
            "items": ["example"],
        },
        "query_string_behavior": "whitelist",
    },
    name="example-policy",
    comment="example comment")
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;

return await Deployment.RunAsync(() =>
{
    var example = new Aws.CloudFront.OriginRequestPolicy("example", new()
    {
        CookiesConfig = new Aws.CloudFront.Inputs.OriginRequestPolicyCookiesConfigArgs
        {
            Cookies = new Aws.CloudFront.Inputs.OriginRequestPolicyCookiesConfigCookiesArgs
            {
                Items = new[]
                {
                    "example",
                },
            },
            CookieBehavior = "whitelist",
        },
        HeadersConfig = new Aws.CloudFront.Inputs.OriginRequestPolicyHeadersConfigArgs
        {
            Headers = new Aws.CloudFront.Inputs.OriginRequestPolicyHeadersConfigHeadersArgs
            {
                Items = new[]
                {
                    "example",
                },
            },
            HeaderBehavior = "whitelist",
        },
        QueryStringsConfig = new Aws.CloudFront.Inputs.OriginRequestPolicyQueryStringsConfigArgs
        {
            QueryStrings = new Aws.CloudFront.Inputs.OriginRequestPolicyQueryStringsConfigQueryStringsArgs
            {
                Items = new[]
                {
                    "example",
                },
            },
            QueryStringBehavior = "whitelist",
        },
        Name = "example-policy",
        Comment = "example comment",
    });

});
package main

import (
	"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/cloudfront"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := cloudfront.NewOriginRequestPolicy(ctx, "example", &cloudfront.OriginRequestPolicyArgs{
			CookiesConfig: &cloudfront.OriginRequestPolicyCookiesConfigArgs{
				Cookies: &cloudfront.OriginRequestPolicyCookiesConfigCookiesArgs{
					Items: pulumi.StringArray{
						pulumi.String("example"),
					},
				},
				CookieBehavior: pulumi.String("whitelist"),
			},
			HeadersConfig: &cloudfront.OriginRequestPolicyHeadersConfigArgs{
				Headers: &cloudfront.OriginRequestPolicyHeadersConfigHeadersArgs{
					Items: pulumi.StringArray{
						pulumi.String("example"),
					},
				},
				HeaderBehavior: pulumi.String("whitelist"),
			},
			QueryStringsConfig: &cloudfront.OriginRequestPolicyQueryStringsConfigArgs{
				QueryStrings: &cloudfront.OriginRequestPolicyQueryStringsConfigQueryStringsArgs{
					Items: pulumi.StringArray{
						pulumi.String("example"),
					},
				},
				QueryStringBehavior: pulumi.String("whitelist"),
			},
			Name:    pulumi.String("example-policy"),
			Comment: pulumi.String("example comment"),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
pulumi {
  required_providers {
    aws = {
      source = "pulumi/aws"
    }
  }
}

resource "aws_cloudfront_originrequestpolicy" "example" {
  cookies_config = {
    cookies = {
      items = ["example"]
    }
    cookie_behavior = "whitelist"
  }
  headers_config = {
    headers = {
      items = ["example"]
    }
    header_behavior = "whitelist"
  }
  query_strings_config = {
    query_strings = {
      items = ["example"]
    }
    query_string_behavior = "whitelist"
  }
  name    = "example-policy"
  comment = "example comment"
}
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.cloudfront.OriginRequestPolicy;
import com.pulumi.aws.cloudfront.OriginRequestPolicyArgs;
import com.pulumi.aws.cloudfront.inputs.OriginRequestPolicyCookiesConfigArgs;
import com.pulumi.aws.cloudfront.inputs.OriginRequestPolicyCookiesConfigCookiesArgs;
import com.pulumi.aws.cloudfront.inputs.OriginRequestPolicyHeadersConfigArgs;
import com.pulumi.aws.cloudfront.inputs.OriginRequestPolicyHeadersConfigHeadersArgs;
import com.pulumi.aws.cloudfront.inputs.OriginRequestPolicyQueryStringsConfigArgs;
import com.pulumi.aws.cloudfront.inputs.OriginRequestPolicyQueryStringsConfigQueryStringsArgs;
import java.util.ArrayList;
import java.util.Arrays;
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 example = new OriginRequestPolicy("example", OriginRequestPolicyArgs.builder()
            .cookiesConfig(OriginRequestPolicyCookiesConfigArgs.builder()
                .cookies(OriginRequestPolicyCookiesConfigCookiesArgs.builder()
                    .items("example")
                    .build())
                .cookieBehavior("whitelist")
                .build())
            .headersConfig(OriginRequestPolicyHeadersConfigArgs.builder()
                .headers(OriginRequestPolicyHeadersConfigHeadersArgs.builder()
                    .items("example")
                    .build())
                .headerBehavior("whitelist")
                .build())
            .queryStringsConfig(OriginRequestPolicyQueryStringsConfigArgs.builder()
                .queryStrings(OriginRequestPolicyQueryStringsConfigQueryStringsArgs.builder()
                    .items("example")
                    .build())
                .queryStringBehavior("whitelist")
                .build())
            .name("example-policy")
            .comment("example comment")
            .build());

    }
}
resources:
  example:
    type: aws:cloudfront:OriginRequestPolicy
    properties:
      cookiesConfig:
        cookies:
          items:
            - example
        cookieBehavior: whitelist
      headersConfig:
        headers:
          items:
            - example
        headerBehavior: whitelist
      queryStringsConfig:
        queryStrings:
          items:
            - example
        queryStringBehavior: whitelist
      name: example-policy
      comment: example comment

Import

Using pulumi import, import Cloudfront Origin Request Policies using the id. For example:

$ pulumi import aws:cloudfront/originRequestPolicy:OriginRequestPolicy policy ccca32ef-dce3-4df3-80df-1bd3000bc4d3

Constructors

OriginRequestPolicy(String name, {OriginRequestPolicyArgs? args, CustomResourceOptions? options})
Creates a new OriginRequestPolicy. name The Pulumi resource name. args Arguments used to configure this OriginRequestPolicy. The set of arguments for OriginRequestPolicy. options Resource options controlling this resource's behavior.
OriginRequestPolicy.reference(String urn)
Creates a typed reference to an existing OriginRequestPolicy resource.

Properties

arn ↔ Output<String>
The origin request policy ARN.
latefinal
childResources → Set<Resource>
finalinherited
comment ↔ Output<String?>
Comment to describe the origin request policy.
latefinal
completionSources ↔ Map<String, IOutputCompletionSource>
latefinalinherited
cookiesConfig ↔ Output<OriginRequestPolicyCookiesConfig>
Object that determines whether any cookies in viewer requests (and if so, which cookies) are included in the origin request key and automatically included in requests that CloudFront sends to the origin. See Cookies Config for more information.
latefinal
etag ↔ Output<String>
The current version of the origin request policy.
latefinal
hashCode → int
The hash code for this object.
no setterinherited
headersConfig ↔ Output<OriginRequestPolicyHeadersConfig>
Object that determines whether any HTTP headers (and if so, which headers) are included in the origin request key and automatically included in requests that CloudFront sends to the origin. See Headers Config for more information.
latefinal
id ↔ Output<String>
getter/setter pairinherited
isCustom → bool
Returns whether this resource is provider-managed.
no setterinherited
isProtected → bool
Returns whether this resource is protected from deletion.
no setterinherited
isRemote → bool
Whether this resource is registered as remote.
no setterinherited
isResourceReference → bool
Whether this instance represents a resource value returned over RPC.
finalinherited
name ↔ Output<String>
Unique name to identify the origin request policy.
latefinal
queryStringsConfig ↔ Output<OriginRequestPolicyQueryStringsConfig>
Object that determines whether any URL query strings in viewer requests (and if so, which query strings) are included in the origin request key and automatically included in requests that CloudFront sends to the origin. See Query String Config for more information.
latefinal
resourceTransforms → List<ResourceTransform>
Inherited/explicit async transforms.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
transformations → List<ResourceTransformation>
Inherited/explicit legacy transformations.
no setterinherited
urn ↔ Output<String>
latefinalinherited

Methods

failId(Object error) → void
Completes this resource ID with an error when registration fails.
inherited
failOutputs(Object error) → void
Completes all output properties with error.
inherited
failUrn(Object error) → void
Completes this resource URN with an error when registration fails.
inherited
getProvider(String moduleMember) → ProviderResource?
Returns provider for moduleMember's package, if configured.
inherited
getResourceName() → String
Returns this resource's logical name.
inherited
getResourceType() → String
Returns this resource's Pulumi type token.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
registerOutput<T>(String propertyName, {Object? decoder(Object?)?, bool isSecret = false}) → Output<T>
Registers a dynamic output property for this resource.
inherited
resolveId(String? value, {required bool isKnown}) → void
Resolves the provider-assigned ID for this resource.
inherited
resolveOutputs(Struct outputs) → void
Resolves all output properties from a monitor response payload.
inherited
resolveUrn(String value) → void
Resolves this resource's URN once assigned by the engine.
inherited
serializeProperties(Map<String, dynamic> properties) → Future<Struct>
Serializes resource properties for RPC transmission.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

get(String name, Input<String> id, {OriginRequestPolicyState? state, CustomResourceOptions? options}) → OriginRequestPolicy
Gets an existing OriginRequestPolicy resource's state with the given name and id.