Files
floci/src/main/java
Aniket Shukla ea74b979ae fix(lambda): scope resource-policy statements to the request Qualifier (#2129)
* fix(lambda): scope resource-policy statements to the request Qualifier

AddPermission, GetPolicy and RemovePermission ignored the Qualifier query
parameter. Every statement was stored against the unqualified function ARN, so
an alias-scoped permission could never be read back under its alias: GetPolicy
returned identical payloads with and without ?Qualifier, and the statement's
Resource had no qualifier suffix.

This is what stops Terraform's aws_lambda_permission with qualifier set from
converging — it creates the permission, polls GetPolicy?Qualifier=<alias>
forever, and a later apply then hits ResourceConflictException against a
statement its read could never confirm.

AWS keeps a separate resource policy per qualifier, so the qualifier is part of
a statement's identity. Declare @QueryParam("Qualifier") on the three policy
endpoints and thread it through the service, reusing the existing
resolveWithRegion() helper so a qualifier embedded in the function name
(arn:...:function:fn:ALIAS) is reconciled with the query-string value exactly as
the function-URL endpoints already do.

The scope is derived from the statement's own Resource rather than a new stored
field, so statements persisted before this change stay readable as the
function's unqualified policy. Consequently:

- AddPermission?Qualifier=X writes Resource <functionArn>:X
- GetPolicy?Qualifier=X returns only that qualifier's statements (404 if none)
- RemovePermission?Qualifier=X removes only within that qualifier
- the same StatementId may exist on the function and on each alias, and a
  duplicate within one qualifier still conflicts

Qualifier existence is deliberately not validated — that is a separate behaviour
change, and the endpoints did not validate it before either.

Adds LambdaPermissionQualifierIntegrationTest (12 cases); 7 of them fail against
the unfixed code with the exact symptom from the report (Resource missing the
alias suffix). The existing LambdaPermissionTagLayerIntegrationTest (19) and
LambdaVersionIntegrationTest (6) stay green, covering the unqualified path.

* fix(lambda): clarify missing scoped policy error
2026-08-12 14:07:20 -04:00
..