본문 바로가기

AWS

(61)
CloudWatch 로그 S3로 자동 백업 AWS Architecture Amazon EventBridge에서 Cron 기반 일정으로 매일 0시에 SNS에 주제를 게시 SNS에 주제가 게시되면 구독자인 SQS로 메세지 전달 Lambda 함수는 SQS에 도착한 메시지를 트리거로 실행 Lambda 함수가 실행되면 S3로 하루치 CloudWatch 로그 전송 S3에 저장된 로그는 180일이 경과하면 S3 Glacier로 전환하여 비용 절약 1. S3 1-1. S3 생성 버킷 > 권한 > 버킷 정책 편집 CloudWatch에서 로그를 가져올 수 있도록 버킷 권한 설정 { "Version": "2012-10-17", "Statement": [ { "Sid": "AllowLogsToWriteToBucket", "Effect": "Allow", "Princi..
EKS에서 nginx-tomcat 연동하는 방법 Nginx upstream 모듈을 사용하면 된다. /etc/nginx/sites-available 디렉토리에 위치한 default 파일에 upstream 모듈 추가 upstream express-server { server :8080; } 에는 EKS에서 부여하는 IP 주소가 자동으로 매치되도록 tomcat의 서비스 이름을 넣어준다. EKS에서 서비스 생성 시 tomcat 서비스를 먼저 만들고 nginx 서비스를 만들어야한다. 아래는 코드 예시: 반드시 was-server 라는 이름의 서비스를 먼저 생성 # Cluster yaml 파일 # web은 nginx # was는 tomcat --- apiVersion: v1 kind: Service metadata: name: was-server labels: ..
[AWS Terraform]EKS 구축 01. 기본 설정 변수 파일 작성 # 99_var.tf variable "region" { type = string default = "ap-northeast-2" } variable "cidr" { type = string default = "10.0.0.0/16" } variable "rocidr" { type = string default = "0.0.0.0/0" } variable "name" { type = string default = "eks" } 프로바이더, region 등 기본 aws terraform 설정 # 01_init.tf terraform { required_providers { aws = { source = "hashicorp/aws" version = "~> 5.0" } } ..
[AWS Terraform]Wordpress EC2 인스턴스 생성 사전 작업: 프로바이더 설정, VPC, 키페어, 서브넷, 인터넷 게이트웨이, 라우트 테이블, 보안그룹, 로드발란서, RDS 생성 (퍼블릭 서브넷에 인스턴스를 올릴것이기 때문에 NAT 게이트웨이는 제외) (서브넷은 가용영역별로 애플리케이션용 퍼블릭 하나, RDS용 프라이빗 하나 생성) 생성 방법은 이전 포스팅 참조 1. Wordpress 실행 파일 작성 # wordpress.sh #! /bin/bash yum install -y httpd amazon-linux-extras enable php7.4 yum install -y php php-cli php-pdo php-fpm php-json php-mysqlnd mariadb wget https://ko.wordpress.org/wordpress-5.7.8..
[AWS Terraform 기초]20. RDS 생성 1. Terraform Docs 예시 DB Subnet Group https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/db_subnet_group Terraform Registry registry.terraform.io DB Instance https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/db_instance Terraform Registry registry.terraform.io 예시: 인수 등: 2. Terraform 코드 작성 # 19_rds.tf resource "aws_db_subnet_group" "pmh-dbsg" { na..
[AWS Terraform 기초]19. AutoScaling Group에 ALB 연결 1. Terraform Docs 예시 https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/autoscaling_attachment Terraform Registry registry.terraform.io 예시: 인수 등: 2. Terraform 코드 작성 # 18_autosgatt.tf resource "aws_autoscaling_attachment" "pmh-autosgatt" { autoscaling_group_name = aws_autoscaling_group.pmh_autosg.id lb_target_group_arn = aws_lb_target_group.pmh_albtg.arn } resource "aws_a..
[AWS Terraform 기초]18. AutoScaling Group 생성 앞서 만들었던 시작 템플릿과 AMI로 오토 스케일링 생성 1. Terraform Docs 예시 https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/autoscaling_group Terraform Registry registry.terraform.io 예시: 인수 등: 2. Terraform 코드 작성 # 17_autosg.tf resource "aws_autoscaling_group" "pmh_autosg" { name = "pmh-autosg" min_size = 1 max_size = 6 desired_capacity = 1 health_check_grace_period = 60 health_check_type = ..
[AWS Terraform 기초]17. Launch Template(시작 템플릿) 생성 Auto Scaling에 사용될 시작 템플릿 생성 1. Terraform Docs 예시 https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/launch_template Terraform Registry registry.terraform.io 예시: 인수 등: 2. Terraform 코드 작성 # 16_lantemp.tf resource "aws_launch_template" "pmh_lantemp" { name = "pmh-lantemp" block_device_mappings { device_name = "/dev/sdf" ebs { volume_size = 10 volume_type = "gp2" } } image_i..