Skip to content

Commit 3fbd6de

Browse files
authored
Merge pull request #219 from nitrictech/feature/fix-gcp-entrypoints
GCP: Entrypoint deployment fixes.
2 parents 571290d + ae2d621 commit 3fbd6de

File tree

2 files changed

+21
-11
lines changed

2 files changed

+21
-11
lines changed

packages/plugins/gcp/src/resources/entrypoint.ts

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export class NitricEntrypointGoogleCloudLB extends pulumi.ComponentResource {
5959
`${entrypointPath.target}-neg`,
6060
{
6161
networkEndpointType: 'INTERNET_FQDN_PORT',
62-
//defaultPort: 443,
62+
defaultPort: 443,
6363
},
6464
defaultResourceOptions,
6565
);
@@ -78,9 +78,13 @@ export class NitricEntrypointGoogleCloudLB extends pulumi.ComponentResource {
7878
const backend = new gcp.compute.BackendService(
7979
`${entrypointPath.target}`,
8080
{
81+
// Default options for timeout and connection draining
82+
// without these, receiving 502 error
83+
timeoutSec: 10,
84+
connectionDrainingTimeoutSec: 10,
8185
// Link the NEG to the backend
8286
backends: [{ group: apiGatewayNEG.id }],
83-
customRequestHeaders: [pulumi.interpolate`Host: ${deployedApi.hostname}`],
87+
customRequestHeaders: [pulumi.interpolate`host: ${deployedApi.hostname}`],
8488
// TODO: Determine CDN requirements for API gateways
8589
enableCdn: false,
8690
protocol: 'HTTPS',
@@ -90,6 +94,7 @@ export class NitricEntrypointGoogleCloudLB extends pulumi.ComponentResource {
9094

9195
return {
9296
name: entrypointPath.target,
97+
path: entrypointPath.path,
9398
backend,
9499
};
95100
}
@@ -103,7 +108,7 @@ export class NitricEntrypointGoogleCloudLB extends pulumi.ComponentResource {
103108
}
104109

105110
const backend = new gcp.compute.BackendBucket(
106-
`${entrypointPath.target}`,
111+
`${entrypointPath.target}-bucket`,
107112
{
108113
bucketName: deployedSite.storage.name,
109114
// Enable CDN for sites
@@ -114,6 +119,7 @@ export class NitricEntrypointGoogleCloudLB extends pulumi.ComponentResource {
114119

115120
return {
116121
name: entrypointPath.target,
122+
path: entrypointPath.path,
117123
backend,
118124
};
119125
}
@@ -140,7 +146,7 @@ export class NitricEntrypointGoogleCloudLB extends pulumi.ComponentResource {
140146
);
141147

142148
const backend = new gcp.compute.BackendService(
143-
`${entrypointPath.target}`,
149+
`${entrypointPath.target}-${entrypointPath.type}`,
144150
{
145151
// Link the NEG to the backend
146152
backends: [{ group: serverlessNEG.id }],
@@ -153,6 +159,7 @@ export class NitricEntrypointGoogleCloudLB extends pulumi.ComponentResource {
153159

154160
return {
155161
name: entrypointPath.target,
162+
path: entrypointPath.path,
156163
backend,
157164
};
158165
}
@@ -178,7 +185,7 @@ export class NitricEntrypointGoogleCloudLB extends pulumi.ComponentResource {
178185
const pathRules =
179186
otherEntrypoints.length > 0
180187
? otherEntrypoints.map((ep) => {
181-
const backend = backends.find((b) => b.name === ep.target)!.backend;
188+
const backend = backends.find((b) => b.name === ep.target && b.path == ep.path)!.backend;
182189
pulumi.log.info(`other backend: ${ep.target}`, backend);
183190
return {
184191
paths: [`${ep.path}*`],
@@ -268,7 +275,7 @@ export class NitricEntrypointGoogleCloudLB extends pulumi.ComponentResource {
268275
defaultResourceOptions,
269276
);
270277

271-
this.url = pulumi.interpolate`https://${ipAddress}`;
278+
this.url = pulumi.interpolate`https://${ipAddress.address}`;
272279
}
273280

274281
pulumi.log.info('Connecting URL map to HTTP proxy', urlMap);
@@ -296,10 +303,10 @@ export class NitricEntrypointGoogleCloudLB extends pulumi.ComponentResource {
296303
defaultResourceOptions,
297304
);
298305

299-
(this.ipAddress = forwardingRule.ipAddress),
300-
this.registerOutputs({
301-
url: this.url,
302-
ipAddress: this.ipAddress,
303-
});
306+
this.ipAddress = forwardingRule.ipAddress;
307+
this.registerOutputs({
308+
url: this.url,
309+
ipAddress: this.ipAddress,
310+
});
304311
}
305312
}

packages/plugins/gcp/src/resources/site.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ export class NitricSiteCloudStorage extends pulumi.ComponentResource {
4141
this.storage = new gcp.storage.Bucket(
4242
site.getName(),
4343
{
44+
website: {
45+
mainPageSuffix: 'index.html',
46+
},
4447
labels: {
4548
'x-nitric-name': site.getName(),
4649
},

0 commit comments

Comments
 (0)