Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fresh-taxis-trade.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@gradientedge/cdk-utils-cloudflare': patch
---

feat: Cloudflare static add dependency between route and worker
17 changes: 11 additions & 6 deletions packages/cloudflare/src/construct/worker-site/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,17 @@ export class CloudflareWorkerSite extends CommonCloudflareConstruct {
* @summary Create the worker domain
*/
protected createWorkerDomain() {
this.siteWorkerDomain = this.workerManager.createWorkerDomain(`${this.id}-worker-domain`, this, {
...this.props.siteWorkerDomain,
environment: this.props.siteWorkerDomain.environment ?? 'production',
hostname: `${this.props.siteSubDomain}.${this.props.domainName}`,
service: this.siteWorkerScript.scriptName,
})
this.siteWorkerDomain = this.workerManager.createWorkerDomain(
`${this.id}-worker-domain`,
this,
{
...this.props.siteWorkerDomain,
environment: this.props.siteWorkerDomain.environment ?? 'production',
hostname: `${this.props.siteSubDomain}.${this.props.domainName}`,
service: this.siteWorkerScript.scriptName,
},
{ dependsOn: [this.siteWorkerScript] }
)
}

/**
Expand Down
10 changes: 8 additions & 2 deletions packages/cloudflare/src/services/worker/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
WorkersRoute,
WorkersScript,
} from '@pulumi/cloudflare'
import { ResourceOptions } from '@pulumi/pulumi'
import _ from 'lodash'

import { CommonCloudflareConstruct } from '../../common/index.js'
Expand Down Expand Up @@ -45,7 +46,12 @@ export class CloudflareWorkerManager {
* @param props worker domain properties
* @see [Pulumi Worker Domain]{@link https://www.pulumi.com/registry/packages/cloudflare/api-docs/workercustomdomain/}
*/
public createWorkerDomain(id: string, scope: CommonCloudflareConstruct, props: WorkerDomainProps) {
public createWorkerDomain(
id: string,
scope: CommonCloudflareConstruct,
props: WorkerDomainProps,
resourceOptions?: ResourceOptions
) {
if (!props) throw new Error(`Props undefined for ${id}`)

const zoneId = props.zoneId
Expand All @@ -58,7 +64,7 @@ export class CloudflareWorkerManager {
accountId: props.accountId ?? scope.props.accountId,
zoneId,
},
{ parent: scope }
{ parent: scope, ...resourceOptions }
)
}

Expand Down