예: SQS, CloudWatch 및 SNS - AWS Elastic Beanstalk

기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.

예: SQS, CloudWatch 및 SNS

이 예제에서는 환경에 Amazon SQS 대기열과 대기열 깊이에 대한 경보를 추가합니다. 이 예제에서 보이는 속성은 이러한 각 리소스에 대해 설정해야 하는 최소 필수 속성입니다. SQS, SNS, CloudWatch에서 예제를 다운로드할 수 있습니다.

참고

이 예에서는 요금이 부과될 수 있는 AWS 리소스를 생성합니다. AWS 요금에 대한 자세한 내용은 https://aws.amazon.com/pricing/ 단원을 참조하세요. 일부 서비스는 AWS 프리 티어의 일부분입니다. 신규 고객은 무료로 이 서비스를 시험 사용할 수 있습니다. 자세한 내용은 https://aws.amazon.com/free/를 참조하십시오.

이 예를 활용하려면 다음과 같이 하세요.

  1. 소스 번들의 최상위 디렉터리에 .ebextensions 디렉터리를 생성합니다.

  2. 확장자 .config로 구성 파일 두 개를 생성하고 .ebextensions 디렉터리로 가져옵니다. 구성 파일 하나는 리소스를 정의하고 다른 하나는 옵션을 정의합니다.

  3. Elastic Beanstalk에 애플리케이션을 배포합니다.

    YAML은 일정한 들여쓰기를 사용합니다. 예제 구성 파일의 콘텐츠를 바꿀 때 들여쓰기 레벨을 일치시키고, 텍스트 편집기가 탭 문자 대신 공백을 사용해 들여쓰기를 하도록 합니다.

리소스를 정의하는 구성 파일(예: sqs.config)을 생성합니다. 이 예제에서는 SQS 대기열을 만들고 VisbilityTimeout 리소스의 MySQSQueue 속성을 정의합니다. 그런 다음 SNS Topic을 만들고 경보가 울리면 이메일을 someone@example.com으로 보내도록 지정합니다. 마지막으로 대기열이 메시지 10개 이상으로 증가하면 CloudWatch 경보를 생성합니다. Dimensions 속성에서 차원 측정을 나타내는 차원 이름과 값을 지정합니다. Fn::GetAtt를 사용하여 QueueName에서 MySQSQueue의 값을 반환합니다.

#This sample requires you to create a separate configuration file to define the custom options for the SNS topic and SQS queue. Resources: MySQSQueue: Type: AWS::SQS::Queue Properties: VisibilityTimeout: Fn::GetOptionSetting: OptionName: VisibilityTimeout DefaultValue: 30 AlarmTopic: Type: AWS::SNS::Topic Properties: Subscription: - Endpoint: Fn::GetOptionSetting: OptionName: AlarmEmail DefaultValue: "nobody@amazon.com" Protocol: email QueueDepthAlarm: Type: AWS::CloudWatch::Alarm Properties: AlarmDescription: "Alarm if queue depth grows beyond 10 messages" Namespace: "AWS/SQS" MetricName: ApproximateNumberOfMessagesVisible Dimensions: - Name: QueueName Value : { "Fn::GetAtt" : [ "MySQSQueue", "QueueName"] } Statistic: Sum Period: 300 EvaluationPeriods: 1 Threshold: 10 ComparisonOperator: GreaterThanThreshold AlarmActions: - Ref: AlarmTopic InsufficientDataActions: - Ref: AlarmTopic Outputs : QueueURL: Description : "URL of newly created SQS Queue" Value : { Ref : "MySQSQueue" } QueueARN : Description : "ARN of newly created SQS Queue" Value : { "Fn::GetAtt" : [ "MySQSQueue", "Arn"]} QueueName : Description : "Name newly created SQS Queue" Value : { "Fn::GetAtt" : [ "MySQSQueue", "QueueName"]}

이 구성 파일 예제에서 사용된 리소스에 대한 자세한 내용은 다음 참조를 참조하십시오.

options.config라는 별개의 구성 파일을 생성하고, 사용자 지정 옵션 설정을 정의합니다.

option_settings: "aws:elasticbeanstalk:customoption": VisibilityTimeout : 30 AlarmEmail : "nobody@example.com"

이러한 행은 사용할 실제 값의 이름-값 페어가 포함된 aws:elasticbeanstalk:customoption 섹션과 함께 option_settings 섹션이 포함된 구성 파일(이 예제의 options.config)의 VisibilityTimeout and Subscription Endpoint 값에서 VisibilityTimeout and Subscription Endpoint 속성의 값을 가져오라고 Elastic Beanstalk에 지시합니다. 위 예제에서 이는 30을 뜻하며 "nobody@amazon.com"이 값에 사용됩니다. Fn::GetOptionSetting에 대한 자세한 내용은 함수 단원을 참조하세요.