aws-samples
terraform-aws-organization-policies
HCL

Deploy SCPs, RCPs, and other AWS organization policies with Terraform

Last updated May 13, 2026
105
Stars
21
Forks
1
Issues
0
Stars/day
Attention Score
65
Language breakdown
HCL 80.5%
Smarty 19.5%
Files click to expand
README

terraform-aws-organization-policies

Deploy SCPs, RCPs, and other AWS organization policies with Terraform.

Module Inputs

SCP example:
module "scps" {
  source      = "aws-samples/organization-policies/aws"
  version     = "3.1.0"
  policytype = "SERVICECONTROL_POLICY"
  ou_map = {
    "r-1xyz"           = ["root", "allow_services"] #root
    "ou-abcd-11223344" = ["sandbox"]                #sandbox ou
    "ou-efgh-22334455" = ["ssm"]                    #workload ou
  }
}
RCP example:
module "rcps" {
  source      = "aws-samples/organization-policies/aws"
  version     = "3.1.0"
  policytype = "RESOURCECONTROL_POLICY"
  ou_map = {
    "r-1xyz" = ["root"] #root
  }
}

policy_type is the type of organizational policy. A new module needs to be created for each policy type.

oumap is a map of OU IDs and the policies attached to them. Policies are stored as json files in an adjacent directory. The directory name defaults to the policy type, eg ./servicecontrol_policy/.

The above two module inputs would look like this:

. ├── resourcecontrolpolicy │   └── root.json ├── servicecontrolpolicy │   ├── allow_services.json │   ├── root.json │   ├── sandbox.json │   └── ssm.json └── main.tf

Optional Inputs

module "scps" {
  ... 
  policies_directory = "policies/scps"
}

policiesdirectory overrides the name and location of the directory used to store policies. Otherwise it will default to the name of the policy type, eg ./servicecontrol_policy/.

Template Files

The module accepts template files (.json.tpl). These can be inputted alongside json files.

module "scps" {   source      = "aws-samples/organization-policies/aws"   version     = "3.1.0"   policytype = "SERVICECONTROL_POLICY"   ou_map = {     "r-1xyz"           = ["root", "iam"] #root   }   template_variables = {     managementaccountid = var.managementaccountid   } }
templatevariables inserts variables into template files. See iam.json.tpl for an example.

Troubleshooting

| Issue | Fix | |---|---| | PolicyTypeNotEnabledException | Enable the policy type within AWS Organizations first. |

Related Resources

Security

See CONTRIBUTING for more information.

License

This library is licensed under the MIT-0 License. See the LICENSE file.

🔗 More in this category

© 2026 GitRepoTrend · aws-samples/terraform-aws-organization-policies · Updated daily from GitHub