Link Cloudfront to API Gateway, to Lambda

Hi, I can add http event to a Lambda function to have an API gateway createed, but now I want to create a Cloudfront distribution which uses the methods of that API gateway. In my cloudfront, how do I refer to the API gateway which is implicitly created for the Lambda functions?
I got a snippet to describe the origin from here:
http://forum.serverless.com/t/use-cloudfront-proxy-to-access-lambda-apis/357

But that’s not doing it for me :frowning: so far I’m getting: An error occurred while provisioning your stack: CloudFrontDistribution - One or more of your origins do not exist…

"DomainName" : {
                "Fn::Join": [
                  "",
                  [
                    { "Ref": "ApiGatewayRestApi" },
                    ".execute-api.${self:provider.region}.amazonaws.com"
                  ]
                ]
              }

Hi! We ran into the same issue and decided to create and open-source Serverless plugin that does exactly that :slight_smile: So feel free to check it out and let me know if it works for you - https://github.com/Droplr/serverless-api-cloudfront

1 Like