title: Unable to add cloudfront as trigger to lambda function
body: <p>Hi I've followed this <a href="https://aws.amazon.com/tw/blogs/networking-and-content-delivery/resizing-images-with-amazon-cloudfront-lambdaedge-aws-cdn-blog/" rel="noreferrer">instruction</a> try to resize image with Cloudfront and lambda@edge. When I tried to test the resized image, I keep getting the error message below:</p>
  
  <blockquote>
    <p>The Lambda function associated with the CloudFront distribution is
    invalid or doesn't have the required permissions.</p>
  </blockquote>
  
  <p>So I checked the lambda functions created by cloud formation provided by the article I mentioned in the beginning, and I found there's no trigger in it.</p>
  
  <p><a href="https://i.stack.imgur.com/iMk2F.png" rel="noreferrer"><img src="https://i.stack.imgur.com/iMk2F.png" alt="enter image description here"></a></p>
  
  <p>I've tried to set it manually but getting the error message below:</p>
  
  <blockquote>
    <p>CloudFront events cannot be associated with $LATEST or Alias. Choose
    Actions to publish a new version of your function, and then retry
    association.</p>
  </blockquote>
  
  <p>I followed the instruction in the error message; publish, and add Cloudfront as trigger but it seems there's no way to apply it. It's still running the one without Cloudfront as the trigger.</p>
  
  <p><a href="https://i.stack.imgur.com/BJqFq.png" rel="noreferrer"><img src="https://i.stack.imgur.com/BJqFq.png" alt="How can I apply this version as my lambda service?"></a></p>
  
  <p>Is there any way to set Cloudfront as trigger and make this work properly?</p>