I'm trying to use a list of string inside a sam template but it doesn't work as expected. There is my code
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
Sample SAM Template
Parameters:
CognitoPoolArns:
Type: List<String>
Default: "[\"arn:aws:cognito-idp:eu-west-X:XXXXX:userpool/eu-west-XXXXXXX\",\"arn:aws:cognito-idp:eu-west-X:XXXXXX:userpool/eu-west-XXXXXX\",]"
Resources:
Api:
Type: AWS::Serverless::Api
Properties:
StageName: dev
Name: name
EndpointConfiguration:
Type: REGIONAL
Auth:
DefaultAuthorizer: MyCognitoAuthorizer
Authorizers:
MyCognitoAuthorizer:
UserPoolArn: !Ref CognitoPoolArns
PingGetFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: lambdas/ping_get/
FunctionName: get-ping
Handler: main.lambda_handler
Runtime: python3.8
Events:
API:
Type: Api
Properties:
RestApiId: !Ref Api
Path: /api/v1/ping
Method: get
I get this error message : Errors found during import: Unable to create authorizer 'MyCognitoAuthorizer': ProviderARNs need to be valid Cognito Userpools. Invalid ARNs- ["arn:aws:cognito-idp:eu- west-X:XXXX:userpool/eu- west-XXXXX" "arn:aws:cognito-idp:eu- west-X:XXXXXX:userpool/eu- west-XXXXX" ]
But if I do
MyCognitoAuthorizer:
UserPoolArn:
- arn:aws:cognito-idp:eu-west-X:XXX:userpool/eu-west-XXXXXXXX
- arn:aws:cognito-idp:eu-west-X:XXX:userpool/eu-west-XXXXXXXX
It's working. How can I deal with that by passing by variable ?
Change the default value of CognitoPoolArns
parameter in the template as below to resolve the error.
Execute sam build
command after making the change and then you will be able to deploy successfully.
Default: "arn:aws:cognito-idp:eu-west-X:XXXXX:userpool/eu-west-XXXXXXX, arn:aws:cognito-idp:eu-west-X:XXXXXX:userpool/eu-west-XXXXXX"