I want to deploy a AppSync API behind a CloudFront distribution.
The CloudFront distribution needs an HTTP origin, how do I get this from my API object inside one CDK stack?
I found a solution. Had to use an intrinsic function to get the right value out of the distribution construct.
const api = new appsync.GraphqlApi(...);
const origin = new origins.HttpOrigin(
cdk.Fn.select(2, cdk.Fn.split("/", api.graphqlUrl))
);
const distribution = new cloudfront.Distribution(this, "DemoDistribution", {
defaultBehavior: { origin },
});