######################################################################## # 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 configure the delegated administrator account - - 'detective_org' solution in the repo, https://github.com/aws-samples/aws-security-reference-architecture-examples (sra-1ssgnse80) Metadata: SRA: Version: 1.0 Order: 2 AWS::CloudFormation::Interface: ParameterGroups: - Label: default: General Properties Parameters: - pSRASolutionName - Label: default: Role Properties Parameters: - pDetectiveConfigurationRoleName - pDetectiveOrgLambdaRoleName - pManagementAccountId ParameterLabels: pManagementAccountId: default: Organization Management Account ID pDetectiveOrgLambdaRoleName: default: Lambda Role Name pDetectiveConfigurationRoleName: default: Detective Configuration Role Name pSRASolutionName: default: SRA Solution Name Parameters: pManagementAccountId: AllowedPattern: '^\d{12}$' ConstraintDescription: Must be 12 digits Description: Organization Management Account ID Type: String pDetectiveOrgLambdaRoleName: AllowedPattern: '^[\w+=,.@-]{1,64}$' ConstraintDescription: Max 64 alphanumeric characters. Also special characters supported [+, =, ., @, -] Default: sra-detective-org-lambda Description: Lambda Role Name Type: String pDetectiveConfigurationRoleName: AllowedPattern: '^[\w+=,.@-]{1,64}$' ConstraintDescription: Max 64 alphanumeric characters. Also special characters supported [+, =, ., @, -] Default: sra-detective-configuration Description: Detective Configuration IAM Role Name Type: String pSRASolutionName: AllowedValues: [sra-detective-org] Default: sra-detective-org Description: The SRA solution name. The default value is the folder name of the solution Type: String Resources: rConfigurationRole: 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 pDetectiveConfigurationRoleName AssumeRolePolicyDocument: Version: 2012-10-17 Statement: - Effect: Allow Action: sts:AssumeRole Condition: StringEquals: aws:PrincipalArn: - !Sub arn:${AWS::Partition}:iam::${pManagementAccountId}:role/${pDetectiveOrgLambdaRoleName} Principal: AWS: - !Sub arn:${AWS::Partition}:iam::${pManagementAccountId}:root Path: '/' Policies: - PolicyName: sra-detective-org-policy-organizations PolicyDocument: Version: 2012-10-17 Statement: - Sid: OrganizationsListAccounts Effect: Allow Action: - organizations:ListAccounts - organizations:DescribeOrganization Resource: '*' - PolicyName: sra-detective-org-policy PolicyDocument: Version: 2012-10-17 Statement: - Sid: DetectiveAccess Effect: Allow Action: - detective:ListGraphs Resource: '*' - PolicyName: sra-detective PolicyDocument: Version: 2012-10-17 Statement: - Sid: DetectiveAccess Effect: Allow Action: - detective:CreateMembers - detective:DescribeOrganizationConfiguration - detective:ListMembers - detective:ListDataSourcePackages - detective:UpdateDatasourcePackages - detective:UpdateOrganizationConfiguration Resource: !Sub arn:${AWS::Partition}:detective:*:*:graph:* - PolicyName: sra-detective-org-policy-iam PolicyDocument: Version: 2012-10-17 Statement: - Sid: AllowReadIamActions Effect: Allow Action: iam:GetRole Resource: !Sub arn:${AWS::Partition}:iam::${AWS::AccountId}:role/* - Sid: AllowCreateServiceLinkedRole Effect: Allow Action: iam:CreateServiceLinkedRole Condition: StringLike: iam:AWSServiceName: detective.amazonaws.com Resource: !Sub arn:${AWS::Partition}:iam::${AWS::AccountId}:role/aws-service-role/detective.amazonaws.com/AWSServiceRoleForDetective - Sid: AllowPolicyActions Effect: Allow Action: iam:PutRolePolicy Resource: !Sub arn:${AWS::Partition}:iam::${AWS::AccountId}:role/aws-service-role/detective.amazonaws.com/AWSServiceRoleForDetective - Sid: AllowDeleteServiceLinkRole Effect: Allow Action: iam:DeleteServiceLinkedRole Resource: !Sub arn:${AWS::Partition}:iam::${AWS::AccountId}:role/aws-service-role/detective.amazonaws.com/AWSServiceRoleForDetective Tags: - Key: sra-solution Value: !Ref pSRASolutionName