hkb-detection-test
Service role of the hkb-detection-test job. Starts, commands and ends its own instance in hkb-private-a.
- Lives in: Sandbox. Trusted by:
codebuild.amazonaws.com. - Boundary:
hkb-detection-boundary. - Reach: 13 named actions across 4 services (ec2, iam, logs, ssm); 1 statement on all resources.
- Source:
baseline/hkb-baseline-detection-test.yaml, resourceJobRole.
Trust policy
AssumeRolePolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: Allow
Principal:
Service: codebuild.amazonaws.com
Action: sts:AssumeRole
Condition:
StringEquals:
aws:SourceAccount: !Ref AWS::AccountId
Permissions
Policies:
- PolicyName: hkb-detection-test
PolicyDocument:
Version: "2012-10-17"
Statement:
- Sid: StartItsInstance
Effect: Allow
Action: ec2:RunInstances
Resource: !Sub arn:${AWS::Partition}:ec2:${AWS::Region}:${AWS::AccountId}:instance/*
Condition:
StringEquals:
aws:RequestTag/Component: detection-test
ec2:InstanceProfile: !GetAtt TargetInstanceProfile.Arn
ec2:InstanceType: t4g.nano
ec2:MetadataHttpTokens: required
- Sid: ItsVolume
Effect: Allow
Action: ec2:RunInstances
Resource: !Sub arn:${AWS::Partition}:ec2:${AWS::Region}:${AWS::AccountId}:volume/*
- Sid: ItsPrivateInterface
Effect: Allow
Action: ec2:RunInstances
Resource: !Sub arn:${AWS::Partition}:ec2:${AWS::Region}:${AWS::AccountId}:network-interface/*
Condition:
Bool:
ec2:AssociatePublicIpAddress: "false"
- Sid: ThePrivateSubnet
Effect: Allow
Action: ec2:RunInstances
Resource: !Sub arn:${AWS::Partition}:ec2:${AWS::Region}:${AWS::AccountId}:subnet/*
Condition:
StringEquals:
aws:ResourceTag/Name: hkb-private-a
- Sid: TheNatClientsGroup
Effect: Allow
Action: ec2:RunInstances
Resource: !Sub arn:${AWS::Partition}:ec2:${AWS::Region}:${AWS::AccountId}:security-group/*
Condition:
StringEquals:
aws:ResourceTag/Name: hkb-net-nat-clients
- Sid: AnAmazonImage
Effect: Allow
Action: ec2:RunInstances
Resource: !Sub arn:${AWS::Partition}:ec2:${AWS::Region}::image/*
Condition:
StringEquals:
ec2:Owner: amazon
- Sid: TagAtStart
Effect: Allow
Action: ec2:CreateTags
Resource:
- !Sub arn:${AWS::Partition}:ec2:${AWS::Region}:${AWS::AccountId}:instance/*
- !Sub arn:${AWS::Partition}:ec2:${AWS::Region}:${AWS::AccountId}:volume/*
Condition:
StringEquals:
ec2:CreateAction: RunInstances
- Sid: PassTheTarget
Effect: Allow
Action: iam:PassRole
Resource: !GetAtt TargetRole.Arn
Condition:
StringEquals:
iam:PassedToService: ec2.amazonaws.com
- Sid: EndItsInstance
Effect: Allow
Action: ec2:TerminateInstances
Resource: !Sub arn:${AWS::Partition}:ec2:${AWS::Region}:${AWS::AccountId}:instance/*
Condition:
StringEquals:
aws:ResourceTag/Component: detection-test
- Sid: CommandItsInstance
Effect: Allow
Action: ssm:SendCommand
Resource: !Sub arn:${AWS::Partition}:ec2:${AWS::Region}:${AWS::AccountId}:instance/*
Condition:
StringEquals:
ssm:resourceTag/Component: detection-test
- Sid: WithTheShellDocument
Effect: Allow
Action: ssm:SendCommand
Resource: !Sub arn:${AWS::Partition}:ssm:${AWS::Region}::document/AWS-RunShellScript
# These take no resource or condition that would narrow them.
- Sid: Lookups
Effect: Allow
Action:
- ec2:DescribeInstances
- ec2:DescribeSecurityGroups
- ec2:DescribeSubnets
- ssm:DescribeInstanceInformation
- ssm:GetCommandInvocation
Resource: "*"
- Sid: LatestAmazonLinux
Effect: Allow
Action: ssm:GetParameter
Resource: !Sub arn:${AWS::Partition}:ssm:${AWS::Region}::parameter/aws/service/ami-amazon-linux-latest/*
- Sid: OwnLogs
Effect: Allow
Action:
- logs:CreateLogStream
- logs:PutLogEvents
Resource: !Sub ${JobLogGroup.Arn}:*
Page information
- Owner
- Identity and Access
- Status
- current Current: generated from the templates and records in the repository at this build.
- Generated from
baseline/hkb-baseline-detection-test.yaml- Linked from
- Detection test, Access, Roles, Security tooling roles
- Plain markdown
- /wiki/roles/tools/hkb-detection-test/index.md