# Serverless version \> 2.35 error in variable replacement to Cloudformation template

**URL:** <https://forum.serverless.com/t/serverless-version-2-35-error-in-variable-replacement-to-cloudformation-template/15907>\
**Category:** Serverless Framework\
**Tags:** cloudformation, api-gateway\
**Created:** [September 10, 2021, 7:17am UTC](https://forum.serverless.com/t/serverless-version-2-35-error-in-variable-replacement-to-cloudformation-template/15907 "2021-09-10T07:17:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![next-hectormateos2](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/next-hectormateos2/32/6178_2.png) [@next-hectormateos2](https://forum.serverless.com/u/next-hectormateos2)\
**Post date:** [September 10, 2021, 7:17am UTC](https://forum.serverless.com/t/serverless-version-2-35-error-in-variable-replacement-to-cloudformation-template/15907/1 "2021-09-10T07:17:56Z")

</div>

How are you?

I’m facing to a very odd error after upgrading my Serverless version from 2.35 to any newer version. Using the exactly the same .yml that deploys in 2.35, in newer versions the following error is thrown:

ProviderARNs need to be valid Cognito Userpools:

```auto
Serverless Error ----------------------------------------
 
  An error occurred: ApiGatewayCognitoAuthorizer - ProviderARNs need to be valid Cognito Userpools. Invalid ARNs-
  arn:aws:cognito-idp:${file(./src/config/dev.json):REGION}:${file(./src/config/dev.json):AWS_ACCOUNT}:userpool/${file(./src/config/dev.json):COGNITO_POOL_ID} (Service: AmazonApiGateway; Status Code: 400; Error Code: BadRequestException; Request ID: e8403d66-ec5c-4ead-9528-308baed7640f; Proxy: null).
 
  Get Support --------------------------------------------
     Docs: docs.serverless.com
     Bugs: github.com/serverless/serverless/issues
     Issues: forum.serverless.com
 
  Your Environment Information ---------------------------
     Operating System: darwin
     Node Version: 12.22.1
     Framework Version: 2.50.0 (local)
     Plugin Version: 5.4.4
     SDK Version: 4.3.0
     Components Version: 3.17.0

```

In the deep, the problem is that the CloudFormation template generated in the deployment is unable to resolve variables that 2.35 and previous versions resolved properly, for example in my code:

```auto
ApiGatewayCognitoAuthorizer:
      DependsOn:
        - ApiGatewayRestApi
      Type: AWS::ApiGateway::Authorizer
      Properties:
        Name: cognito-authorizer
        IdentitySource: method.request.header.Authorization
        ProviderARNs:
          - "arn:aws:cognito-idp:${${self:custom.config}:REGION}:${${self:custom.config}:AWS_ACCOUNT}:userpool/${${self:custom.config}:COGNITO_POOL_ID}"
        RestApiId:
          Ref: ApiGatewayRestApi
        Type: COGNITO_USER_POOLS

```

Same variable replacements are used in other resources, lambdas, etc. but the error is only thrown to API Cognito Authorizer, I don’t understand…

Thank you all for your attention and help 🙂

---

<div class="post-metadata">

**Author:** ![next-hectormateos2](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/next-hectormateos2/32/6178_2.png) [@next-hectormateos2](https://forum.serverless.com/u/next-hectormateos2)\
**Post date:** [September 30, 2021, 11:47am UTC](https://forum.serverless.com/t/serverless-version-2-35-error-in-variable-replacement-to-cloudformation-template/15907/2 "2021-09-30T11:47:17Z")

</div>

Hi guys!

Solved using [Resolution of environment variables](https://www.serverless.com/framework/docs/environment-variables/), ie, loading environment variables from .env files instead custom .json files.

Thanks anyway to everybody.
