AWSTemplateFormatVersion: '2010-09-09' # docs:overview Description: > Creates the IAM roles that the JIT Guard system uses to manage IAM Identity Center group membership, SSO permission set assignments, event rule lifecycle, and cross-account event forwarding. Parameters: # docs:parameter-customer-id CustomerId: Type: String Description: > The JIT Guard customer identifier (a lowercase UUID) assigned to your organisation. Provided by the JIT Guard system administrator. MinLength: 36 MaxLength: 36 AllowedPattern: '^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$' ConstraintDescription: > Customer ID must be a lowercase UUID of the form aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa. Resources: # docs:role-jitguard JitGuardRole: Type: AWS::IAM::Role Properties: RoleName: 'jitguard' Description: > Grants the JIT Guard system permission to manage IAM Identity Center groups, memberships, and account assignments for ephemeral access. AssumeRolePolicyDocument: Version: '2012-10-17' Statement: - Effect: Allow Principal: AWS: 'arn:aws:iam::233084605897:role/jitguard-customer-access' Action: sts:AssumeRole Condition: StringEquals: sts:ExternalId: !Ref CustomerId Policies: - PolicyName: jitguard-permissions PolicyDocument: Version: '2012-10-17' Statement: # docs:permission-identity-store-group-management - Sid: IdentityStoreGroupManagement Effect: Allow Action: - identitystore:CreateGroup - identitystore:DeleteGroup - identitystore:CreateGroupMembership - identitystore:DeleteGroupMembership - identitystore:ListUsers - identitystore:ListGroups - identitystore:GetGroupId - identitystore:DescribeGroup # The engine resolves approver group members to emails via # DescribeUser (#1335); without it, approval lookup fails. - identitystore:DescribeUser - identitystore:ListGroupMemberships - identitystore:ListGroupMembershipsForMember Resource: '*' # docs:permission-sso-admin-account-assignment - Sid: SSOAdminAccountAssignment Effect: Allow Action: - sso:CreateAccountAssignment - sso:DescribeAccountAssignmentCreationStatus - sso:ListAccountAssignments - sso:DeleteAccountAssignment - sso:DescribeAccountAssignmentDeletionStatus Resource: '*' # docs:permission-organization-read - Sid: OrganizationRead Effect: Allow Action: - organizations:ListAccounts - organizations:ListOrganizationalUnitsForParent - organizations:ListRoots - organizations:DescribeOrganization - organizations:DescribeAccount - organizations:ListTagsForResource - organizations:ListParents - organizations:ListChildren Resource: '*' # docs:permission-region-discovery - Sid: RegionDiscovery Effect: Allow Action: - ec2:DescribeRegions Resource: '*' # docs:permission-sso-discovery - Sid: SSODiscovery Effect: Allow Action: - sso:ListInstances - sso:DescribeInstance - sso:ListPermissionSets - sso:DescribePermissionSet Resource: '*' # docs:permission-eventbridge-rule-management - Sid: EventBridgeRuleManagement Effect: Allow Action: - events:DescribeRule - events:PutRule - events:PutTargets - events:RemoveTargets - events:DeleteRule - events:ListTargetsByRule Resource: 'arn:aws:events:*:*:rule/jitguard-*' # docs:permission-pass-forward-role - Sid: PassForwardRoleToEventBridge Effect: Allow Action: - iam:PassRole - iam:GetRole Resource: !GetAtt JitGuardEvents.Arn # docs:role-jitguard-events JitGuardEvents: Type: AWS::IAM::Role Properties: RoleName: 'jitguard-events' Description: > Allows EventBridge rules in this account to forward customer events to the central JIT Guard event bus. AssumeRolePolicyDocument: Version: '2012-10-17' Statement: - Effect: Allow Principal: Service: events.amazonaws.com Action: sts:AssumeRole Policies: - PolicyName: forward-to-central-bus PolicyDocument: Version: '2012-10-17' Statement: # docs:permission-forward-to-central-bus - Effect: Allow Action: events:PutEvents Resource: 'arn:aws:events:eu-west-1:233084605897:event-bus/jitguard-org-events' # docs:outputs Outputs: RoleArn: Description: ARN of the JIT Guard role assumed by the backend Value: !GetAtt JitGuardRole.Arn EventsRoleArn: Description: ARN of the JIT Guard event forwarding role Value: !GetAtt JitGuardEvents.Arn