AWS Serverless, CloudFormation : Error, Trying to populate non string value into a string for variable

I am using serverless framework for deploying my application on AWS Cloud.

https://serverless.com/

I want to use the value of AWS Account ID in my serverless.yml file and I want to export the acccount ID as the environment variable, so that it can be accessed from Lambda functions.

Based on the value of this lambda function, I want to create some resources ( like IAM roles, etc.), which refer to this accountId variable.

But when I try to deploy the stack, I get the below error,

Trying to populate non string value into a string for variable ${self:custom.accountId}. Please make sure the value of the property is a string.

My Serverless.yml file is as below

custom:
  accountId : !Ref "AWS::AccountId"


provider:
  name: aws
  runtime: go1.x
  stage: dev

  region: us-east-1

  environment:
     ACCOUNT_ID : ${self:custom.accountId}       
     myRoleArn: arn:aws:iam::${self:custom.accountId}:role/xxxxxxxx

Is there any way to refer to the value of the Account Id in the serverless.yml file?