fix(cloudformation): forward ProviderARNs on AWS::ApiGateway::Authorizer (#4704)

The REST API Gateway provisioner never read ProviderARNs, so a COGNITO_USER_POOLS authorizer was created with no user pool and CognitoUserPoolAuthorizer rejected every token with 401 before inspecting it. Resolve the list like the other list-shaped properties and forward it as providerARNs, which createAuthorizer already accepts.
This commit is contained in:
danielxoi authored and GitHub committed 2026-10-01 20:40:14 -04:00
1 parent 9c3593f4d1
commit b5f053c587
2 files changed
+28

No files matched your search

@@ -513,6 +513,9 @@ public class ApiGatewayRestApiCfnProvisioner implements CfnResourceProvisioner {
if (ttl != null) {
req.put("authorizerResultTtlInSeconds", ttl);
}
if (props != null && props.has("ProviderARNs")) {
req.put("providerARNs", ctx.resolveStringList(props, "ProviderARNs"));
}
Authorizer authorizer = apiGatewayService.createAuthorizer(ctx.region(), apiId, req);
r.setPhysicalId(authorizer.getId());
r.getAttributes().put("AuthorizerId", authorizer.getId());
@@ -14,6 +14,7 @@ import io.github.hectorvent.floci.services.cloudformation.CloudFormationTemplate
import io.github.hectorvent.floci.services.cloudformation.model.StackResource;
import io.github.hectorvent.floci.services.s3.S3Service;
import org.junit.jupiter.api.Test;
import org.mockito.ArgumentCaptor;
import java.util.ArrayList;
import java.util.HashMap;
@@ -344,6 +345,30 @@ class ApiGatewayRestApiCfnProvisionerTest {
assertEquals("auth-1", r.getAttributes().get("AuthorizerId"));
}
/**
* A COGNITO_USER_POOLS authorizer with no provider ARNs rejects every token, so dropping the
* property turns a correct template into a 401 on every request.
*/
@Test
void authorizerForwardsProviderArns() throws Exception {
Authorizer authorizer = new Authorizer();
authorizer.setId("auth-1");
when(api.createAuthorizer(eq("us-east-1"), eq("api-1"), anyMap())).thenReturn(authorizer);
StackResource r = resource("AWS::ApiGateway::Authorizer", "Auth");
provisioner.provision(r, props("""
{"RestApiId": "api-1", "Name": "cognito", "Type": "COGNITO_USER_POOLS",
"IdentitySource": "method.request.header.Authorization",
"ProviderARNs": ["arn:aws:cognito-idp:us-east-1:000000000000:userpool/us-east-1_abc"]}
"""), ctx());
@SuppressWarnings("unchecked")
ArgumentCaptor<Map<String, Object>> request = ArgumentCaptor.forClass(Map.class);
verify(api).createAuthorizer(eq("us-east-1"), eq("api-1"), request.capture());
assertEquals(List.of("arn:aws:cognito-idp:us-east-1:000000000000:userpool/us-east-1_abc"),
request.getValue().get("providerARNs"));
}
@Test
void methodUsesTheCompositePhysicalIdAndProvisionsItsIntegration() throws Exception {
StackResource r = resource("AWS::ApiGateway::Method", "Get");