Search code examples
amazon-web-servicesaws-cloudformationamazon-cloudfront

AWS::CloudFront::OriginRequestPolicy resource in CloudFormation


I am trying to CloudFormation for my Lambda@Edge resource, which I would like to utilize CloudFront's new origin request policy.

However, when I tried to deploy the following resource with aws cloudformation:

AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: "Test"
Resources:
  CloudFrontOriginRequestPolicy:
    Type: AWS::CloudFront::OriginRequestPolicy
    Properties:
      OriginRequestPolicyConfig:
        CookiesConfig:
          CookieBehavior: none
        HeadersConfig:
          HeaderBehavior: none
        QueryStringsConfig:
          QueryStringBehavior: none
        Name: Managed-CORS-Policy

It only gave this error: Invalid request provided: AWS::CloudFront::OriginRequestPolicy

I have no clue where it really went wrong; I believe I already provided all required fields in the resource following: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cloudfront-originrequestpolicy.html

Anyone has experience how this resource should be setup? Thanks!


Solution

  • This seems to be caused by some CloudFormation internal issue/bug. There is already a GitHub issue opened for that.

    Thus you can have a look at the issue, still open and not resolved, but people do post that sometimes it works, depending on the region, policy name, IAM permissions. You could try some of the ideas posted there.