Skip to content

Commit 676d0b3

Browse files
committed
revamp cloudtrail
1 parent 585ed68 commit 676d0b3

File tree

1 file changed

+25
-28
lines changed

1 file changed

+25
-28
lines changed

src/content/docs/aws/services/cloudtrail.md

Lines changed: 25 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
---
22
title: "CloudTrail"
3-
linkTitle: "CloudTrail"
43
description: Get started with CloudTrail on LocalStack
54
tags: ["Ultimate"]
65
persistence: supported
@@ -12,7 +11,7 @@ CloudTrail is a service provided by Amazon Web Services (AWS) that enables you t
1211
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.
1312

1413
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.
1615

1716
## Getting started
1817

@@ -26,50 +25,50 @@ We will demonstrate how to enable S3 object logging to CloudTrail using AWS CLI.
2625
Before you create a trail, you need to create an S3 bucket where CloudTrail can deliver the log data.
2726
You can use the [`mb`](https://docs.aws.amazon.com/cli/latest/reference/s3/mb.html) command to create a bucket:
2827

29-
{{< command >}}
30-
$ awslocal s3 mb s3://my-bucket
31-
{{< /command >}}
28+
```bash
29+
awslocal s3 mb s3://my-bucket
30+
```
3231

3332
### Create a trail
3433

3534
You can create a trail which would allow the delivery of events to the S3 bucket we created earlier.
3635
You can use the [`CreateTrail`](https://docs.aws.amazon.com/awscloudtrail/latest/APIReference/API_CreateTrail.html) API to create a trail.
3736
Run the following command to create a trail:
3837

39-
{{< command >}}
40-
$ awslocal cloudtrail create-trail \
38+
```bash
39+
awslocal cloudtrail create-trail \
4140
--name MyTrail \
4241
--s3-bucket-name my-bucket
43-
{{< /command >}}
42+
```
4443

4544
### Enable logging and configure event selectors
4645

4746
You can now enable logging for your trail.
4847
You can use the [`StartLogging`](https://docs.aws.amazon.com/awscloudtrail/latest/APIReference/API_StartLogging.html) API to enable logging for your trail.
4948
Run the following command to enable logging:
5049

51-
{{< command >}}
52-
$ awslocal cloudtrail start-logging --name MyTrail
53-
{{< /command >}}
50+
```bash
51+
awslocal cloudtrail start-logging --name MyTrail
52+
```
5453

5554
You can further configure event selectors for the trail.
5655
In this example, we will configure the trail to log all S3 object level events.
5756
You can use the [`PutEventSelectors`](https://docs.aws.amazon.com/awscloudtrail/latest/APIReference/API_PutEventSelectors.html) API to configure event selectors for your trail.
5857
Run the following command to configure event selectors:
5958

60-
{{< command >}}
61-
$ awslocal cloudtrail put-event-selectors \
59+
```bash
60+
awslocal cloudtrail put-event-selectors \
6261
--trail-name MyTrail \
6362
--event-selectors '[{"ReadWriteType": "All", "IncludeManagementEvents":true, "DataResources": [{"Type": "AWS::S3::Object", "Values": ["arn:aws:s3:::my-bucket/"]}]}]'
64-
{{< /command >}}
63+
```
6564

6665
You can verify if your configuration is correct by using the [`GetEventSelectors`](https://docs.aws.amazon.com/awscloudtrail/latest/APIReference/API_GetEventSelectors.html) API.
6766
Run the following command to verify your configuration:
6867

69-
{{< command >}}
70-
$ awslocal cloudtrail get-event-selectors \
68+
```bash
69+
awslocal cloudtrail get-event-selectors \
7170
--trail-name MyTrail
72-
{{< /command >}}
71+
```
7372

7473
The following output would be retrieved:
7574

@@ -98,21 +97,21 @@ The following output would be retrieved:
9897
You can now test the configuration by creating an object in the S3 bucket.
9998
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:
10099

101-
{{< command >}}
102-
$ echo "hello world" > /tmp/hello-world
103-
$ awslocal s3 cp /tmp/hello-world s3://my-bucket/hello-world
104-
$ awslocal s3 ls s3://my-bucket
105-
{{< /command >}}
100+
```bash
101+
echo "hello world" > /tmp/hello-world
102+
awslocal s3 cp /tmp/hello-world s3://my-bucket/hello-world
103+
awslocal s3 ls s3://my-bucket
104+
```
106105

107106
You can verify that the object was created in the S3 bucket.
108107
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.
109108
Run the following command to verify the event:
110109

111-
{{< command >}}
112-
$ awslocal cloudtrail lookup-events \
110+
```bash
111+
awslocal cloudtrail lookup-events \
113112
--lookup-attributes AttributeKey=EventName,AttributeValue=PutObject \
114113
--max-results 1
115-
{{< /command >}}
114+
```
116115

117116
The following output would be retrieved:
118117

@@ -133,9 +132,7 @@ The following output would be retrieved:
133132
The LocalStack Web Application provides a Resource Browser for managing CloudTrail's Event History & Trails.
134133
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.
135134

136-
<img src="cloudtrail-resource-browser.png" alt="CloudTrail Resource Browser" title="CloudTrail Resource Browser" width="900" />
137-
<br>
138-
<br>
135+
![CloudTrail Resource Browser](/images/aws/cloudtrail-resource-browser.png)
139136

140137
The Resource Browser allows you to perform the following actions:
141138

0 commit comments

Comments
 (0)