記錄 AWS CloudFormation API呼叫 AWS CloudTrail - AWS CloudFormation

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

記錄 AWS CloudFormation API呼叫 AWS CloudTrail

AWS CloudFormation 與 (提供中的使用者 AWS CloudTrail、角色或服務所採取的動作記錄) 的 AWS 服務整合 CloudFormation。 CloudTrail 會擷取 CloudFormation as 事件的所有API呼叫,包括來自 CloudFormation 主控台的呼叫,以及從 CloudFormation APIs. 如果您建立追蹤,您可以啟用持續交付 CloudTrail 事件到 Amazon S3 儲存貯體,包括 CloudFormation. 如果您未設定追蹤,您仍然可以在 [事件歷程記錄] 中檢視 CloudTrail 主控台中最近的事件。使用收集的資訊 CloudTrail,您可以判斷提出的要求 CloudFormation、提出要求的 IP 位址、提出要求的人員、提出要求的時間,以及其他詳細資訊。

若要進一步了解 CloudTrail,請參閱使AWS CloudTrail 用者指南

CloudFormation 中的資訊 CloudTrail

CloudTrail 在您創建 AWS 帳戶時,您的帳戶已啟用。當活動發生在中時 CloudFormation,該活動會與事件歷史記錄中的其他 AWS 服務 CloudTrail 事件一起記錄在事件中。您可以檢視、搜尋和下載 AWS 帳戶的最新事件。如需詳細資訊,請參閱使用 CloudTrail 事件歷程記錄檢視事件

如需 AWS 帳戶中持續記錄事件 (包括的事件) CloudFormation,請建立追蹤。追蹤可 CloudTrail 將日誌檔交付到 Amazon S3 儲存貯體。根據預設,當您在主控台建立線索時,線索會套用到所有 區域。追蹤記錄來自 AWS 分區中所有區域的事件,並將日誌檔傳送到您指定的 Amazon S3 儲存貯體。此外,您還可以設定其他 AWS 服務,以進一步分析 CloudTrail 記錄中收集的事件資料並採取行動。如需詳細資訊,請參閱:

所有 CloudFormation 動作均由記錄, CloudTrail 並將其記錄在「AWS CloudFormation API參考」中。例如,呼叫CreateStackDeleteStack、和ListStacks區段會在 CloudTrail 記錄檔中產生項目。

每一筆事件或日誌專案都會包含產生請求者的資訊。身分資訊可協助您判斷下列事項:

  • 要求是使用根憑證還是IAM使用者認證提出。

  • 提出該請求時,是否使用了特定角色或聯合身分使用者的暫時安全憑證。

  • 請求是否由其他 AWS 服務提出。

如需詳細資訊,請參閱CloudTrail userIdentity元素

瞭解 CloudFormation 記錄檔項目

追蹤是一種組態,可讓事件以日誌檔的形式傳遞到您指定的 Amazon S3 儲存貯體。 CloudTrail 記錄檔包含一或多個記錄項目。事件代表來自任何來源的單一請求,包括有關請求的操作,操作的日期和時間,請求參數等信息。 CloudTrail 日誌文件不是公共API調用的有序堆棧跟踪,因此它們不會以任何特定順序顯示。

下列範例顯示示範CreateStack作業的 CloudTrail 記錄項目。該操作是由一個名為愛麗絲的IAM用戶進行的。

注意

僅記錄輸入參數索引鍵名稱。不記錄參數值。

{ "eventVersion": "1.01", "userIdentity": { "type": "IAMUser", "principalId": "AIDAABCDEFGHIJKLNMOPQ", "arn": "arn:aws:iam::012345678910:user/Alice", "accountId": "012345678910", "accessKeyId": "AKIDEXAMPLE", "userName": "Alice" }, "eventTime": "2014-03-24T21:02:43Z", "eventSource": "cloudformation.amazonaws.com", "eventName": "CreateStack", "awsRegion": "us-east-1", "sourceIPAddress": "127.0.0.1", "userAgent": "aws-cli/1.2.11 Python/2.7.4 Linux/2.6.18-164.el5", "requestParameters": { "templateURL": "templateURL", "tags": [ { "key": "test", "value": "tag" } ], "stackName": "my-test-stack", "disableRollback": true, "parameters": [ { "parameterKey": "password" }, { "parameterKey": "securitygroup" } ] }, "responseElements": { "stackId": "arn:aws:cloudformation:us-east-1:012345678910:stack/my-test-stack/a38e6a60-b397-11e3-b0fc-08002755629e" }, "requestID": "9f960720-b397-11e3-bb75-a5b75389b02d", "eventID": "9bf6cfb8-83e1-4589-9a70-b971e727099b" }

以下範例顯示 Alice 在 my-test-stack 堆疊上呼叫了 UpdateStack 操作:

{ "eventVersion": "1.01", "userIdentity": { "type": "IAMUser", "principalId": "AIDAABCDEFGHIJKLNMOPQ", "arn": "arn:aws:iam::012345678910:user/Alice", "accountId": "012345678910", "accessKeyId": "AKIDEXAMPLE", "userName": "Alice" }, "eventTime": "2014-03-24T21:04:29Z", "eventSource": "cloudformation.amazonaws.com", "eventName": "UpdateStack", "awsRegion": "us-east-1", "sourceIPAddress": "127.0.0.1", "userAgent": "aws-cli/1.2.11 Python/2.7.4 Linux/2.6.18-164.el5", "requestParameters": { "templateURL": "templateURL", "parameters": [ { "parameterKey": "password" }, { "parameterKey": "securitygroup" } ], "stackName": "my-test-stack" }, "responseElements": { "stackId": "arn:aws:cloudformation:us-east-1:012345678910:stack/my-test-stack/a38e6a60-b397-11e3-b0fc-08002755629e" }, "requestID": "def0bf5a-b397-11e3-bb75-a5b75389b02d", "eventID": "637707ce-e4a3-4af1-8edc-16e37e851b17" }

以下範例顯示 Alice 呼叫了 ListStacks 操作。

{ "eventVersion": "1.01", "userIdentity": { "type": "IAMUser", "principalId": "AIDAABCDEFGHIJKLNMOPQ", "arn": "arn:aws:iam::012345678910:user/Alice", "accountId": "012345678910", "accessKeyId": "AKIDEXAMPLE", "userName": "Alice" }, "eventTime": "2014-03-24T21:03:16Z", "eventSource": "cloudformation.amazonaws.com", "eventName": "ListStacks", "awsRegion": "us-east-1", "sourceIPAddress": "127.0.0.1", "userAgent": "aws-cli/1.2.11 Python/2.7.4 Linux/2.6.18-164.el5", "requestParameters": null, "responseElements": null, "requestID": "b7d351d7-b397-11e3-bb75-a5b75389b02d", "eventID": "918206d0-7281-4629-b778-b91eb0d83ce5" }

以下範例顯示 Alice 在 my-test-stack 堆疊上呼叫了 DescribeStacks 操作。

{ "eventVersion": "1.01", "userIdentity": { "type": "IAMUser", "principalId": "AIDAABCDEFGHIJKLNMOPQ", "arn": "arn:aws:iam::012345678910:user/Alice", "accountId": "012345678910", "accessKeyId": "AKIDEXAMPLE", "userName": "Alice" }, "eventTime": "2014-03-24T21:06:15Z", "eventSource": "cloudformation.amazonaws.com", "eventName": "DescribeStacks", "awsRegion": "us-east-1", "sourceIPAddress": "127.0.0.1", "userAgent": "aws-cli/1.2.11 Python/2.7.4 Linux/2.6.18-164.el5", "requestParameters": { "stackName": "my-test-stack" }, "responseElements": null, "requestID": "224f2586-b398-11e3-bb75-a5b75389b02d", "eventID": "9e5b2fc9-1ba8-409b-9c13-587c2ea940e2" }

以下範例顯示 Alice 在 my-test-stack 堆疊上呼叫了 DeleteStack 操作。

{ "eventVersion": "1.01", "userIdentity": { "type": "IAMUser", "principalId": "AIDAABCDEFGHIJKLNMOPQ", "arn": "arn:aws:iam::012345678910:user/Alice", "accountId": "012345678910", "accessKeyId": "AKIDEXAMPLE", "userName": "Alice" }, "eventTime": "2014-03-24T21:07:15Z", "eventSource": "cloudformation.amazonaws.com", "eventName": "DeleteStack", "awsRegion": "us-east-1", "sourceIPAddress": "127.0.0.1", "userAgent": "aws-cli/1.2.11 Python/2.7.4 Linux/2.6.18-164.el5", "requestParameters": { "stackName": "my-test-stack" }, "responseElements": null, "requestID": "42dae739-b398-11e3-bb75-a5b75389b02d", "eventID": "4965eb38-5705-4942-bb7f-20ebe79aa9aa" }