View a markdown version of this page

Lambda architecture - Dynamic Image Transformation for Amazon CloudFront

Lambda architecture

If you’ve deployed the Lambda architecture stack and have set the Use Existing CloudFront Distribution template parameter to Yes, use the following instructions to complete your setup.

Setting the Origin

  1. In the CloudFront console, navigate to the distribution you indicated in the Existing CloudFront Distribution ID template parameter.

  2. Select the Origins tab and click Create origin.

  3. Set the Origin domain as the API Gateway execution link. This value can be found by placing the Physical ID of the stack’s AWS::ApiGateway::RestApi in the search field and selecting LambdaRestApi under API Gateway.

  4. Set the Origin path to /image.

  5. Select Create origin.

Setting the behavior

  1. In the CloudFront console, navigate to the distribution you indicated in the Existing CloudFront Distribution ID template parameter.

  2. Select the Behaviors tab and choose Create behavior

  3. Set the Path pattern you’d like to point to your solution instance, in a Solution created distribution, this is Default (*)

  4. Set the Origin to the Origin created in the previous section.

  5. Set the Viewer Protocol policy to Redirect HTTP to HTTPS

  6. Set the Cache Policy to the one named ServerlessImageHandler-${UUID}.

  7. Set the Origin request policy to the one named ServerlessImageHandler-${UUID}.

  8. Set the Viewer request Function type to CloudFront Functions, and the Function ARN to the one named sih-apig-request-modifier-${UUID}.

  9. Select Create behavior.