라벨이 aws인 게시물 표시

AWS Elasticache IP 변경으로 인한 Timeout 해결책

elasticache node 스펙 변경으로 node 교체가 되면서 이들의 private ip가 바뀌는 상황이 있었다. 다른 Spring boot 서버들이 lettuce에 elasticache configuration endpoint로 설정하여 사용중이였기에 자동 ip 전환이 되길 기대하고 있었으나 지속된 redis timeout... lettuce에서 한번 redis ip가 설정되면 재부팅 전까지 값이 변경 되지 않는다는 걸 알게 되었다. elasticache는 한번씩 의도하지 않은 ip 변경이 있을때가 있어 luttuce에서 ip refresh를 할 수 있도록 해결책이 필요하게 되었다. 이런 저런걸 알아봤는데 우선 해결책부터 https://github.com/lettuce-io/lettuce-core/issues/822 요약) enablePeriodicRefresh=true 혹은 원하는 refresh interval (true로 줄 경우 60s) elasticasche를 사용할 경우  dynamicRefreshSources disable 아래 코드 참조 final var topologyRefreshOptions = ClusterTopologyRefreshOptions . builder () . dynamicRefreshSources ( false ) . enablePeriodicRefresh ( Duration . ofSeconds ( 30 )) . build (); final var clientOptions = ClusterClientOptions . builder () ...

Sliding Window vs Tumbling Window

이미지
 아래 그림으로 설명이 가능할 듯 하다. Sliding Window length = 10s, interval = 5s 10초 크기의 윈도우가 5초씩 미끄러져 간다. Tumbling Window length = 5s 0 ~ 5초, 5초후에는 5초 ~ 10초, 10초 후에는 10초 ~ 15초로 구간 분리.  출처 :  https://docs.cloudera.com/HDPDocuments/HDP3/HDP-3.0.1/developing-storm-applications/content/understanding_sliding_and_tumbling_windows.html

[Spring Boot] Redis Key Expired Event

이미지
Redis에서 TTL 설정 된 key에 대해 expire 될 때 이벤트를 받을 필요가 생겨 리서치를 진행 했다.  Reids 버전 언제부터인지는 모르겠지만 아래 redis.conf를 보니 key expired 이벤트를 받을 수 있도록 되어 있었다. 출처 :  https://github.com/redis/redis/blob/unstable/redis.conf expired 이벤트는 disabled가 default라 아래처럼 redis node에서 따로 설정을 해 줘야 한다. $> config set notify-keyspace-events Ex note) 맨 뒤 Ex는 위 redis.conf에 있는 E : Keyevent events / x : Expired events 두 개를 사용하겠다는 의미. Redis 서버에 셋팅 후 Spring Boot에서 이벤트를 받아 보기 위해 코드를 작성했는데 두 가지가 가능 했다. 첫째로 Redis의 KeyExpirationEventMessageListener 와 Spring Boot EventListener 를 활용하는 방법과 두번째는 그냥 Redis의 MessageListener를 구현하는 방법이다. 1) Spring EventListner RedisKeyExpiredEvent를 받는 리스너를 만들어 준다. @Component public class MyRedisKyeExpiredSpringListener { @EventListener public void expiredKey ( RedisKeyExpiredEvent event ) { System . out . println ( "=========== spring listener ===========" ); System . out . println ( "event : " + event ); System . out . println ( "e...

AWS Identity Federation

이미지
  Identity Federation 은 AWS 유저가 아니면서 일시적으로 접속권한을 받아서 AWS에 접속하는 서비스를 말한다. 위 그림과 같이 AWS로부터 신임을 받는 3rd party에 로그인을 하고 그 서비스가 credential을 증명해주고 해당 account을 가지고 aws에 접속을 하게 된다. 이 3rd는 여러가지가 해당될 수 있는데, 그중에 하나가 Microsoft Active Directory, LDAP, Single Sign On, Open ID, Congnito 등이 될 수 있다. 이 Federation을 통해서 IAM 을 통해서 유저를 따로 만들필요없이 다른 3rd party app에서 계정들을 가져와서 유저로 사용할 수 있다. Active Directory, SAML 과 통합되어 AWS 의 접속할 수 있는 유저를 싱크하게 된다. AWS console이나 CLI 로 로그인 모두 가능하다. Custom Identity Broker Application 이것은 SAML 등과 같이 Integration 이 될 수 있는 앱이 하나도 없을 경우에만 사용되며, 아래와 같이 Identity broker가 corporate identity store에서 인증을 하고 STS에서 임시적인 접근권한을 가지고 AWS 에 접속하는 형태를 말한다. Identity broker에 전적으로 의지를 하기 때문에 이는 반드시 AWS IAM 정책과 일치하는 정책을 가져야 한다. AWS Cognito 이를 사용하는 이유는 Client side에서 AWS resource를 직접적으로 접근하기 위해서이다. 이를 위해서는 Federated identity provider로 로그인을 하고 임시적인 AWS credential을 받아온다. 이러한 credential은 이미 정의된 IAM 정책에 따라서 받아오게 된다. 예를 들어 페이스북 계정을 통해서 S3에 직접적으로 접근하는 것과 같다. 출처) https://m.blog.naver.com/PostView.naver?i...

AWS CLI Configure

 aws cli를 사용하기 위한 초기 설정(Mac 사용자) 1. aws cli download $> brew install awscli 2. aws session manager plugin 설치(SSM 필요한 사람만) $> brew tab dkanejs/aws-session-manager-plugin $> brew install aws-session-manager-plugin 3. aws key 설정 $> aws configure AWS Access Key ID [None] : {액세스 키 받은거 입력} AWS Secret Access Key [None] : {시트릿 키 받은거 입력} Default region name [None] : ap-northeast-2    <-서울 Default output format [None] : json 4. 확인 $> aws configure list

AWS EC2 Public DNS 할당이 되지 않을때

EC2에 public 접속을 하기 위해 Elastic IP를 할당 했는데 Public DNS가 할당이 안될때 해결법. 원인: VPC의 DNS hostnames 기능이 disabled로 되어 있어 그렇다. 해결: enabled로 바꿔 주면 된다. 1. Services 메뉴에서 VPC 선택 2. 왼쪽에서 Your VOCs 선택 3. 우측 VPC 목록에서 사용중인 VPC 선택.(or 체크후 상단 Actions 클릭) 4. 팝업 메뉴에서 Edit DNS Hostnames 선택 후 enabled로 변경 cf) 위 이후 적용이 잘 안될땐 instance restart 해보시길~

AWS Route 53 Cloudfront S3 연동

objective: s3 bucket의 static page를 xxx.abc.com domain으로 hosting 하기 1. s3 bucket static website hosting 하기 2. s3와 cloudfront 연결 3. 아래 링크 참고하여 route 53과 cloudfront 연결 http://pyrasis.com/book/TheArtOfAmazonWebServices/Chapter17/04

AWS Route53 도메인과 API Gateway 연결하기

under construction...

AWS Bastion Port Forwarding Shell Script

Example 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 function aws_forwarding_by_bastion { echo "Remove localhost..." ssh-keygen -R localhost echo "connecting to bastion: ${AWS_BASTION_ENDPOINT}" echo "forwarding local SSH port(22) to Test EC2 - ${AWS_TEST_EC2_ENDPOINT}:22." echo "forwarding local Kibana port(9200) to AES:443" echo "forwarding local DB port(3306) to Test DB:3306" echo "" sudo ssh -i ~/.ssh/ { pem file } ec2-user@ ${ AWS_BASTION_ENDPOINT } \ -L 22: ${ AWS_TEST_EC2_ENDPOINT } :22 \ -L 9200: ${ AWS_ES_ENDPOINT } :443 \ -L 3306: ${ AWS_TEST_RDS_ENDPOIN } :3306 }

AWS Import existing AWS infrastructure into terraform

출처:  https://blog.ndk.name/import-existing-aws-infrastructure-into-terraform/ Amazon Web Services (AWS) Amazon Web Services (AWS)  is an on-demand cloud computing platform that offers us a lot of helpful and reliable services. AWS has friendly web interface which user can easily interact with to create virtual machines, networking stuffs, security policies, etc. However, in order to manage all the AWS configuration and keep track of the changes, it is neccessary to work with 3rd party tool like Terraform. Terraform Terraform  is a tool for building, changing, and versioning infrastructure safely and efficiently. Terraform can manage existing and popular service providers as well as custom in-house solutions. You can see here the list of  supported providers . If you are building your IT infrastructure on AWS from scratch with Terraform, it is great, you don’t need to follow this article. But if you already had an existing aws infrastructure and now want t...