Hey all! AWS <recently announced> CloudFront Origi...
# aws
n
Hey all! AWS recently announced CloudFront Origin Access Control support for Lambda Function URLs. I see that
lambda
has been added to the
OriginAccessControlOriginType
in CloudFormation, as well as in the Cloud Control API. However, when I try to create an
aws.cloudfront.OriginAccessControl
with
originAccessControlOriginType
of
lambda
I get this error:
Copy code
error: aws:cloudfront/originAccessControl:OriginAccessControl resource 'functionOac' has a problem: expected origin_access_control_origin_type to be one of ["s3" "mediastore"], got lambda. Examine values at 'functionOac.originAccessControlOriginType'.
Is this a known thing? I'll post more of my setup in the thread.
Copy code
const originAccessControl = new aws.cloudfront.OriginAccessControl("functionOac", {
  name: "functionOac",
  description: "OAC for Function URL",
  signingBehavior: "always",
  signingProtocol: "sigv4",
  originAccessControlOriginType: "lambda"
});
Copy code
const distribution = new aws.cloudfront.Distribution("SnapStartDistribution", {
  enabled: true,
  defaultCacheBehavior: {
    allowedMethods: ["GET", "HEAD"],
    cachedMethods: ["GET", "HEAD"],
    targetOriginId: funcUrl.id,
    viewerProtocolPolicy: "redirect-to-https",
    defaultTtl: 600,
    maxTtl: 86400,
    minTtl: 0,
    forwardedValues: {
      queryString: false,
      cookies: { forward: "none" },
    },
  },
  origins: [{
    domainName: funcUrl.functionUrl,
    originAccessControlId: originAccessControl.id,
    originId: funcUrl.id,
  }],
  restrictions: {
    geoRestriction: {
      restrictionType: "whitelist",
      locations: [
        "US",
        "CA",
        "GB",
        "DE",
      ],
    },
  },
  viewerCertificate: {
    cloudfrontDefaultCertificate: true,
  }
});
I have a feeling the
distribution
above is probably wrong, but I'm getting the error on the
OriginAccessControl
.
r
Hey! I think it is an upstream issue. According to https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudfront_origin_access_control only two values are allowed.
g
cloudControl ~= cloudformation ==
aws-native
client ... aws-native client is at least 20% slower than classic aws provider due to cloudformation slowness
n
Thanks for the clarification, Jan, I'll keep a lookout for that. I didn't think to look at the Terraform provider -- thanks!
Looks like it's on deck to be released: resource/aws_cloudfront_origin_access_control: Add
lambda
and
mediapackagev2
as valid values for
origin_access_control_origin_type