|
| 1 | +--- |
| 2 | +page_title: Audit log streaming |
| 3 | +description: |- |
| 4 | + Set up audit log streaming for HCP Boundary with AWS CloudWatch or Datadog. |
| 5 | +--- |
| 6 | + |
| 7 | +# Audit log streaming |
| 8 | + |
| 9 | +HCP Boundary supports near real-time streaming of audit events to existing customer managed accounts of supported providers. Audit events capture all create, list, update, and delete operations performed by an authenticated Boundary client (Desktop, CLI, or the browser-based admin UI) on any of the following Boundary resources: |
| 10 | + |
| 11 | +- Sessions |
| 12 | +- Scopes |
| 13 | +- Workers |
| 14 | +- Credential stores, credential libraries, credentials |
| 15 | +- Auth methods, roles, managed groups, groups, users, accounts, grants |
| 16 | +- Host catalogs, host sets, host, targets |
| 17 | + |
| 18 | +The captured data includes the user ID of the user performing the operation, the timestamp, and the full request and response payloads. |
| 19 | + |
| 20 | +Audit logs allow administrators to track user activity and enable security teams to ensure compliance in accordance with regulatory requirements. |
| 21 | + |
| 22 | +The documentation outlines the steps required to enable and configure audit log streaming to the supported providers AWS CloudWatch and Datadog. You can stream logs to one account at a time. |
| 23 | + |
| 24 | +## Configure streaming with AWS CloudWatch |
| 25 | + |
| 26 | +To configure audit log streaming with AWS CloudWatch, you must create an [IAM role](https://docs.aws.amazon.com/iam/?id=docs_gateway) that HCP Boundary can use to send logs to AWS CloudWatch. Below are the steps to create the IAM role with necessary configuration. |
| 27 | + |
| 28 | +### Create IAM policy |
| 29 | + |
| 30 | +1. Launch [AWS Management Console](https://console.aws.amazon.com/) and navigate to **IAM > Policies**, and click **Create policy**. |
| 31 | +1. Choose **JSON** and enter the following policy in the policy editor. |
| 32 | + |
| 33 | + ```json |
| 34 | + { |
| 35 | + "Version": "2012-10-17", |
| 36 | + "Statement": [ |
| 37 | + { |
| 38 | + "Sid": "HCPLogStreaming", |
| 39 | + "Effect": "Allow", |
| 40 | + "Action": [ |
| 41 | + "logs:PutLogEvents", |
| 42 | + "logs:DescribeLogStreams", |
| 43 | + "logs:DescribeLogGroups", |
| 44 | + "logs:CreateLogStream", |
| 45 | + "logs:CreateLogGroup", |
| 46 | + "logs:TagLogGroup" |
| 47 | + ], |
| 48 | + "Resource": "*" |
| 49 | + } |
| 50 | + ] |
| 51 | + } |
| 52 | + ``` |
| 53 | + |
| 54 | +1. Click **Next**. |
| 55 | +1. Enter a name for the new policy, for example, `hcp-log-streaming`. |
| 56 | +1. Click **Create policy** to create the IAM policy. |
| 57 | + |
| 58 | +### Configure the IAM role |
| 59 | + |
| 60 | +Before you create a new IAM role, get the HashiCorp generated external ID from the HCP Portal. |
| 61 | + |
| 62 | +1. Launch the [HCP Portal](https://portal.cloud.hashicorp.com/). |
| 63 | +1. Navigate to Boundary, and select your cluster. |
| 64 | +1. Select **Audit logs**. |
| 65 | +  |
| 66 | +1. Click **Enable log streaming**. |
| 67 | +1. Select **AWS CloudWatch**. |
| 68 | +1. Copy the **External ID** value. |
| 69 | +  |
| 70 | + You will need this value during the IAM role creation. |
| 71 | + |
| 72 | +Next, create the IAM role using AWS Management Console or HashiCorp Terraform. |
| 73 | + |
| 74 | +<Tabs> |
| 75 | +<Tab heading="AWS Management Console"> |
| 76 | + |
| 77 | +1. Launch **AWS Management Console** and navigate to **IAM > Roles**, and click **Create role**. |
| 78 | +1. For **Trusted entity type**, select **AWS account**. |
| 79 | +1. For **An AWS account**, select **Another AWS account**. |
| 80 | +1. Enter **711430482607** in the **Account ID** field. |
| 81 | +1. Under **Options**, select **Require external ID**. |
| 82 | +1. Enter the **External ID** value you copied from the [HCP portal](https://portal.cloud.hashicorp.com/). |
| 83 | +1. Click **Next**. |
| 84 | +1. Select the policy you created earlier, and click **Next** to attach the policy to the role. |
| 85 | +1. Click **Create role** to complete. |
| 86 | + |
| 87 | + |
| 88 | +</Tab> |
| 89 | +<Tab heading="Terraform"> |
| 90 | + |
| 91 | +Use the following Terraform configuration to create the IAM role necessary to enable audit log streaming. |
| 92 | + |
| 93 | +```hcl |
| 94 | +data "aws_iam_policy_document" "allow_hcp_to_stream_logs" { |
| 95 | + statement { |
| 96 | + effect = "Allow" |
| 97 | + actions = [ |
| 98 | + "logs:PutLogEvents", # To write logs to cloudwatch |
| 99 | + "logs:DescribeLogStreams", # To get the latest sequence token of a log stream |
| 100 | + "logs:DescribeLogGroups", # To check if a log group already exists |
| 101 | + "logs:CreateLogGroup", # To create a new log group |
| 102 | + "logs:CreateLogStream" # To create a new log stream |
| 103 | + ] |
| 104 | + resources = [ |
| 105 | + "*" |
| 106 | + ] |
| 107 | + } |
| 108 | +} |
| 109 | +
|
| 110 | +data "aws_iam_policy_document" "trust_policy" { |
| 111 | + statement { |
| 112 | + sid = "HCPLogStreaming" |
| 113 | + effect = "Allow" |
| 114 | + actions = ["sts:AssumeRole"] |
| 115 | + principals { |
| 116 | + identifiers = ["711430482607"] |
| 117 | + type = "AWS" |
| 118 | + } |
| 119 | + condition { |
| 120 | + test = "StringEquals" |
| 121 | + variable = "sts:ExternalId" |
| 122 | + values = [ |
| 123 | + "<ExternalID-generated-by-Hashicorp>" |
| 124 | + ] |
| 125 | + } |
| 126 | + } |
| 127 | +} |
| 128 | +
|
| 129 | +resource "aws_iam_role" "role" { |
| 130 | + name = "hcp-log-streaming" |
| 131 | + description = "iam role that allows hcp to send logs to cloudwatch logs" |
| 132 | + assume_role_policy = data.aws_iam_policy_document.trust_policy.json |
| 133 | + inline_policy { |
| 134 | + name = "inline-policy" |
| 135 | + policy = data.aws_iam_policy_document.allow_hcp_to_stream_logs.json |
| 136 | + } |
| 137 | +} |
| 138 | +``` |
| 139 | + |
| 140 | +</Tab> |
| 141 | +</Tabs> |
| 142 | + |
| 143 | +Once you have created the IAM role, you can configure the audit log streaming in HCP Boundary. |
| 144 | + |
| 145 | +1. Launch the [HCP Portal](https://portal.cloud.hashicorp.com/). |
| 146 | +1. From the HCP Boundary **Overview** page, select the **Audit logs** view. |
| 147 | +1. Click **Enable log streaming**. |
| 148 | +1. Select **AWS CloudWatch**. |
| 149 | +  |
| 150 | +1. Under the **CloudWatch configuration** section, enter your **Destination name**, and **Role ARN**. |
| 151 | +1. Select the **Region** that matches where you want your data stored. |
| 152 | +1. Click **Save**. |
| 153 | + |
| 154 | +Logs should arrive within your AWS CloudWatch environment in a few minutes after Boundary usage. |
| 155 | + |
| 156 | +HashiCorp dynamically creates the log group and log streams for you. You can find the log group in your AWS CloudWatch with the prefix `/hashicorp` after setting up your configuration. The log group lets you filter the HashiCorp generated logs separately from other logs you may have in CloudWatch. |
| 157 | + |
| 158 | +Refer to the [AWS documentation](https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/WhatIsCloudWatchLogs.html) for details on log exploration. |
| 159 | + |
| 160 | +## Configure streaming with Datadog |
| 161 | + |
| 162 | +To configure audit log streaming with Datadog, you will need the following: |
| 163 | + |
| 164 | +- The region your Datadog account is in |
| 165 | +- Your Datadog [API key](https://docs.datadoghq.com/account_management/api-app-keys/) |
| 166 | + |
| 167 | +Complete the following steps: |
| 168 | + |
| 169 | +1. Launch the [HCP Portal](https://portal.cloud.hashicorp.com/). |
| 170 | +1. Navigate to Boundary, and select your cluster. |
| 171 | +1. Select **Audit logs**. |
| 172 | +  |
| 173 | +1. Click **Enable log streaming**. |
| 174 | +1. Select **Datadog**. |
| 175 | +  |
| 176 | +1. Under the **Datadog configuration**, enter your **Destination name** and **API Key**. |
| 177 | +1. Select the **Datadog site region** that matches your existing Datadog environment. |
| 178 | +1. Click **Save** |
| 179 | + |
| 180 | +Logs should arrive within your Datadog environment in a few minutes after using Boundary. |
| 181 | +Refer to the [Datadog documentation](https://docs.datadoghq.com/getting_started/logs/#explore-your-logs) for details on log exploration. |
| 182 | + |
| 183 | +## Test your streaming configuration |
| 184 | + |
| 185 | +During the streaming configuration setup, you can test that the streaming configuration is working within HCP. Testing the configuration can be helpful when you want to verify you entered the correct credentials and other parameters on the configuration page. To test the configuration, enter the parameters for the logging provider you want to test, then click **Test connection**. |
| 186 | + |
| 187 | +  |
| 188 | + |
| 189 | +HCP sends a test message to the logging provider and shares the status of success or failure on the **Enable log streaming** page. |
| 190 | + |
| 191 | +You can also test the configuration when you update a streaming configuration that you have already configured. |
| 192 | + |
| 193 | +## Update your streaming configuration |
| 194 | + |
| 195 | +You can update the configuration of the existing audit log streaming. For example, you may need to rotate a secret used for your logging provider, or you may need to switch from one logging provider to another. |
| 196 | + |
| 197 | +1. Launch the [HCP Portal](https://portal.cloud.hashicorp.com/). |
| 198 | +1. Navigate to Boundary, and select your cluster. |
| 199 | +1. Select **Audit logs**. |
| 200 | +1. Select **Edit streaming configuration** under the **Manage** menu. |
| 201 | +  |
| 202 | + |
| 203 | + You can: |
| 204 | + - Select a new provider |
| 205 | + - Enter new parameters for the provider |
| 206 | + - Test the connection by selecting **Test connection** |
| 207 | + |
| 208 | +1. Click **Save**. |
| 209 | + |
| 210 | +## Retention |
| 211 | + |
| 212 | +HCP Boundary stores the audit logs for a minimum of one year within the platform. HCP began archiving audit logs in October of 2022. The logs are available after the deletion of the cluster that created them. Please submit a request to the [HashiCorp Help Center](https://support.hashicorp.com/hc/en-us/requests/new) if you need access to logs from deleted clusters or have further questions. |
0 commit comments