https://github.com/mashiike/awstee
awstee is a tee command-like tool with AWS as the output destination.
https://github.com/mashiike/awstee
aws golang tee
Last synced: 3 months ago
JSON representation
awstee is a tee command-like tool with AWS as the output destination.
- Host: GitHub
- URL: https://github.com/mashiike/awstee
- Owner: mashiike
- License: mit
- Created: 2022-06-02T03:28:48.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-06-19T21:01:35.000Z (almost 2 years ago)
- Last Synced: 2024-06-21T09:13:40.940Z (11 months ago)
- Topics: aws, golang, tee
- Language: Go
- Homepage:
- Size: 89.8 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# awstee
[](https://godoc.org/github.com/mashiike/awstee)


[](https://github.com/mashiike/awstee/blob/master/LICENSE)`awstee` is a tee command-like tool with AWS as the output destination.
The `awstee` command reads from standard input and writes to standard output and AWS S3 and CloudWatch Logs.
awstee is the util tool for one time script for mission critical (especially for preventing rerunning it).## Usage
Basically, it can be used as follows
```shell
$ your_command | awstee -s3-url-prefix s3://awstee-example-com/logs/ -log-group-name /awstee/logs hoge.log
2022/06/03 17:28:48 [info] s3 destination: s3://awstee-example-com/logs//hoge.log
2022/06/03 17:28:49 [info] cloudwatch logs destination: LogGroup=/awstee/test, LogStream=hoge
...
```with default config `~/.config/awstee/default.yaml` or `~/.config/awstee/default.yml`.
```yaml
aws_region: "ap-northeast-1"s3:
url_prefix: "s3://awstee-example-com/logs/" # Required if used. If blank, output setting is turned off
allow_overwrite: true # Whether to allow overwriting if the object already existscloudwatch:
log_group: "/awstee/logs" # Required if used. If blank, output setting is turned off
flush_interval: "5s" # Duration of buffer flush output to cloudwatch logs
buffer_lines: 50 # If more than this number of lines are output within the flush period, it is output once to Cloudwatch logs.
create_log_group: true # Whether to create a LogGroup if it does not exist
``````shell
$ your_command | awstee hoge.log
2022/06/03 17:28:48 [info] s3 destination: s3://awstee-example-com/logs//hoge.log
2022/06/03 17:28:49 [info] cloudwatch logs destination: LogGroup=/awstee/test, LogStream=hoge
...
```### Install
#### Homebrew (macOS and Linux)```console
$ brew install mashiike/tap/awstee
```
#### Binary packages[Releases](https://github.com/mashiike/awstee/releases)
### Options
```shell
$ awstee -h
awstee is a tee command-like tool with AWS as the output destination
version: v0.3.0
-aws-region string
aws region
-buffer-lines int
cloudwatch logs output buffered lines (default 50)
-config string
config file path
-create-log-group
cloudwatch logs log group if not exists, create target log group
-flush-interval string
cloudwatch logs output flush interval duration (default "5s")
-i ignore interrupt signal
-log-group-name string
destination cloudwatch logs log group name
-log-level string
awstee log level (default "info")
-s3-allow-overwrite
allow overwriting if the s3 object already exists?
-s3-firstly-put-empty-object
put object from first for authority checks, etc.
-s3-url-prefix string
destination s3 url prefix
-x exit if an error occurs during initialization
```## IAM Role Policy
Permissions that `awstee` may have access to are as follows
```json
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "S3Access",
"Effect": "Allow",
"Action": [
"s3:PutObject",
"s3:GetObject",
"s3:AbortMultipartUpload",
"s3:ListBucket"
],
"Resource": "*"
},
{
"Sid": "CloudwatchLogsAccess",
"Effect": "Allow",
"Action": [
"logs:CreateLogStream",
"logs:DescribeLogStreams",
"logs:CreateLogGroup",
"logs:PutLogEvents"
],
"Resource": "*"
}
]
}
```Note: `logs:CreateLogGroup` privilege is used only when the `-create-log-group` option is enabled.
## LICENSE
MIT License
Copyright (c) 2022 IKEDA Masashi