Skip to content

Commit

Permalink
Substitute /ai with AI App backend (#9728)
Browse files Browse the repository at this point in the history
* Substitute `/ai` with AI App backend

* fix: add origin for production AI app
  • Loading branch information
AaronFriel authored Aug 25, 2023
1 parent 4cbcaa8 commit fec692c
Showing 1 changed file with 40 additions and 1 deletion.
41 changes: 40 additions & 1 deletion infrastructure/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ const config = {

const aiAppStack = new pulumi.StackReference('pulumi/pulumi-ai-app-infra/prod');
const previewAiAppDomain = aiAppStack.requireOutput('previewAiAppDistributionDomain');
const aiAppDomain = aiAppStack.requireOutput('aiAppDistributionDomain');

// originBucketName is the name of the S3 bucket to use as the CloudFront origin for the
// website. This bucket is presumed to exist prior to the Pulumi run; if it doesn't, this
Expand Down Expand Up @@ -278,7 +279,17 @@ const distributionArgs: aws.cloudfront.DistributionArgs = {
httpsPort: 443,
originSslProtocols: ["TLSv1.2"],
},
}
},
{
originId: aiAppDomain,
domainName: aiAppDomain,
customOriginConfig: {
originProtocolPolicy: "https-only",
httpPort: 80,
httpsPort: 443,
originSslProtocols: ["TLSv1.2"],
},
},
],

// Default object to serve when no path is given.
Expand Down Expand Up @@ -434,6 +445,34 @@ const distributionArgs: aws.cloudfront.DistributionArgs = {
defaultTtl: 0,
minTtl: 0,
maxTtl: 0,
},

// AI app, live, with caching handled by the app
{
...baseCacheBehavior,
// allow all methods
allowedMethods: ["DELETE", "GET", "HEAD", "OPTIONS", "PATCH", "POST", "PUT"],
cachedMethods: [
"GET", "HEAD", "OPTIONS",
],
targetOriginId: aiAppDomain,
pathPattern: '/ai',
defaultTtl: 0,
minTtl: 0,
maxTtl: 0,
},
{
...baseCacheBehavior,
// allow all methods
allowedMethods: ["DELETE", "GET", "HEAD", "OPTIONS", "PATCH", "POST", "PUT"],
cachedMethods: [
"GET", "HEAD", "OPTIONS",
],
targetOriginId: aiAppDomain,
pathPattern: '/ai/*',
defaultTtl: 0,
minTtl: 0,
maxTtl: 0,
}
],

Expand Down

0 comments on commit fec692c

Please sign in to comment.