Skip to content

Commit 1d92028

Browse files
authored
Fix public lambdas and sites returning 403 on new AWS accounts (#6400)
* add invoke function permission to public lambdas * fix 403 public lambdas for oac modes * only apply if url auth is `"none"`
1 parent 810ea48 commit 1d92028

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

platform/src/components/aws/function.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2509,6 +2509,17 @@ export class Function extends Component implements Link.Linkable {
25092509
},
25102510
{ parent },
25112511
);
2512+
if (url.authorization === "none") {
2513+
new lambda.Permission(
2514+
`${name}InvokeFunction`,
2515+
{
2516+
action: "lambda:InvokeFunction",
2517+
function: fn.name,
2518+
principal: "*",
2519+
},
2520+
{ parent },
2521+
);
2522+
}
25122523
if (!url.route) return fnUrl.functionUrl;
25132524

25142525
// add router route

platform/src/components/aws/ssr-site.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1064,6 +1064,16 @@ async function handler(event) {
10641064
},
10651065
{ provider, parent: self },
10661066
);
1067+
new lambda.Permission(
1068+
`${name}CloudFrontInvokeFunction${logicalName(region)}`,
1069+
{
1070+
action: "lambda:InvokeFunction",
1071+
function: server.nodes.function.name,
1072+
principal: "cloudfront.amazonaws.com",
1073+
sourceArn: dist.nodes.distribution.arn,
1074+
},
1075+
{ provider, parent: self },
1076+
);
10671077
}
10681078
});
10691079

@@ -1094,6 +1104,16 @@ async function handler(event) {
10941104
},
10951105
{ parent: self },
10961106
);
1107+
new lambda.Permission(
1108+
`${name}ImageOptimizerCloudFrontInvokeFunction`,
1109+
{
1110+
action: "lambda:InvokeFunction",
1111+
function: imgOptimizer.nodes.function.name,
1112+
principal: "cloudfront.amazonaws.com",
1113+
sourceArn: dist.nodes.distribution.arn,
1114+
},
1115+
{ parent: self },
1116+
);
10971117
}
10981118
}
10991119
},

0 commit comments

Comments
 (0)