내 AWS 루트 사용자 계정이 사용되었음을 알리는 EventBridge 이벤트 규칙을 생성하려면 어떻게 해야 하나요?

3분 분량
0

누군가 내 AWS 루트 사용자 계정을 사용할 때 알림을 받고 싶습니다.

해결 방법

AWS CloudFormation 스택을 실행하여 Amazon Simple Notification Service(SNS) 주제를 생성합니다. 그런 다음 AWS Management Console에서 userIdentity 루트 로그인을 모니터링하는 Amazon EventBridge 이벤트 규칙을 생성합니다.

중요: 시작하기 전에 AWS CloudTrail Management 읽기 및 쓰기 이벤트를 모두 또는 쓰기 전용으로 설정했는지 확인하세요. 이렇게 하면 EventBridge 이벤트가 로그인 이벤트 알림을 시작할 수 있습니다. 자세한 내용은 읽기 및 쓰기 이벤트를 참조하세요.

  1. 이 YAML 템플릿을 즐겨 사용하는 편집기 도구에 복사하여 붙여넣은 다음 저장합니다.

    # Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
    # Permission is hereby granted, free of charge, to any person obtaining a copy of this
    # software and associated documentation files (the "Software"), to deal in the Software
    # without restriction, including without limitation the rights to use, copy, modify,
    # merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
    # permit persons to whom the Software is furnished to do so.
    #
    # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
    # INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
    # PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
    # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
    # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
    # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
    
    AWSTemplateFormatVersion: '2010-09-09'
    Description: ROOT-AWS-Console-Sign-In-via-CloudTrail
    Metadata:
      AWS::CloudFormation::Interface:
        ParameterGroups:
        - Label:
            default: Amazon SNS parameters
          Parameters:
          - Email Address
    Parameters:
      EmailAddress:
        Type: String
        ConstraintDescription: Email address required.
        Description: Enter an email address you want to subscribe to the Amazon SNS topic
          that will send notifications if your account's AWS root user logs in.
    Resources:
      RootActivitySNSTopic:
        Type: AWS::SNS::Topic
        Properties:
          DisplayName: ROOT-AWS-Console-Sign-In-via-CloudTrail
          Subscription:
          - Endpoint:
              Ref: EmailAddress
            Protocol: email
          TopicName: ROOT-AWS-Console-Sign-In-via-CloudTrail
      EventsRule:
        Type: AWS::Events::Rule
        Properties:
          Description: Events rule for monitoring root AWS Console Sign In activity
          EventPattern:
            detail-type:
            - AWS Console Sign In via CloudTrail
            detail:
              userIdentity:
                type:
                - Root
          Name:
            Fn::Sub: "${AWS::StackName}-RootActivityRule"
          State: ENABLED
          Targets:
          - Arn:
              Ref: RootActivitySNSTopic
            Id: RootActivitySNSTopic
        DependsOn:
        - RootActivitySNSTopic
      RootPolicyDocument:
        Type: AWS::SNS::TopicPolicy
        Properties:
          PolicyDocument:
            Id: RootPolicyDocument
            Version: '2012-10-17'
            Statement:
            - Sid: RootPolicyDocument
              Effect: Allow
              Principal:
                Service: events.amazonaws.com
              Action: sns:Publish
              Resource:
              - Ref: RootActivitySNSTopic
          Topics:
          - Ref: RootActivitySNSTopic
    Outputs:
      EventsRule:
        Value:
          Ref: EventsRule
        Export:
          Name:
            Fn::Sub: "${AWS::StackName}-RootAPIMonitorEventsRule"
        Description: Event Rule ID.
  2. 미국 동부(버지니아 북부) 리전에서 CloudFormation 콘솔을 연 다음 스택 생성을 선택합니다.

    참고: 미국 동부(버지니아 북부) 리전에서 CloudFormation 스택을 생성해야 합니다.

  3. 스택 생성을 선택한 다음 **새 리소스 사용(표준)**을 선택합니다.

  4. 템플릿 파일 업로드, 다음을 선택한 다음 파일 선택을 선택합니다.

  5. 1단계에서 저장한 템플릿을 선택한 다음 다음을 선택합니다.

  6. 스택 이름에 의미 있는 이름(예: Root-AWS-Console-Sign-In-CloudTrail)을 입력합니다.

  7. 이메일주소에 이메일 주소를 입력한 다음 다음을 선택합니다.
    참고: AWS가 이 이메일 주소로 확인 이메일을 보냅니다.

  8. 옵션에서 다음을 선택한 다음 생성을 선택합니다.

  9. 이메일 받은 편지함에서 AWS 확인 이메일을 확인한 다음 구독 확인에서 SNS 구독 요청 확인을 선택합니다. **구독이 확인되었습니다!**라는 메시지가 표시됩니다.

  10. 알림을 테스트하려면 AWS 관리 콘솔에서 로그아웃합니다. 그런 다음 AWS 루트 사용자 계정으로 AWS 관리 콘솔에 로그인합니다.

  11. 이메일 받은 편지함에서 AWS 알림 메시지를 확인합니다. CloudTrail 레코드를 확인합니다. userIdentity, sourceIPAddressMFAUsed에 로그인 이벤트에 대한 세부 정보가 포함되어 있는지 확인합니다.

알림을 받지 않으려면 2단계에서 생성한 CloudFormation 스택을 삭제합니다.

관련 정보

AWS CloudFormation 콘솔에서 스택 생성

AWS 계정의 루트 액세스 키가 사용될 때 알림을 받는 방법

AWS 계정 루트 사용자 활동 모니터링 및 알림

AWS::CloudWatch::Alarm

AWS 공식
AWS 공식업데이트됨 7달 전