aws 배포 / application / aws 에서 배포 할 때 deploy / 방법 / 쉽게
AWS Elastic Beanstalk 환경 설정
Elastic Beanstalk 에서 하는 일은 대략 아래와 같다. environment 를 생성하고, 삭제할 때 벌어지는 자세한 일은 아래 log 를 참고하자. 물론 환경설정에 따라 달라질 수 있다.
- CloudWatch log group 생성
- taget group 생성
- security group 생성
- auto scaling configuration 생성
- auto scaling group 생성
- ec2 실행
- auto scaling group policy 생성
- CloudWatch alarm 생성
- load balancer 생성
- Load Balance listenr 생성
Create a new environment
logs
2:08am
Successfully launched environment: my-test-environment
2:08am
Application available at my-test-environment.ap-northeast-2.elasticbeanstalk.com.
2:08am
Environment health has transitioned from Pending to Ok. Initialization completed 7 seconds ago and took 5 minutes.
2:05am
Created Load Balancer listener named:
arn:aws:elasticloadbalancing:ap-northeast-2:436912540370:listener/app/awseb-AWSEB-16PM1TA19MRP3/e591d45e9a5e58f8/f089ea9c2ba48e3c
2:05am
Created Load Balancer listener named:
arn:aws:elasticloadbalancing:ap-northeast-2:436912540370:listener/app/awseb-AWSEB-16PM1TA19MRP3/e591d45e9a5e58f8/505139eac2877500
2:05am
Created load balancer named:
arn:aws:elasticloadbalancing:ap-northeast-2:436912540370:loadbalancer/app/awseb-AWSEB-16PM1TA19MRP3/e591d45e9a5e58f8
2:05am
Added instances [i-0f3401a87f99315a5, i-0fd217296824591d7] to your environment.
2:04am
Created CloudWatch alarm named:
awseb-e-kwhccm4s6a-stack-AWSEBCloudwatchAlarmLow-1PLBITVTCQFA3
2:04am
Created CloudWatch alarm named:
awseb-e-kwhccm4s6a-stack-AWSEBCloudwatchAlarmHigh-19JL2GR2G3135
2:04am
Created Auto Scaling group policy named:
arn:aws:autoscaling:ap-northeast-2:436912540370:scalingPolicy:2c485fe3-3908-49ef-89b6-f1e43821c472:autoScalingGroupName/awseb-e-kwhccm4s6a-stack-AWSEBAutoScalingGroup-1OX14XPC9LRR:policyName/awseb-e-kwhccm4s6a-stack-AWSEBAutoScalingScaleDownPolicy-5YLKMBXPVII6
2:04am
Created Auto Scaling group policy named:
arn:aws:autoscaling:ap-northeast-2:436912540370:scalingPolicy:b32d3c4b-9784-4916-824e-98b05d74b921:autoScalingGroupName/awseb-e-kwhccm4s6a-stack-AWSEBAutoScalingGroup-1OX14XPC9LRR:policyName/awseb-e-kwhccm4s6a-stack-AWSEBAutoScalingScaleUpPolicy-BGMJQ8T0A2AM
2:04am
Waiting for EC2 instances to launch. This may take a few minutes.
2:04am
Created Auto Scaling group named:
awseb-e-kwhccm4s6a-stack-AWSEBAutoScalingGroup-1OX14XPC9LRR
2:04am
Environment health has transitioned to Pending. Initialization in progress (running for 34 seconds). There are no instances.
2:03am
Created Auto Scaling launch configuration named:
awseb-e-kwhccm4s6a-stack-AWSEBAutoScalingLaunchConfiguration-1GKP7RH5XKKDY
2:03am
Created security group named:
sg-042aec4ad64e7e17a
2:03am
Created security group named:
sg-0b578c19548ad6543
2:03am
Created target group named:
arn:aws:elasticloadbalancing:ap-northeast-2:436912540370:targetgroup/awseb-AWSEB-1ATVNZKAA4U/3f878cdf07e55d56
2:03am
Created Amazon CloudWatch log group named:
/aws/elasticbeanstalk/my-test-environment/var/log/eb-activity.log
2:03am
Created Amazon CloudWatch log group named:
/aws/elasticbeanstalk/my-test-environment/var/log/httpd/access_log
2:03am
Created Amazon CloudWatch log group named:
/aws/elasticbeanstalk/my-test-environment/var/log/httpd/error_log
2:03am
Using elasticbeanstalk-ap-northeast-2-436912540370 as Amazon S3 storage bucket for environment data.
2:03am
createEnvironment is starting.
terminate
Elastic Beanstalk –> Environment –> my-test-environment
logs
2020-10-25 02:15:16 UTC+0000
INFO
terminateEnvironment completed successfully.
2020-10-25 02:15:15 UTC+0000
INFO
Deleting SNS topic for environment my-test-environment.
2020-10-25 02:15:11 UTC+0000
INFO
Deleted security group named: sg-0b578c19548ad6543
2020-10-25 02:15:11 UTC+0000
INFO
Deleted security group named: sg-042aec4ad64e7e17a
2020-10-25 02:15:11 UTC+0000
INFO
Deleted Auto Scaling launch configuration named: awseb-e-kwhccm4s6a-stack-AWSEBAutoScalingLaunchConfiguration-1GKP7RH5XKKDY
2020-10-25 02:15:11 UTC+0000
INFO
Deleted target group named: arn:aws:elasticloadbalancing:ap-northeast-2:436912540370:targetgroup/awseb-AWSEB-1ATVNZKAA4U/3f878cdf07e55d56
2020-10-25 02:15:11 UTC+0000
INFO
Deleted Auto Scaling group named: awseb-e-kwhccm4s6a-stack-AWSEBAutoScalingGroup-1OX14XPC9LRR
2020-10-25 02:15:01 UTC+0000
INFO
Removed instance [i-0f3401a87f99315a5] from your environment.
2020-10-25 02:15:01 UTC+0000
INFO
Environment health has transitioned from Ok to Pending. Terminate in progress (running for 2 minutes). There are no instances. Auto Scaling group desired capacity is set to 0.
2020-10-25 02:14:01 UTC+0000
INFO
Removed instance [i-0fd217296824591d7] from your environment.
2020-10-25 02:12:53 UTC+0000
INFO
Waiting for EC2 instances to terminate. This may take a few minutes.
2020-10-25 02:12:53 UTC+0000
INFO
Deleted Auto Scaling group policy named: arn:aws:autoscaling:ap-northeast-2:436912540370:scalingPolicy:2c485fe3-3908-49ef-89b6-f1e43821c472:autoScalingGroupName/awseb-e-kwhccm4s6a-stack-AWSEBAutoScalingGroup-1OX14XPC9LRR:policyName/awseb-e-kwhccm4s6a-stack-AWSEBAutoScalingScaleDownPolicy-5YLKMBXPVII6
2020-10-25 02:12:53 UTC+0000
INFO
Deleted Auto Scaling group policy named: arn:aws:autoscaling:ap-northeast-2:436912540370:scalingPolicy:b32d3c4b-9784-4916-824e-98b05d74b921:autoScalingGroupName/awseb-e-kwhccm4s6a-stack-AWSEBAutoScalingGroup-1OX14XPC9LRR:policyName/awseb-e-kwhccm4s6a-stack-AWSEBAutoScalingScaleUpPolicy-BGMJQ8T0A2AM
2020-10-25 02:12:53 UTC+0000
INFO
Deleted load balancer named: arn:aws:elasticloadbalancing:ap-northeast-2:436912540370:loadbalancer/app/awseb-AWSEB-16PM1TA19MRP3/e591d45e9a5e58f8
2020-10-25 02:12:53 UTC+0000
INFO
Deleted CloudWatch alarm named: awseb-e-kwhccm4s6a-stack-AWSEBCloudwatchAlarmLow-1PLBITVTCQFA3
2020-10-25 02:12:53 UTC+0000
INFO
Deleted Load Balancer listener named: arn:aws:elasticloadbalancing:ap-northeast-2:436912540370:listener/app/awseb-AWSEB-16PM1TA19MRP3/e591d45e9a5e58f8/f089ea9c2ba48e3c
2020-10-25 02:12:53 UTC+0000
INFO
Deleted CloudWatch alarm named: awseb-e-kwhccm4s6a-stack-AWSEBCloudwatchAlarmHigh-19JL2GR2G3135
2020-10-25 02:12:53 UTC+0000
INFO
Deleted Load Balancer listener named: arn:aws:elasticloadbalancing:ap-northeast-2:436912540370:listener/app/awseb-AWSEB-16PM1TA19MRP3/e591d45e9a5e58f8/505139eac2877500
2020-10-25 02:12:36 UTC+0000
INFO
terminateEnvironment is starting.
worker environment
worker environment
에서 만약 여러개의 instance(EC2) 가 동작을 한다고 가정하면, 각 instance 는 각각 message 를 읽어오는 deamon 을 갖는다.(sqsd deamon) 그리고 이 deamon 들은 Amazon SQS Queue 를 바라보고 있다. 즉, 이 worker environment 에 SQS Queue 는 1개 이다.
이 deamon 이 message 를 일고 이것을 worker environment 에서 동작하는 web application 에 넘겨주게 된다. 그러면 이 web application 이 이 message 에 대한 처리를 하게 되는 것이다. deamon 은 http://localhost
로 HTTP POST request 를 보내게 된다.
web application source code 에 YAML file 을 넣어서 worker environment에서 이 주기적인 작업을 설정할 수 있다. 이 yaml file 에 schedule 과 어떤 path 를 호출할 지를 정해주게 된다.
자세한 사항은 다음 링크를 참고하자.
기존의 configuration 확인 방법
- Beanstalk(https://ap-northeast-2.console.aws.amazon.com/elasticbeanstalk/) --> Enviroment 선택 --> 왼쪽메뉴에서
Configuration
선택
Database
기본적으로 환경을 만들때 Database 를 만들지 않게 되어 있다. 실제로 aws doc 에서도 amazon rds 를 연결하는 것은 좋은 선택이 아니라고 한다. 이유는 environment 를 terminate 하면 rds 도 삭제 되기 때문이다.
- https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/AWSHowTo.RDS.html
- https://aws.amazon.com/premiumsupport/knowledge-center/decouple-rds-from-beanstalk/?nc1=h_ls
- https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/using-features.CNAMESwap.html
만약 environment 에 RDS 를 사용한 경우에 이것을 다른 environment 로 옮기려면 아래 링크를 참고하자.
- https://aws.amazon.com/premiumsupport/knowledge-center/decouple-rds-from-beanstalk/?nc1=h_ls
대략적인 이야기는 환경을 지우면, rds 도 같이 삭제된다. 그러므로 rds 에 deletion protection을 설정하고, 이것을 다른 environment 에 연결한 후 기존의 environment 를 terminate 해야 한다는 이야기이다.
Reference
ScreenShots
댓글 없음:
댓글 쓰기