- nginx access log data를 fluentd를 통하여 kinesis로 1분 단위로 전송
- kinesis stream을 lambda가 받아 json 형태로 변환하여 S3에 업로드
- 모든 것을 localstack으로 확인
$ docker build -t custom-fluentd:latest .
Dockerfile 참고
version: '3'
services:
localstack:
container_name: "localstack"
image: localstack/localstack
ports:
- "4566-4599:4566-4599"
- "${PORT_WEB_UI-4566}:${PORT_WEB_UI-8080}"
environment:
- SERVICES=${SERVICES-lambda,kinesis,s3 }
- DEBUG=${DEBUG-1 }
- DATA_DIR=${DATA_DIR- }
- PORT_WEB_UI=${PORT_WEB_UI- }
- LAMBDA_EXECUTOR=${LAMBDA_EXECUTOR-docker-reuse }
- KINESIS_ERROR_PROBABILITY=${KINESIS_ERROR_PROBABILITY- }
- DOCKER_HOST=unix:///var/run/docker.sock
volumes:
- "./localstack:/tmp/localstack"
- "/var/run/docker.sock:/var/run/docker.sock"
nginx:
container_name: nginx
image: nginx:latest
ports:
- "80:80"
volumes:
- "./nginx/conf/nginx.conf:/etc/nginx/nginx.conf"
- "./nginx/log:/var/log/nginx"
fluentd:
container_name: fluentd
image: custom-fluentd:latest
ports:
- "24224:24224"
volumes:
- "./fluentd/fluent.conf:/fluentd/etc/fluent.conf"
- "./nginx/log:/var/log/nginx"
MacOS : $ TMPDIR=/private$TMPDIR docker-compose up -d
Others : $ docker-compose up -d
http://localhost:8080/health
$ pip install awscli-local
- 적용하기 위한 명령 :
$ terraform init
$ terraform plan
$ terraform apply
- 테스트 후 destory :
$ terraform destroy
$ docker logs -f localstack