Search code examples
amazon-web-servicesterraformterraform-provider-awsaws-organizations

Get Organisation Unit from Account ID


In terraform is there a way (data source etc.) to extract Organization Unit (OU) from ID of the account that belongs to that OU?

I can extract various pieces of information from

data "aws_caller_identity" "current" {}

or

data "aws_iam_session_context" "current" {}

But no OU.


Solution

  • I couldn't find direct way to do this in terraform, but found out that CLI command list-parents exists that I could use in conjunction with terraform. Until terraform adds this datasource I will go this way.