Basic


  • Resource Type :
    • Config 是 Region Level 服務,預設存取當下 Region 下 Config 支援服務的全部設定,可以指定特定服務
    • 可以存取 Global 服務的設定
  • 所有 Config 紀錄存取到 S3
  • 單一 Resource 可以看 Configuration Timeline detailed 包含
    • 和其他服務的關係
    • 改動的地方
    • CloudTail 整合 Event

Rules


  • 每一個 Rule 每個月有固定費用 ex 1 USD/Month
  • AWS 已經有提供許多常見的 Rule , 也可以客製化自己的 Rule - rule 是透過 Lambda 執行去檢查
  • Trigger Type
    • Configuration Change : 每次更動都檢查
    • Periodic: 週期性檢查
  • 檢查 Scope
    • Resource Scope : 特定 Resource 例如 EC2
    • Tags: 特定 Tag
    • All Changes
  • Compliance Status: Noncompliant or compliant
  • 單一 Resource 可以看 Compliance Timeline - 可以從 Timeline 看到 Rule 的 Status 改變 - 和其他服務的關係 - 改動的地方

SNS


  • AWS Config 有 Streaming 的功能,可以將 Event 通知到 SNS
  • 會通知的事件包含
    • Resource 的 Config 變動
    • 歷史紀錄 或 Snapshot 上傳到 S3
    • Compliance 的結果
    • Compliance Rule 開始審核
    • AWS Config 跟 S3 互動失敗,例如上傳 Snapshot

CloudWatch Event


  • 可以偵測到 Event
    • AWS API call via CloudTail
    • Config Configuration Item Change
    • Config Rules Compliance Change
    • Config Rules Re-evaluation Status
    • Config Configuration Snapshot Delivery Status
    • Config Configuration History Delivery Status

SSM


Advance Query Example


  • 可以使用 SQL Query
 1SELECT
 2    resourceId,
 3    resourceType,
 4    configuration.instanceType,
 5    configuration.placement.tenancy,
 6    configuration.imageId,
 7    availabilityZone
 8WHERE
 9    resourceType = 'AWS::EC2::Instance'
10    AND configuration.imageId = 'ami-12345'

Aggregator View


  • 可以整合多個 AWS Account 或多個 Region 下的 AWS Config 資訊
  • 需要由一個 Main Config 建立 View,其他 Config 授權給 Main Config 就算是同一個 Account 但不同 Region。
    • 例如要多個Region ,Main Config 在 JP 建立 Aggregator 並整合 US Config,在 US Config 下需要授權給 JP Config configAggregate

S3 允許 Config 權限的 Bucket Policy


 1{
 2  "Version": "2012-10-17",
 3  "Statement": [
 4    {
 5      "Sid": "AWSConfigBucketPermissionsCheck",
 6      "Effect": "Allow",
 7      "Principal": {
 8        "Service": [
 9         "config.amazonaws.com"
10        ]
11      },
12      "Action": "s3:GetBucketAcl",
13      "Resource": "arn:aws:s3:::targetBucketName"
14    },
15    {
16      "Sid": "AWSConfigBucketExistenceCheck",
17      "Effect": "Allow",
18      "Principal": {
19        "Service": [
20          "config.amazonaws.com"
21        ]
22      },
23      "Action": "s3:ListBucket",
24      "Resource": "arn:aws:s3:::targetBucketName"
25    },
26    {
27      "Sid": "AWSConfigBucketDelivery",
28      "Effect": "Allow",
29      "Principal": {
30        "Service": [
31         "config.amazonaws.com"    
32        ]
33      },
34      "Action": "s3:PutObject",
35      "Resource": "arn:aws:s3:::targetBucketName/[optional] prefix/AWSLogs/sourceAccountID-WithoutHyphens/Config/*",
36      "Condition": { 
37        "StringEquals": { 
38          "s3:x-amz-acl": "bucket-owner-full-control"
39        }
40      }
41    }
42  ]
43}