Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
66 changes: 40 additions & 26 deletions docs/data-sources/audit_trail_event.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,55 +5,69 @@ page_title: "Scaleway: scaleway_audit_trail_event"

# scaleway_audit_trail_event

Use this data source to get a list of existing Audit Trail events.
The [`scaleway_audit_trail_event`](https://registry.terraform.io/providers/scaleway/scaleway/latest/docs/data-sources/audit_trail_event) data source is used to get a list of existing Audit Trail events.

For more information refer to the [Audit Trail API documentation](https://www.scaleway.com/en/developers/api/audit-trail/).


## Example Usage

```hcl
```terraform
# Retrieve audit trail for a specific resource
data "scaleway_audit_trail_event" "find_by_resource_id" {
resource_id = "11111111-1111-1111-1111-111111111111"
}
```

```terraform
# Retrieve all audit trail events on the default organization
data "scaleway_audit_trail_event" "find_all" {
data "scaleway_audit_trail_event" "find_all" {}
```

```terraform
# Retrieve audit trail for a specific Scaleway product
data "scaleway_audit_trail_event" "find_by_product_name" {
product_name = "secret-manager"
}
```

```terraform
# Retrieve audit trail events with various filtering
data "scaleway_audit_trail_event" "find_with_filters" {
region = "fr-par"
service_name = "instance"
method_name = "CreateServer"
principal_id = "11111111-1111-1111-1111-111111111111"
source_ip = "192.0.2.1"
status = 200
recorded_after = "2025-10-01T00:00:00Z"
recorded_before = "2025-12-31T23:59:59Z"
order_by = "recorded_at_desc"
}
```

```terraform
# Retrieve audit trail events on a specific organization
data "scaleway_audit_trail_event" "find_by_org" {
organization_id = "11111111-1111-1111-1111-111111111111"
}
```

```terraform
# Retrieve audit trail events on a specific project
data "scaleway_audit_trail_event" "find_by_project" {
project_id = "11111111-1111-1111-1111-111111111111"
}
```

```terraform
# Retrieve audit trail events for a specific type of resource
data "scaleway_audit_trail_event" "find_by_resource_type" {
resource_type = "instance_server"
}

# Retrieve audit trail for a specific resource
data "scaleway_audit_trail_event" "find_by_resource_id" {
resource_id = "11111111-1111-1111-1111-111111111111"
}

# Retrieve audit trail for a specific Scaleway product
data "scaleway_audit_trail_event" "find_by_product_name" {
product_name = "secret-manager"
}

# Retrieve audit trail events with various filtering
data "scaleway_audit_trail_event" "find_with_filters" {
region = "fr-par"
service_name = "instance"
method_name = "CreateServer"
principal_id = "11111111-1111-1111-1111-111111111111"
source_ip = "192.0.2.1"
status = 200
recorded_after = "2025-10-01T00:00:00Z"
recorded_before = "2025-12-31T23:59:59Z"
order_by = "recorded_at_desc"
}
```


## Argument Reference

- `region` - (Optional) The [region](../guides/regions_and_zones.md#regions) you want to target. Defaults to the region specified in the [provider configuration](../index.md#region).
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Retrieve audit trail for a specific resource
data "scaleway_audit_trail_event" "find_by_resource_id" {
resource_id = "11111111-1111-1111-1111-111111111111"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Retrieve all audit trail events on the default organization
data "scaleway_audit_trail_event" "find_all" {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Retrieve audit trail for a specific Scaleway product
data "scaleway_audit_trail_event" "find_by_product_name" {
product_name = "secret-manager"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Retrieve audit trail events with various filtering
data "scaleway_audit_trail_event" "find_with_filters" {
region = "fr-par"
service_name = "instance"
method_name = "CreateServer"
principal_id = "11111111-1111-1111-1111-111111111111"
source_ip = "192.0.2.1"
status = 200
recorded_after = "2025-10-01T00:00:00Z"
recorded_before = "2025-12-31T23:59:59Z"
order_by = "recorded_at_desc"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Retrieve audit trail events on a specific organization
data "scaleway_audit_trail_event" "find_by_org" {
organization_id = "11111111-1111-1111-1111-111111111111"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Retrieve audit trail events on a specific project
data "scaleway_audit_trail_event" "find_by_project" {
project_id = "11111111-1111-1111-1111-111111111111"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Retrieve audit trail events for a specific type of resource
data "scaleway_audit_trail_event" "find_by_resource_type" {
resource_type = "instance_server"
}
6 changes: 3 additions & 3 deletions examples/instance-servers/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ resource "scaleway_instance_ip" "ip" {
}

resource "scaleway_instance_server" "server" {
count = var.server_count
type = "PLAY2-MICRO"
image = "ubuntu_jammy"
count = var.server_count
type = "PLAY2-MICRO"
image = "ubuntu_jammy"
ip_ids = [scaleway_instance_ip.ip[count.index].id]
}
3 changes: 3 additions & 0 deletions internal/services/audittrail/descriptions/event.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
The [`scaleway_audit_trail_event`](https://registry.terraform.io/providers/scaleway/scaleway/latest/docs/data-sources/audit_trail_event) data source is used to get a list of existing Audit Trail events.

For more information refer to the [Audit Trail API documentation](https://www.scaleway.com/en/developers/api/audit-trail/).
5 changes: 5 additions & 0 deletions internal/services/audittrail/event_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package audittrail

import (
"context"
_ "embed"
"fmt"

"github.com/google/uuid"
Expand All @@ -18,8 +19,12 @@ import (
"github.com/scaleway/terraform-provider-scaleway/v2/internal/verify"
)

//go:embed descriptions/event.md
var eventDescription string

func DataSourceEvent() *schema.Resource {
return &schema.Resource{
Description: eventDescription,
ReadContext: DataSourceEventsRead,
SchemaFunc: eventSchema,
}
Expand Down
51 changes: 7 additions & 44 deletions templates/data-sources/audit_trail_event.md.tmpl
Original file line number Diff line number Diff line change
@@ -1,58 +1,21 @@
{{- /*gotype: github.com/hashicorp/terraform-plugin-docs/internal/provider.ResourceTemplateType */ -}}
---
subcategory: "Audit Trail"
page_title: "Scaleway: scaleway_audit_trail_event"
---

# scaleway_audit_trail_event

Use this data source to get a list of existing Audit Trail events.
For more information refer to the [Audit Trail API documentation](https://www.scaleway.com/en/developers/api/audit-trail/).
{{ .Description }}

{{ if .HasExamples }}
## Example Usage

```hcl
# Retrieve all audit trail events on the default organization
data "scaleway_audit_trail_event" "find_all" {
}
{{ range .ExampleFiles -}}
{{ tffile . }}

# Retrieve audit trail events on a specific organization
data "scaleway_audit_trail_event" "find_by_org" {
organization_id = "11111111-1111-1111-1111-111111111111"
}

# Retrieve audit trail events on a specific project
data "scaleway_audit_trail_event" "find_by_project" {
project_id = "11111111-1111-1111-1111-111111111111"
}

# Retrieve audit trail events for a specific type of resource
data "scaleway_audit_trail_event" "find_by_resource_type" {
resource_type = "instance_server"
}

# Retrieve audit trail for a specific resource
data "scaleway_audit_trail_event" "find_by_resource_id" {
resource_id = "11111111-1111-1111-1111-111111111111"
}

# Retrieve audit trail for a specific Scaleway product
data "scaleway_audit_trail_event" "find_by_product_name" {
product_name = "secret-manager"
}

# Retrieve audit trail events with various filtering
data "scaleway_audit_trail_event" "find_with_filters" {
region = "fr-par"
service_name = "instance"
method_name = "CreateServer"
principal_id = "11111111-1111-1111-1111-111111111111"
source_ip = "192.0.2.1"
status = 200
recorded_after = "2025-10-01T00:00:00Z"
recorded_before = "2025-12-31T23:59:59Z"
order_by = "recorded_at_desc"
}
```
{{ end }}
{{ end -}}

## Argument Reference

Expand Down
Loading