Skip to content
This repository has been archived by the owner on Jul 28, 2023. It is now read-only.

Add table turbot_notification #9

Merged
merged 29 commits into from
Dec 6, 2021
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/registry-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.14
go-version: 1.16

- name: Get latest version tag
run: |-
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Use SQL to query infrastructure including servers, networks, identity and more f

- **[Get started →](https://hub.steampipe.io/plugins/turbot/turbot)**
- Documentation: [Table definitions & examples](https://hub.steampipe.io/plugins/turbot/turbot/tables)
- Community: [Slack Channel](https://join.slack.com/t/steampipe/shared_invite/zt-oij778tv-lYyRTWOTMQYBVAbtPSWs3g)
- Community: [Slack Channel](https://steampipe.io/community/join)
- Get involved: [Issues](https://github.com/turbot/steampipe-plugin-turbot/issues)


Expand Down
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ connection "turbot" {
## Get involved

- Open source: https://github.com/turbot/steampipe-plugin-turbot
- Community: [Slack Channel](https://join.slack.com/t/steampipe/shared_invite/zt-oij778tv-lYyRTWOTMQYBVAbtPSWs3g)
- Community: [Slack Channel](https://steampipe.io/community/join)

## Advanced configuration options

Expand Down
148 changes: 148 additions & 0 deletions docs/tables/turbot_notification.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
# Table: turbot_notification

Notifications represent significant events in the lifecycle of turbot infrastructure, including:

- History of change for a resource (e.g. my-bucket).
- A log of state changes and actions performed by a control (e.g. my-bucket Tags).
- Changes to policy settings, and the specific policy values they update.
- Records of permission grants, activations, deactivations and revocations.

Queries to this table must specify (usually in the `where` clause) at least one
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we use must, or recommended, since those are not required, but we can use those for faster query.

of these columns: `id`, `resource_id`, `notification_type`, `control_id`, `control_type_id`,
`control_type_uri`, `resource_type_id`, `resource_type_uri`, `policy_type_id`, `policy_type_uri`, `actor_identity_id`, `create_timestamp` or `filter`.

Please [refer](https://turbot.com/v5/docs/reference/filter/notifications#examples) for notification filter examples
LalitLab marked this conversation as resolved.
Show resolved Hide resolved

### Find all Turbot grants activations in last 1 week using `filter`

```sql
select
grant_id,
notification_type,
grant_permission_type,
grant_permission_level,
create_timestamp,
actor_trunk_title,
grant_identity_trunk_title,
grant_end_date,
grant_identity_profile_id,
resource_title
from
turbot_notification
where
filter = 'notificationType:activeGrant createTimestamp:>T-1w'
and grant_permission_type = 'Turbot'
order by
create_timestamp desc,
notification_type,
actor_trunk_title,
resource_title;
```

### Find all AWS grants activations in last 7 days

```sql
select
grant_id,
notification_type,
grant_permission_type,
grant_permission_level,
create_timestamp,
actor_trunk_title,
grant_identity_trunk_title,
grant_end_date,
grant_identity_profile_id,
resource_title
from
turbot_notification
where
notification_type = 'active_grants_created'
and create_timestamp >= (current_date - interval '7' day)
and grant_permission_type = 'AWS'
order by
create_timestamp desc,
notification_type,
actor_trunk_title,
resource_title;
```

### Find all AWS S3 buckets created in last 7 days

```sql
select
create_timestamp,
resource_id,
resource_title,
resource_trunk_title,
actor_trunk_title
from
turbot_notification
where
notification_type = 'resource_created'
and create_timestamp >= (current_date - interval '7' day)
and resource_type_uri = 'tmod:@turbot/aws-s3#/resource/types/bucket'
order by
create_timestamp desc;
```

### All policy settings set on a given resource or below

```sql
select
notification_type,
create_timestamp,
policy_id,
policy_trunk_title,
policy_type_uri,
resource_trunk_title,
resource_type_trunk_title,
policy_read_only,
policy_secret,
policy_value
from
turbot_notification
where
resource_id = 191382256916538
and filter = 'notificationType:policySetting level:self,descendant'
order by
create_timestamp desc;
```

### All policy settings notification for AWS > Account > Regions policy

```sql
select
notification_type,
create_timestamp,
policy_id,
resource_id,
resource_trunk_title,
policy_value
from
turbot_notification
where
policy_type_uri = 'tmod:@turbot/aws#/policy/types/regionsDefault'
and filter = 'notificationType:policySetting level:self'
order by
create_timestamp desc;
```

### All notification for AWS > Account > Budget > Budget control
LalitLab marked this conversation as resolved.
Show resolved Hide resolved

```sql
select
notification_type,
create_timestamp,
control_id,
resource_trunk_title,
control_state,
control_reason
from
turbot_notification
where
control_type_uri = 'tmod:@turbot/aws#/control/types/budget'
and filter = 'notificationType:control level:self'
order by
resource_id,
create_timestamp desc;
```
10 changes: 5 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
module github.com/turbot/steampipe-plugin-turbot

go 1.15
go 1.16

require (
github.com/blang/semver v3.5.1+incompatible
github.com/go-yaml/yaml v2.1.0+incompatible
github.com/hashicorp/terraform v0.12.0
github.com/machinebox/graphql v0.2.3-0.20180904014615-9835de6386a3
github.com/matryer/is v1.2.0 // indirect
github.com/mattn/go-isatty v0.0.12 // indirect
github.com/matryer/is v1.4.0 // indirect
github.com/mitchellh/go-homedir v1.1.0
github.com/mitchellh/mapstructure v1.3.3
github.com/pkg/errors v0.9.1
github.com/stretchr/testify v1.6.1
github.com/turbot/go-kit v0.2.2-0.20210628165333-268ba0a30be3
github.com/turbot/steampipe-plugin-sdk v1.6.1
github.com/turbot/go-kit v0.3.0
github.com/turbot/steampipe-plugin-sdk v1.7.0
golang.org/x/net v0.0.0-20210119194325-5f4716e94777 // indirect
gopkg.in/yaml.v2 v2.2.8 // indirect
)
19 changes: 9 additions & 10 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,8 @@ github.com/machinebox/graphql v0.2.3-0.20180904014615-9835de6386a3/go.mod h1:F+k
github.com/marstr/guid v1.1.0/go.mod h1:74gB1z2wpxxInTG6yaqA7KrtM0NZ+RbrcqDvYHefzho=
github.com/masterzen/simplexml v0.0.0-20160608183007-4572e39b1ab9/go.mod h1:kCEbxUJlNDEBNbdQMkPSp6yaKcRXVI6f4ddk8Riv4bc=
github.com/masterzen/winrm v0.0.0-20190223112901-5e5c9a7fe54b/go.mod h1:wr1VqkwW0AB5JS0QLy5GpVMS9E3VtRoSYXUYyVk46KY=
github.com/matryer/is v1.2.0 h1:92UTHpy8CDwaJ08GqLDzhhuixiBUUD1p3AU6PHddz4A=
github.com/matryer/is v1.2.0/go.mod h1:2fLPjFQM9rhQ15aVEtbuwhJinnOqrmgXPNdZsdwlWXA=
github.com/matryer/is v1.4.0 h1:sosSmIWwkYITGrxZ25ULNDeKiMNzFSr4V/eqBQP0PeE=
github.com/matryer/is v1.4.0/go.mod h1:8I/i5uYgLzgsgEloJE1U6xx5HkBQpAZvepWuujKwMRU=
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
github.com/mattn/go-colorable v0.1.1/go.mod h1:FuOcm+DKB9mbwrcAfNl7/TZVBZ6rcnceauSikq3lYCQ=
github.com/mattn/go-colorable v0.1.4 h1:snbPLB8fVfU9iwbbo30TPtbLRzwWu6aJS6Xh4eaaviA=
Expand All @@ -238,9 +238,8 @@ github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNx
github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
github.com/mattn/go-isatty v0.0.5/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
github.com/mattn/go-isatty v0.0.10 h1:qxFzApOv4WsAL965uUPIsXzAKCZxN2p9UqdhFS4ZW10=
github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcMEpPG5Rm84=
github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY=
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
github.com/mattn/go-runewidth v0.0.7 h1:Ei8KR0497xHyKJPAv59M1dkC+rOZCMBJ+t3fZ+twI54=
github.com/mattn/go-runewidth v0.0.7/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
Expand Down Expand Up @@ -345,10 +344,10 @@ github.com/terraform-providers/terraform-provider-openstack v1.15.0/go.mod h1:2a
github.com/tkrajina/go-reflector v0.5.4 h1:dS9aJEa/eYNQU/fwsb5CSiATOxcNyA/gG/A7a582D5s=
github.com/tkrajina/go-reflector v0.5.4/go.mod h1:9PyLgEOzc78ey/JmQQHbW8cQJ1oucLlNQsg8yFvkVk8=
github.com/tmc/grpc-websocket-proxy v0.0.0-20171017195756-830351dc03c6/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
github.com/turbot/go-kit v0.2.2-0.20210628165333-268ba0a30be3 h1:UAfWYp+K7oESlqomRus4k+h/dSPXU17tEcarbRdtBwQ=
github.com/turbot/go-kit v0.2.2-0.20210628165333-268ba0a30be3/go.mod h1:SBdPRngbEfYubiR81iAVtO43oPkg1+ASr+XxvgbH7/k=
github.com/turbot/steampipe-plugin-sdk v1.6.1 h1:zXs0jiGyYc0vq3YwPDtw78jCZbirjSPEeTcZEDvoPJk=
github.com/turbot/steampipe-plugin-sdk v1.6.1/go.mod h1:zM68yGM+wjkjDPz8yUTx6078GDTVWkrI26EC56XIspw=
github.com/turbot/go-kit v0.3.0 h1:o4zZIO1ovdmJ2bHWOdXnnt8jJMIDGqYSkZvBREzFeMQ=
github.com/turbot/go-kit v0.3.0/go.mod h1:SBdPRngbEfYubiR81iAVtO43oPkg1+ASr+XxvgbH7/k=
github.com/turbot/steampipe-plugin-sdk v1.7.0 h1:84OFfUoxgMXHb51tPMtkabnIuADw3hAA07Ye4+dTAFY=
github.com/turbot/steampipe-plugin-sdk v1.7.0/go.mod h1:y7q8abyaXXQNzwE9l4Tn/gkEnvmcyPpyedpHF04wggs=
github.com/ugorji/go v0.0.0-20180813092308-00b869d2f4a5/go.mod h1:hnLbHMwcvSihnDhEfx2/BzKp2xb0Y+ErdfYcrs9tkJQ=
github.com/ulikunitz/xz v0.5.5/go.mod h1:2bypXElzHzzJZwzH67Y6wb67pO62Rzfn7BSiF4ABRW8=
github.com/vmihailenco/msgpack v3.3.3+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk=
Expand Down Expand Up @@ -425,7 +424,6 @@ golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5h
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190502175342-a43fa875dd82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68 h1:nxC68pudNYkKU6jWhgrqdreuFiOQWj1Fs7T3VrH4Pjw=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
Expand Down Expand Up @@ -494,8 +492,9 @@ gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMy
gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
grpc.go4.org v0.0.0-20170609214715-11d0a25b4919/go.mod h1:77eQGdRu53HpSqPFJFmuJdjuHRquDANNeA4x7B8WQ9o=
Expand Down
25 changes: 13 additions & 12 deletions helpers/helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ package helpers

import (
"encoding/json"
"github.com/stretchr/testify/assert"
"log"
"testing"

"github.com/stretchr/testify/assert"
)

func TestRemoveProperties(t *testing.T) {
Expand All @@ -15,43 +16,43 @@ func TestRemoveProperties(t *testing.T) {
expected []interface{}
}
tests := []test{
test{
{
"No exclusions",
[]interface{}{"a", "b", "c"},
[]string{},
[]interface{}{"a", "b", "c"},
},
test{
{
"String exclusions",
[]interface{}{"a", "b", "c"},
[]string{"a"},
[]interface{}{"b", "c"},
},
test{
{
"All excluded",
[]interface{}{"a", "b", "c"},
[]string{"a", "b", "c"},
[]interface{}(nil),
},
test{
{
"Map exclusion",
[]interface{}{"a", "b", map[string]string{"c": "C", "d": "D"}},
[]string{"c"},
[]interface{}{"a", "b", map[string]string{"d": "D"}},
},
test{
{
"2 map exclusions",
[]interface{}{"a", "b", map[string]string{"c": "C", "d": "D"}, map[string]string{"e": "E", "f": "F"}},
[]string{"c", "f"},
[]interface{}{"a", "b", map[string]string{"d": "D"}, map[string]string{"e": "E"}},
},
test{
{
"No matching exclusions",
[]interface{}{"a", "b", "c"},
[]string{"d"},
[]interface{}{"a", "b", "c"},
},
test{
{
"No matching exclusions with map",
[]interface{}{"a", "b", map[string]string{"c": "C", "d": "D"}},
[]string{"e"},
Expand All @@ -72,14 +73,14 @@ func TestGetNullProperties(t *testing.T) {
expected []interface{}
}
tests := []test{
test{
{
"Empty object",
`{
"allOf": []
}`,
[]interface{}{nil},
},
test{
{
"Single exclusion",
`{
"allOf": [
Expand All @@ -104,7 +105,7 @@ func TestGetNullProperties(t *testing.T) {
}`,
[]interface{}{"Id"},
},
test{
{
"No exclusion",
`{
"allOf": [
Expand All @@ -121,7 +122,7 @@ func TestGetNullProperties(t *testing.T) {
}`,
[]interface{}(nil),
},
test{
{
"Multiple exclusion",
`{
"allOf": [
Expand Down
1 change: 1 addition & 0 deletions turbot/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ func Plugin(ctx context.Context) *plugin.Plugin {
TableMap: map[string]*plugin.Table{
"turbot_control": tableTurbotControl(ctx),
"turbot_control_type": tableTurbotControlType(ctx),
"turbot_notification": tableTurbotNotification(ctx),
"turbot_policy_setting": tableTurbotPolicySetting(ctx),
"turbot_policy_type": tableTurbotPolicyType(ctx),
"turbot_resource": tableTurbotResource(ctx),
Expand Down
Loading