Skip to content

Commit

Permalink
fix: distribution functions suffix
Browse files Browse the repository at this point in the history
  • Loading branch information
thijsdaniels committed Aug 30, 2024
1 parent b3f27bf commit fd47292
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changeset/big-radios-fetch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@codedazur/cdk-site-distribution": patch
---

The functions' behavior suffix is now configured correctly.
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ export class SiteDistribution extends Construct {
domainNames: this.domain ? [this.domain] : undefined,
defaultBehavior: this.behavior(),
additionalBehaviors: this.props.behaviors
? revalueObject(this.props.behaviors, ([, props]) =>
this.behavior(props),
? revalueObject(this.props.behaviors, ([pattern, props]) =>
this.behavior({ pattern, ...props }),
)
: undefined,
});
Expand All @@ -167,7 +167,7 @@ export class SiteDistribution extends Construct {
pattern?: string;
} = {}): BehaviorOptions {
const functions = this.createFunctions({
pattern,
idSuffix: pattern,
authentication: authentication ?? this.props.authentication,
functions: functionsCode ?? this.props.functions,
});
Expand Down Expand Up @@ -197,20 +197,20 @@ export class SiteDistribution extends Construct {
}

protected createFunctions({
pattern,
idSuffix,
authentication,
functions,
}: {
pattern: string;
idSuffix: string;
} & Partial<Pick<BehaviorProps, "authentication" | "functions">>) {
const viewerRequest = this.createViewerRequestFunction({
id: `ViewerRequestFunction-${pattern}`,
id: `ViewerRequestFunction-${idSuffix}`,
authentication,
code: functions?.viewerRequest,
});

const viewerResponse = this.createViewerResponseFunction({
id: `ViewerResponseFunction-${pattern}`,
id: `ViewerResponseFunction-${idSuffix}`,
code: functions?.viewerResponse,
});

Expand Down

0 comments on commit fd47292

Please sign in to comment.