S3 TLS Enforcement SCP
This Terraform Module creates an AWS Organizations Service Control Policy (SCP) that denies all S3 operations not using TLS and attaches it to the organization root. This provides defense-in-depth for CIS compliance across all member accounts by ensuring that no account in the organization can make unencrypted S3 requests.
Features
-
Creates an SCP that denies all
s3:*actions whenaws:SecureTransportisfalse -
Attaches the policy to the AWS Organizations root, enforcing it across all member accounts
-
Supports conditional resource creation via the
create_resourcesvariable
Learn
Note
This repo is a part of the Gruntwork Infrastructure as Code Library, a collection of reusable, battle-tested, production ready infrastructure code. If you’ve never used the Infrastructure as Code Library before, make sure to read How to use the Gruntwork Infrastructure as Code Library!
Core concepts
Repo organization
-
modules: the main implementation code for this repo, broken down into multiple standalone, orthogonal submodules.
-
examples: This folder contains working examples of how to use the submodules.
-
test: Automated tests for the modules and examples.
Deploy
Non-production deployment (quick start for learning)
If you just want to try this module out, check out the following resources:
- examples/s3-tls-enforcement-scp: A sample configuration optimized for learning, experimenting, and testing (but not production usage).
Production deployment
If you want to deploy this module in production, check out the following resources:
Note
This module must be deployed from the management account (root account) of your AWS Organization, as SCPs can only be created and attached there.
Sample Usage
- Terraform
- Terragrunt
# ------------------------------------------------------------------------------------------------------
# DEPLOY GRUNTWORK'S S3-TLS-ENFORCEMENT-SCP MODULE
# ------------------------------------------------------------------------------------------------------
module "s_3_tls_enforcement_scp" {
source = "git::git@github.com:gruntwork-io/terraform-aws-security.git//modules/s3-tls-enforcement-scp?ref=v1.4.0"
# ----------------------------------------------------------------------------------------------------
# REQUIRED VARIABLES
# ----------------------------------------------------------------------------------------------------
# A name prefix to use for the SCP policy name.
name_prefix = <string>
# The ID of the AWS Organizations root, organizational unit, or account to
# attach the SCP to.
target_id = <string>
# ----------------------------------------------------------------------------------------------------
# OPTIONAL VARIABLES
# ----------------------------------------------------------------------------------------------------
# Set to false to skip creating resources. This is a workaround for
# Terraform's lack of support for conditional modules.
create_resources = true
}
# ------------------------------------------------------------------------------------------------------
# DEPLOY GRUNTWORK'S S3-TLS-ENFORCEMENT-SCP MODULE
# ------------------------------------------------------------------------------------------------------
terraform {
source = "git::git@github.com:gruntwork-io/terraform-aws-security.git//modules/s3-tls-enforcement-scp?ref=v1.4.0"
}
inputs = {
# ----------------------------------------------------------------------------------------------------
# REQUIRED VARIABLES
# ----------------------------------------------------------------------------------------------------
# A name prefix to use for the SCP policy name.
name_prefix = <string>
# The ID of the AWS Organizations root, organizational unit, or account to
# attach the SCP to.
target_id = <string>
# ----------------------------------------------------------------------------------------------------
# OPTIONAL VARIABLES
# ----------------------------------------------------------------------------------------------------
# Set to false to skip creating resources. This is a workaround for
# Terraform's lack of support for conditional modules.
create_resources = true
}
Reference
- Inputs
- Outputs
Required
name_prefixstringA name prefix to use for the SCP policy name.
target_idstringThe ID of the AWS Organizations root, organizational unit, or account to attach the SCP to.
Optional
create_resourcesboolSet to false to skip creating resources. This is a workaround for Terraform's lack of support for conditional modules.
trueThe ID of the S3 TLS enforcement SCP.