# CLI get aws account id

**URL:** <https://forum.serverless.com/t/cli-get-aws-account-id/6201>\
**Category:** Serverless Framework\
**Tags:** aws, variables\
**Created:** [October 21, 2018, 1:39pm UTC](https://forum.serverless.com/t/cli-get-aws-account-id/6201 "2018-10-21T13:39:28Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![richarddd](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/richarddd/32/2985_2.png) [@richarddd](https://forum.serverless.com/u/richarddd)\
**Post date:** [October 21, 2018, 1:39pm UTC](https://forum.serverless.com/t/cli-get-aws-account-id/6201/1 "2018-10-21T13:39:29Z")

</div>

Hi,

I’ve managed to hack together this piped bash line to receive accountId. Is there some easier way?

`serverless info | grep https | sed -E 's/(.*)https:\/\/(.*)/\2/' | cut -d '.' -f 1 | head -n 1`

Thanks

---

<div class="post-metadata">

**Author:** ![teddy-gustiaux](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/teddy-gustiaux/32/2494_2.png) [@teddy-gustiaux](https://forum.serverless.com/u/teddy-gustiaux)\
**Post date:** [October 22, 2018, 12:36pm UTC](https://forum.serverless.com/t/cli-get-aws-account-id/6201/2 "2018-10-22T12:36:58Z")

</div>

If what you want is to retrieve your AWS account ID to use in your `serverless.yml` configuration file, I would recommend you to have a look at the [serverless-pseudo-parameters plugin](https://www.npmjs.com/package/serverless-pseudo-parameters).

EDIT:

If you are just looking to retrieve the ID from the command line, then you can use the [AWS CLI](https://docs.aws.amazon.com/cli/latest/index.html) and run `aws sts get-caller-identity --output text --query 'Account'`.

Hope it helps! 🙂
