All Projects → ScaleSec → Terraform_aws_scp

ScaleSec / Terraform_aws_scp

Licence: other
AWS Organizations Service Control Policies (SCPs) written in HashiCorp Terraform.

Labels

Projects that are alternatives of or similar to Terraform aws scp

Example Pragmatic Terraform
『実践Terraform』のサンプルコード
Stars: ✭ 99 (-13.16%)
Mutual labels:  hcl
Aws Accounts Terraform
Stars: ✭ 108 (-5.26%)
Mutual labels:  hcl
Terraform Config
Terraform bits and bytes
Stars: ✭ 111 (-2.63%)
Mutual labels:  hcl
Typhoon
Minimal and free Kubernetes distribution with Terraform
Stars: ✭ 1,397 (+1125.44%)
Mutual labels:  hcl
Libvirt K8s Provisioner
Automate your k8s installation
Stars: ✭ 106 (-7.02%)
Mutual labels:  hcl
Terraform Aws Config
Enables AWS Config and adds managed config rules with good defaults.
Stars: ✭ 107 (-6.14%)
Mutual labels:  hcl
Cobalt
Infrastructure turn-key solution for app service workloads
Stars: ✭ 97 (-14.91%)
Mutual labels:  hcl
Awesome Codepipeline Ci
an AWS CodePipeline, AWS CodeBuild, AWS APIGateway & AWS Lambda CI
Stars: ✭ 112 (-1.75%)
Mutual labels:  hcl
Solutions Terraform Cloudbuild Gitops
Stars: ✭ 106 (-7.02%)
Mutual labels:  hcl
Terraform Aws Ecr
Terraform Module to manage Docker Container Registries on AWS ECR
Stars: ✭ 110 (-3.51%)
Mutual labels:  hcl
Hcledit
A command line editor for HCL
Stars: ✭ 104 (-8.77%)
Mutual labels:  hcl
Spinnaker Terraform
A set of terraform scripts to create an environment from scratch with a Bastion Host, Jenkins, and Spinnaker
Stars: ✭ 106 (-7.02%)
Mutual labels:  hcl
Terraform Google Vault
A Terraform Module for how to run Vault on Google Cloud using Terraform and Packer
Stars: ✭ 108 (-5.26%)
Mutual labels:  hcl
Aws Minikube
Single node Kubernetes instance implemented using Terraform and kubeadm
Stars: ✭ 101 (-11.4%)
Mutual labels:  hcl
Terraform Up And Running Code
Code samples for the book "Terraform: Up & Running" by Yevgeniy Brikman
Stars: ✭ 1,739 (+1425.44%)
Mutual labels:  hcl
Terraform Example
Terraform, Ansible, sticky tape and magic
Stars: ✭ 98 (-14.04%)
Mutual labels:  hcl
Aws Ecs Airflow
Run Airflow in AWS ECS(Elastic Container Service) using Fargate tasks
Stars: ✭ 107 (-6.14%)
Mutual labels:  hcl
Best Practices
No description, website, or topics provided.
Stars: ✭ 1,478 (+1196.49%)
Mutual labels:  hcl
Aws Lambda Es Cleanup
AWS Elasticsearch Lambda Curator
Stars: ✭ 112 (-1.75%)
Mutual labels:  hcl
Terraform Aws Vpc
An example of Terraform which brings up a VPC with Public/Private Subnets
Stars: ✭ 109 (-4.39%)
Mutual labels:  hcl

Terraform AWS Service Control Policies

GitHub Super-Linter

This repo is a collection of AWS Service Control Policies (SCPs) written in Hashicorp Terraform to be used in AWS Organizations.

About Service Control Policies

  • For official documentation about SCPs, visit the links here and here.
  • SCPs enable you to restrict, at the account level of granularity, what services and actions the users, groups and roles in those accounts can do.
  • SCPs are available only in an organization that has all features enabled. SCPs aren't available if your organization has enabled only the consolidated billing features.

Considerations

  • Best practice is to never attach SCPs to the root of your organization. Instead, create an Organizational Unit (OU) underneath root and attach policies there.
  • SCPs do not grant permissions in IAM but instead allow/deny services or set security guardrails.
  • Root user accounts are affected by SCPs.
  • You must have at least one SCP attached to each entity.
  • Maximum of 5 SCPs can be attached to the root, OU, or Account in an organization.

Permission Logic

  • If a user or role has an IAM permission policy that grants access to an action that is also allowed by the applicable SCPs, the user or role can perform that action.
  • If a user or role has an IAM permission policy that grants access to an action that is either not allowed or explicitly denied by the applicable SCPs, the user or role can't perform that action.
  • AWS Organizations use a tree hierarchy for SCPs. This means that if your account is in an Organizational Unit, it inherits that OUs policies.
  • From the documentation:

alt text

Content

  • The security_controls_scp folder is a modularized grouping of AWS Security Best Practices to control at the AWS Organizations level.
    • NOTICE: Due to the limitations of Service Control Policies, only a max of 5 may be attached at one time. With that in mind, you cannot apply ALL of the security controls at once (in their current modularized format). All of the SCPs will attempt to attach to one target ID and will fail. You have a couple of options:
      • Select the aws_iam_policy_document you want and combine into one large data document.
      • Pick and choose 5 modules to deploy and remove the others.
      • Remove aws_organizations_policy_attachment from the modules' main.tf file and apply. You would then need to manually attach the SCPs.
  • The hipaa_scp folder is a service control policy that whitelists HIPAA compliant AWS services based off of https://aws.amazon.com/compliance/hipaa-eligible-services-reference/.
  • The pci_scp folder is a service control policy that whitelists PCI compliant AWS services based off of https://aws.amazon.com/compliance/services-in-scope/.

Usage

An example main.tf for the module to deny the ability to delete CloudTrail Trails:

module "cloudtrail" {
  source      = "./modules/cloudtrail"

  target_id = "123456789012"
  aws_region = "us-east-1"
  shared_credentials_file = "~/.aws/credentials"
  customprofile = "default"
}

Deployment

To Deploy all of the AWS security best practice SCPs navigate to security_controls_scp:

  • terraform init to get the plugins.
  • terraform plan to verify your resource planning.
  • terraform apply to apply your SCPs.

You will receive an error related similar to ConstraintViolationException: You have attached the maximum number of policies to the specified target. when you deploy ALL of the security related SCPs. We recommend only deploying the SCPs you need by leveraging the -target flag in your terraform apply command. An example command to deploy only the S3 and Lambda SCPs is below:

  • terraform apply -target=module.s3 -target=module.lambda

To Remove the SCPs:

  • terraform destroy to destroy the deployed policies.

Deployment Dependencies

Common Errors

Enabled Policy Types

error creating Organizations Policy Attachment: PolicyTypeNotEnabledException: This operation can be performed only for enabled policy types.  
status code: 400, request id: 2b8ecgeb-34h3-11e6-86fb-275c76986dec

SCP functionality must be enabled on the root. See https://github.com/terraform-providers/terraform-provider-aws/issues/4545 for more information

Minimum SCP Requirement

aws_organizations_policy_attachment.deny_orgs_leave_attachment: ConstraintViolationException: You cannot remove the last policy attached to the specified target. You must have at least one attached at all times.
status code: 400, request id: 2d6c75b3-5757-13e9-ab76-518b756aebd3

You must have one SCP attached to an account or OU at all times. See: https://docs.aws.amazon.com/organizations/latest/userguide/orgs_reference_limits.html for more information.

Conflicting Policy Attachment

error creating Organizations Policy Attachment: ConcurrentModificationException: AWS Organizations can't complete your request because it conflicts with another attempt to modify the same entity. Try again later. status code: 400, request id: h725f9g7-1234-12e9-h746-ch123ab12345

Occasionally, if you try to assign many SCPs to one target at the same time, it could error out. If you see this error simply run terraform apply again.

Limitation of Liability

Please view the License for limitations of liability.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].