You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/docs/aws/services/cloudtrail.md
+25-28Lines changed: 25 additions & 28 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,5 @@
1
1
---
2
2
title: "CloudTrail"
3
-
linkTitle: "CloudTrail"
4
3
description: Get started with CloudTrail on LocalStack
5
4
tags: ["Ultimate"]
6
5
persistence: supported
@@ -12,7 +11,7 @@ CloudTrail is a service provided by Amazon Web Services (AWS) that enables you t
12
11
It records API calls and actions made on your AWS resources, offering an audit trail that helps you understand changes, diagnose issues, and maintain compliance.
13
12
14
13
LocalStack allows you to use the CloudTrail APIs in your local environment to create and manage Event history and trails.
15
-
The supported APIs are available on our [API coverage page]({{< ref "coverage_cloudtrail" >}}), which provides information on the extent of CloudTrail's integration with LocalStack.
14
+
The supported APIs are available on our [API coverage page](), which provides information on the extent of CloudTrail's integration with LocalStack.
16
15
17
16
## Getting started
18
17
@@ -26,50 +25,50 @@ We will demonstrate how to enable S3 object logging to CloudTrail using AWS CLI.
26
25
Before you create a trail, you need to create an S3 bucket where CloudTrail can deliver the log data.
27
26
You can use the [`mb`](https://docs.aws.amazon.com/cli/latest/reference/s3/mb.html) command to create a bucket:
28
27
29
-
{{< command >}}
30
-
$ awslocal s3 mb s3://my-bucket
31
-
{{< /command >}}
28
+
```bash
29
+
awslocal s3 mb s3://my-bucket
30
+
```
32
31
33
32
### Create a trail
34
33
35
34
You can create a trail which would allow the delivery of events to the S3 bucket we created earlier.
36
35
You can use the [`CreateTrail`](https://docs.aws.amazon.com/awscloudtrail/latest/APIReference/API_CreateTrail.html) API to create a trail.
37
36
Run the following command to create a trail:
38
37
39
-
{{< command >}}
40
-
$ awslocal cloudtrail create-trail \
38
+
```bash
39
+
awslocal cloudtrail create-trail \
41
40
--name MyTrail \
42
41
--s3-bucket-name my-bucket
43
-
{{< /command >}}
42
+
```
44
43
45
44
### Enable logging and configure event selectors
46
45
47
46
You can now enable logging for your trail.
48
47
You can use the [`StartLogging`](https://docs.aws.amazon.com/awscloudtrail/latest/APIReference/API_StartLogging.html) API to enable logging for your trail.
You can further configure event selectors for the trail.
56
55
In this example, we will configure the trail to log all S3 object level events.
57
56
You can use the [`PutEventSelectors`](https://docs.aws.amazon.com/awscloudtrail/latest/APIReference/API_PutEventSelectors.html) API to configure event selectors for your trail.
58
57
Run the following command to configure event selectors:
You can verify if your configuration is correct by using the [`GetEventSelectors`](https://docs.aws.amazon.com/awscloudtrail/latest/APIReference/API_GetEventSelectors.html) API.
67
66
Run the following command to verify your configuration:
68
67
69
-
{{< command >}}
70
-
$ awslocal cloudtrail get-event-selectors \
68
+
```bash
69
+
awslocal cloudtrail get-event-selectors \
71
70
--trail-name MyTrail
72
-
{{< /command >}}
71
+
```
73
72
74
73
The following output would be retrieved:
75
74
@@ -98,21 +97,21 @@ The following output would be retrieved:
98
97
You can now test the configuration by creating an object in the S3 bucket.
99
98
You can use the [`cp`](https://docs.aws.amazon.com/cli/latest/reference/s3/cp.html) command to copy an object in the S3 bucket:
You can verify that the object was created in the S3 bucket.
108
107
You can also verify that the object level event was logged by CloudTrail using the [`LookupEvents`](https://docs.aws.amazon.com/awscloudtrail/latest/APIReference/API_LookupEvents.html) API.
@@ -133,9 +132,7 @@ The following output would be retrieved:
133
132
The LocalStack Web Application provides a Resource Browser for managing CloudTrail's Event History & Trails.
134
133
You can access the Resource Browser by opening the LocalStack Web Application in your browser, navigating to the **Resources** section, and then clicking on **CloudTrail** under the **Management/Governance** section.
0 commit comments