Skip to content

Commit d233ec8

Browse files
authored
access_monitoring_rules: Add spec.schedules (#59007)
* Extend access_monitoring_rules API Spec now includes a schedules field * Validate schedules * Update terraform provider * Remove duplicate test case * Comment shift fields * Address feedback - Remove timezone configuration - Use schedule map instead of list
1 parent bafb299 commit d233ec8

File tree

7 files changed

+868
-54
lines changed

7 files changed

+868
-54
lines changed

api/gen/proto/go/teleport/accessmonitoringrules/v1/access_monitoring_rules.pb.go

Lines changed: 241 additions & 54 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/proto/teleport/accessmonitoringrules/v1/access_monitoring_rules.proto

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ message AccessMonitoringRuleSpec {
6767
// subjects, the desired_state may be set to `reviewed` to indicate that the
6868
// Access Request should be automatically reviewed.
6969
string desired_state = 7;
70+
71+
// schedules specifies a map of schedules that can be used to configure the
72+
// access monitoring rule conditions.
73+
map<string, Schedule> schedules = 8;
7074
}
7175

7276
// Notification contains configurations for plugin notification rules.
@@ -87,6 +91,29 @@ message AutomaticReview {
8791
string decision = 2;
8892
}
8993

94+
// Schedule specifies a schedule that can be used to configure rule conditions.
95+
message Schedule {
96+
// TimeSchedule specifies an in-line schedule.
97+
TimeSchedule time = 1;
98+
}
99+
100+
// TimeSchedule specifies an in-line schedule.
101+
message TimeSchedule {
102+
// Shifts contains a set of shifts that make up the schedule.
103+
// Shifts are configured in UTC.
104+
repeated Shift shifts = 1;
105+
106+
// Shift contains the weekday, start time, and end time of a shift.
107+
message Shift {
108+
// Weekday specifies the day of the week, e.g., "Sunday", "Monday", "Tuesday".
109+
string weekday = 1;
110+
// Start specifies the start time in the format HH:MM, e.g., "12:30".
111+
string start = 2;
112+
// End specifies the end time in the format HH:MM, e.g., "12:30".
113+
string end = 3;
114+
}
115+
}
116+
90117
// CreateAccessMonitoringRuleRequest is the request for CreateAccessMonitoringRule.
91118
message CreateAccessMonitoringRuleRequest {
92119
// access_monitoring_rule is the specification of the rule to be created.

docs/pages/reference/infrastructure-as-code/terraform-provider/data-sources/access_monitoring_rule.mdx

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ Optional:
4646
- `condition` (String) condition is a predicate expression that operates on the specified subject resources, and determines whether the subject will be moved into desired state.
4747
- `desired_state` (String) desired_state defines the desired state of the subject. For Access Request subjects, the desired_state may be set to `reviewed` to indicate that the Access Request should be automatically reviewed.
4848
- `notification` (Attributes) notification defines the plugin configuration for notifications if rule is triggered. Both notification and automatic_review may be set within the same access_monitoring_rule. If both fields are set, the rule will trigger both notifications and automatic reviews for the same set of access events. Separate plugins may be used if both notifications and automatic_reviews is set. (see [below for nested schema](#nested-schema-for-specnotification))
49+
- `schedules` (Attributes Map) schedules specifies a map of schedules that can be used to configure the access monitoring rule conditions. (see [below for nested schema](#nested-schema-for-specschedules))
4950
- `states` (List of String) states are the desired state which the monitoring rule is attempting to bring the subjects matching the condition to.
5051

5152
### Nested Schema for `spec.automatic_review`
@@ -64,6 +65,29 @@ Optional:
6465
- `recipients` (List of String) recipients is the list of recipients the plugin should notify.
6566

6667

68+
### Nested Schema for `spec.schedules`
69+
70+
Optional:
71+
72+
- `time` (Attributes) TimeSchedule specifies an in-line schedule. (see [below for nested schema](#nested-schema-for-specschedulestime))
73+
74+
### Nested Schema for `spec.schedules.time`
75+
76+
Optional:
77+
78+
- `shifts` (Attributes List) Shifts contains a set of shifts that make up the schedule. Shifts are configured in UTC. (see [below for nested schema](#nested-schema-for-specschedulestimeshifts))
79+
80+
### Nested Schema for `spec.schedules.time.shifts`
81+
82+
Optional:
83+
84+
- `end` (String) End specifies the end time in the format HH:MM, e.g., "12:30".
85+
- `start` (String) Start specifies the start time in the format HH:MM, e.g., "12:30".
86+
- `weekday` (String) Weekday specifies the day of the week, e.g., "Sunday", "Monday", "Tuesday".
87+
88+
89+
90+
6791

6892
### Nested Schema for `metadata`
6993

docs/pages/reference/infrastructure-as-code/terraform-provider/resources/access_monitoring_rule.mdx

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ Optional:
6868
- `condition` (String) condition is a predicate expression that operates on the specified subject resources, and determines whether the subject will be moved into desired state.
6969
- `desired_state` (String) desired_state defines the desired state of the subject. For Access Request subjects, the desired_state may be set to `reviewed` to indicate that the Access Request should be automatically reviewed.
7070
- `notification` (Attributes) notification defines the plugin configuration for notifications if rule is triggered. Both notification and automatic_review may be set within the same access_monitoring_rule. If both fields are set, the rule will trigger both notifications and automatic reviews for the same set of access events. Separate plugins may be used if both notifications and automatic_reviews is set. (see [below for nested schema](#nested-schema-for-specnotification))
71+
- `schedules` (Attributes Map) schedules specifies a map of schedules that can be used to configure the access monitoring rule conditions. (see [below for nested schema](#nested-schema-for-specschedules))
7172
- `states` (List of String) states are the desired state which the monitoring rule is attempting to bring the subjects matching the condition to.
7273

7374
### Nested Schema for `spec.automatic_review`
@@ -86,6 +87,29 @@ Optional:
8687
- `recipients` (List of String) recipients is the list of recipients the plugin should notify.
8788

8889

90+
### Nested Schema for `spec.schedules`
91+
92+
Optional:
93+
94+
- `time` (Attributes) TimeSchedule specifies an in-line schedule. (see [below for nested schema](#nested-schema-for-specschedulestime))
95+
96+
### Nested Schema for `spec.schedules.time`
97+
98+
Optional:
99+
100+
- `shifts` (Attributes List) Shifts contains a set of shifts that make up the schedule. Shifts are configured in UTC. (see [below for nested schema](#nested-schema-for-specschedulestimeshifts))
101+
102+
### Nested Schema for `spec.schedules.time.shifts`
103+
104+
Optional:
105+
106+
- `end` (String) End specifies the end time in the format HH:MM, e.g., "12:30".
107+
- `start` (String) Start specifies the start time in the format HH:MM, e.g., "12:30".
108+
- `weekday` (String) Weekday specifies the day of the week, e.g., "Sunday", "Monday", "Tuesday".
109+
110+
111+
112+
89113

90114
### Nested Schema for `metadata`
91115

0 commit comments

Comments
 (0)