Data Source: aws_organizations_organization

Get information about the organization that the user's account belongs to

Example Usage

List all account IDs for the organization

data "aws_organizations_organization" "example" {}

output "account_ids" {
  value = data.aws_organizations_organization.example.accounts[*].id
}

SNS topic that can be interacted by the organization only

data "aws_organizations_organization" "example" {}

resource "aws_sns_topic" "sns_topic" {
  name = "my-sns-topic"
}

resource "aws_sns_topic_policy" "sns_topic_policy" {
  arn = aws_sns_topic.sns_topic.arn

  policy = data.aws_iam_policy_document.sns_topic_policy.json
}

data "aws_iam_policy_document" "sns_topic_policy" {
  statement {
    effect = "Allow"

    actions = [
      "SNS:Subscribe",
      "SNS:Publish",
    ]

    condition {
      test     = "StringEquals"
      variable = "aws:PrincipalOrgID"

      values = [
        data.aws_organizations_organization.example.id,
      ]
    }

    principals {
      type        = "AWS"
      identifiers = ["*"]
    }

    resources = [
      aws_sns_topic.sns_topic.arn,
    ]
  }
}

Argument Reference

There are no arguments available for this data source.

Attribute Reference

This data source exports the following attributes in addition to the arguments above:

Master Account or Delegated Administrator Attribute Reference

If the account is the master account or a delegated administrator for the organization, the following attributes are also exported: