Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Terraform examples #17

Merged
merged 4 commits into from
Sep 4, 2024
Merged
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
48 changes: 46 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,53 @@ logs:PutLogEvents
logs:PutRetentionPolicy
```

Example Terraform [`aws_iam_role`][], [`aws_iam_role_policy`][] and [`aws_iam_policy_document`][] definitions which grant a minimal set of permissions required to push logs to CloudWatch:
#### Terraform examples

Below are [`aws_iam_role`][], [`aws_iam_role_policy`][] and [`aws_iam_policy_document`][] definitions which grant a minimal set of permissions required to push logs to CloudWatch:

[`aws_iam_role`]: https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role
[`aws_iam_role_policy`]: https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy
[`aws_iam_policy_document`]: https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document


<details><summary>Simple 🏠 </summary>

```hcl
resource "aws_iam_role" "vercel_log_drain" {
name = "vercel-log-drain"
description = "Role to be used by the vercel log drain deployment"
assume_role_policy = data.aws_iam_policy_document.vercel_log_drain_assume.json
}
data "aws_iam_policy_document" "vercel_log_drain_assume" {
# depends on how you intend to deploy/run the service
}
resource "aws_iam_role_policy" "vercel_log_drain_policy" {
name = "vercel-log-drain-policy"
role = aws_iam_role.vercel_log_drain.id
policy = data.aws_iam_policy_document.vercel_log_drain_permissions.json
}
data "aws_iam_policy_document" "vercel_log_drain_permissions" {
statement {
actions = [
"logs:DescribeLogGroups",
"logs:DescribeLogGroups",
"logs:DescribeLogStreams",
"logs:CreateLogGroup",
"logs:CreateLogStream",
"logs:PutLogEvents",
"logs:PutRetentionPolicy",
]
resources = [
"*"
]
}
}
```

</details>

<details><summary>Advanced 🏘️ </summary>

```hcl
data "aws_caller_identity" "current" {}
variable "aws_region" {
Expand Down Expand Up @@ -99,6 +140,9 @@ data "aws_iam_policy_document" "vercel_log_drain_permissions" {
}
```

</details>


### [Grafana Loki](https://grafana.com/docs/loki/latest/)

> *Available with the `loki` [feature](#cargo-features) (enabled by default).*
Expand Down Expand Up @@ -126,7 +170,7 @@ To use the loki driver, you'll need to set up:
| `--loki-basic-auth-user` | `VERCEL_LOG_DRAIN_LOKI_USER` | `""` | Loki basic auth username |
| `--loki-basic-auth-pass` | `VERCEL_LOG_DRAIN_LOKI_PASS` | `""` | Loki basic auth password |

## Setting up
## Setting up (in Vercel)

Vercel requires that you host the application over HTTP or HTTPS, and have it be accessible from the public internet.

Expand Down
Loading