View a markdown version of this page

Enable controls across an organization - CloudFormation

Enable controls across an organization

To enable a control across an organization, deploy an AWS::CloudFormation::HookTypeConfig resource for each control with service-managed CloudFormation StackSets. Settings can differ by organizational unit (OU). For example, you can set a control to FAIL mode in a production OU and to WARN mode in a development OU.

Create a template that sets a control's mode

The following template contains one AWS::CloudFormation::HookTypeConfig resource that configures the AWS::Controls::IAMRoleInUseRemoved control. The FailureMode parameter sets the mode for each stack set that you create from the template.

AWSTemplateFormatVersion: 2010-09-09 Parameters: FailureMode: Type: String AllowedValues: - FAIL - WARN Resources: IAMRoleInUseRemovedConfig: Type: AWS::CloudFormation::HookTypeConfig Properties: TypeName: AWS::Controls::IAMRoleInUseRemoved Configuration: !Sub '{"CloudFormationConfiguration":{"HookConfiguration":{"HookInvocationStatus":"ENABLED","FailureMode":"${FailureMode}"}}}'

Deploy the template to organizational units with StackSets

Create one stack set for each mode, and then create stack instances in the OUs that use that mode. The following example sets FAIL mode in a production OU and WARN mode in a development OU.

To enable a control across an organization (AWS CLI)
  1. Use the create-stack-set command to create the stack set for the production OU.

    aws cloudformation create-stack-set \ --stack-set-name ProactiveControlsProd \ --template-body file://template.yaml \ --parameters ParameterKey=FailureMode,ParameterValue=FAIL \ --permission-model SERVICE_MANAGED \ --auto-deployment Enabled=true,RetainStacksOnAccountRemoval=false
  2. Use the create-stack-instances command to deploy the stack set to the production OU.

    aws cloudformation create-stack-instances \ --stack-set-name ProactiveControlsProd \ --deployment-targets OrganizationalUnitIds=ou-1111-11111111 \ --regions us-east-1
  3. Create the stack set for the development OU with WARN mode.

    aws cloudformation create-stack-set \ --stack-set-name ProactiveControlsDev \ --template-body file://template.yaml \ --parameters ParameterKey=FailureMode,ParameterValue=WARN \ --permission-model SERVICE_MANAGED \ --auto-deployment Enabled=true,RetainStacksOnAccountRemoval=false
  4. Deploy the stack set to the development OU.

    aws cloudformation create-stack-instances \ --stack-set-name ProactiveControlsDev \ --deployment-targets OrganizationalUnitIds=ou-2222-22222222 \ --regions us-east-1