######################################################################## # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # SPDX-License-Identifier: MIT-0 ######################################################################## AWSTemplateFormatVersion: 2010-09-09 Description: This template creates an IAM role to delete the GuardDuty detector within each account and region. - 'guardduty_org' solution in the repo, https://github.com/aws-samples/aws-security-reference-architecture-examples (sra-1ssgnse4k) Metadata: SRA: Version: 1.1 Order: 2 AWS::CloudFormation::Interface: ParameterGroups: - Label: default: General Properties Parameters: - pSRASolutionName - Label: default: Role Properties Parameters: - pDeleteDetectorRoleName - pManagementAccountId - pGuardDutyOrgLambdaRoleName ParameterLabels: pDeleteDetectorRoleName: default: Delete Detector Role Name pManagementAccountId: default: Organization Management Account ID pGuardDutyOrgLambdaRoleName: default: GuardDuty Lambda Role Name pSRASolutionName: default: SRA Solution Name Parameters: pDeleteDetectorRoleName: AllowedPattern: '^[\w+=,.@-]{1,64}$' ConstraintDescription: Max 64 alphanumeric characters. Also special characters supported [+, =, ., @, -] Default: sra-guardduty-delete-detector Description: Delete Detector IAM Role Name Type: String pGuardDutyOrgLambdaRoleName: AllowedPattern: '^[\w+=,.@-]{1,64}$' ConstraintDescription: Max 64 alphanumeric characters. Also special characters supported [+, =, ., @, -] Default: sra-guardduty-org-lambda Description: Lambda Role Name Type: String pManagementAccountId: AllowedPattern: '^\d{12}$' ConstraintDescription: Must be 12 digits Description: Organization Management Account ID Type: String pSRASolutionName: AllowedValues: [sra-guardduty-org] Default: sra-guardduty-org Description: The SRA solution name. The default value is the folder name of the solution Type: String Resources: rDeleteDetectorRole: Type: AWS::IAM::Role Metadata: cfn_nag: rules_to_suppress: - id: W11 reason: Actions require * in resource - id: W28 reason: Explicit role name provided Properties: RoleName: !Ref pDeleteDetectorRoleName AssumeRolePolicyDocument: Statement: - Action: sts:AssumeRole Condition: StringEquals: aws:PrincipalArn: - !Sub arn:${AWS::Partition}:iam::${pManagementAccountId}:role/${pGuardDutyOrgLambdaRoleName} Effect: Allow Principal: AWS: - !Sub arn:${AWS::Partition}:iam::${pManagementAccountId}:root Version: 2012-10-17 Path: '/' Policies: - PolicyName: sra-guardduty-org-policy-guardduty-delete PolicyDocument: Version: 2012-10-17 Statement: - Sid: GuardDutyNoResource Effect: Allow Action: guardduty:ListDetectors Resource: '*' - Sid: GuardDutyWithResource Effect: Allow Action: guardduty:DeleteDetector Resource: !Sub arn:${AWS::Partition}:guardduty:*:${AWS::AccountId}:detector/* Tags: - Key: sra-solution Value: !Ref pSRASolutionName