Drift Detection
Drift Detection
AWS CloudFormation cho phép bạn phát hiện sự thay đổi cấu hình về mặt tài nguyên của Stack gây ra bởi AWS Management Console, CLI, và SDKs. Drift là sự khác biệt giữa cấu hình tài nguyên dự kiến của Stack xác định bởi các CloudFormation template với cấu hình tài nguyên thực tế của nó trên CloudFormation.
Tính năng này giúp bạn quản lý các Stack tốt hơn và đảm bảo tính nhất quán trong các cấu hình tài nguyên. Để có thêm thông tin chi tiết về Drift, hãy tham khảo Blog AWS.
Trong bài thực hành lần này, chúng ta sẽ tạo một CloudFormation Stack rồi thay đổi cấu hình tài nguyên của nó sử dụng AWS Management Console.
- Truy cập vào giao diện AWS Management Console
- Tìm CloudFormation
- Chọn CloudFormation
- Trong giao diện CloudFormation
- Chọn Stack
- Chọn Create stack
- Chọn With new resources (standard)
- Trong giao diện Create stack
- Tạo một file my_cfn_stack.yml
- Sau đó sao chép và dán đoạn mã này đồng thời lưu lại:
AWSTemplateFormatVersion: "2010-09-09"
Resources:
InputQueue:
Type: "AWS::SQS::Queue"
Properties:
QueueName: "DriftLab-InputQueue"
VisibilityTimeout: 30
RedrivePolicy:
deadLetterTargetArn:
Fn::GetAtt:
- "DeadLetterQueue"
- "Arn"
maxReceiveCount: 5
DeadLetterQueue:
Type: "AWS::SQS::Queue"
Properties:
QueueName: "DriftLab-ErrorQueue"
- Chọn Template is ready
- Chọn Upload a template file
- Chọn Choose file
- Chọn my_cfn_stack.yml
- Chọn Next
- Trong giao diện Specify stack details
- Stack name, nhập
drift-lab-with-sqs
- Chọn Next
- Chọn Next
- Chọn Submit
- Trong giao diện CloudFormation
- Chọn Stack details
- Chọn stack vừa tạo
- Chọn Event xem các event khởi tạo
- Trạng thái chuyển sang CREATE_COMPLETE là khởi tạo thành công
- Trong giao diện CloudFormation
- Chọn Stack details
- Chọn stack vừa tạo
- Chọn Resources
- Xem các resource vừa tạo
- Trong giao diện CloudFormation
- Chọn stack vừa tạo
- Chọn Stack actions
- Chọn Detect drift
- Trong giao diện CloudFormation
- Chọn stack vừa tạo
- Chọn Stack info
- Xem Drift status chuyển sang IN_SYNC
- Truy cập vào giao diện AWS Management Console
- Tìm Simple Queue Service
- Chọn Simple Queue Service
- Trong giao diện Amazon SQS
- Chọn DriftLab-InputQueue
- Chọn Edit
- Trong giao diện Configuration
- Visibility timeout, nhập
50
- Delivery delay, nhập
120
- Chọn Save
- Giao diện AWS SQS edit thành công
- Trong giao diện CloudFormation
- Chọn Stack details
- Chọn drift-lab-with-sqs
- Chọn Stack info
- Chọn Stack actions
- Chọn Detect drift
- Trong giao diện CloudFormation
- Chọn Stack details
- Chọn Stack info
- Xem Drift status chuyển sang DRIFTED
- Trong giao diện CloudFormation
- Chọn Stack details
- Chọn Stack info
- Chọn Stack actions
- Chọn View drift results
- Trong giao diện Drifts
- Xem Drift status
- Xem Resource drift status,
InputQueue
chuyển Drift status sang MODIFIED