If you are automating AWS resources in Terraform, then you will want to not hardcode things as much as possible.
Terraform makes it possible to pull the
account_id from the local credentials.
How to get the AccountID data attributes
data.tf file and place the following item in it:
Now the account_id will be available to you within your standard code as follows:
How to use the AccountID data attributes
This can now be used in a module, or wherever you need to reference the account id: