View a markdown version of this page

管理資產 - AWS DevOps 代理程式

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

管理資產

AWS DevOps Agent 會將 Agent Space 的組態和參考資料儲存為資產、客戶管理的資源,以塑造客服人員知道的內容及其行為。Skills、AGENTS.md 檔案和附件都是資產,您可以透過資產 API 以程式設計方式建立、讀取、更新和刪除它們。

若要設定 AWS DevOps Agent 知道的內容及其行為,請在 Agent Space 中管理資產。本主題涵蓋資產模型、IAM 許可,以及每個資產類型預期的中繼資料。使用 AWS CLI、適用於 Python 的 AWS SDK (Boto3) 或 AWS CloudFormation end-to-end管理資產。如需技能本身的概念概觀,請參閱 DevOps 代理程式技能。如需您不自行建立的客服人員產生知識,請參閱 學到的技能。

何時使用資產 API

Operator Web 應用程式是編寫單一技能或以互動方式上傳 AGENTS.md 檔案的最快方法。資產 API 會以程式設計方式公開相同的操作,以便指令碼和自動化可以管理資產,而無需透過 Web 應用程式。直接呼叫資產 API 的常見原因包括:

  • 從指令碼、終端機或筆記本撰寫或更新資產,而非 Web 應用程式。

  • 將一組入門技能或 AGENTS.md 檔案大量載入新的客服人員空間。

  • 讀取資產的內容以備份或比較版本。

資產 API 中的每個操作都會透過 AWS CLI 公開為 aws devops-agent <operation> ,並透過 AWS SDKs公開為 devops-agent用戶端。

資產 API 操作

資產 API 會公開下列操作。每一列都會列出您必須授予以呼叫 操作的 IAM 動作,以及動作適用的資源。每個動作都存在於 aidevops: 命名空間中,除了 之外ListAssetTypes, 適用於表單 的 Agent Space 資源arn:aws:aidevops:<region>:<account-id>:agentspace/<agentSpaceId>。如需aidevops:許可的更廣泛背景,請參閱 DevOps Agent IAM 許可。

作業 說明 IAM 動作 資源
ListAssetTypes 列出 AWS DevOps Agent 支援的資產類型。 aidevops:ListAssetTypes *
CreateAsset 在 代理程式空間 (技能、https://AGENTS.md、附件、自訂代理程式、記憶體存放區、記憶體、測試設定檔或意見回饋) 中建立新的資產。 aidevops:CreateAsset 客服人員空間
GetAsset 擷取資產的中繼資料和版本資訊。 aidevops:GetAsset 客服人員空間
UpdateAsset 更新現有資產的中繼資料或內容。 aidevops:UpdateAsset 客服人員空間
DeleteAsset 從 代理程式空間刪除資產及其所有檔案。 aidevops:DeleteAsset 客服人員空間
ListAssets 列出 代理程式空間中的資產,並依資產類型進行選用篩選。 aidevops:ListAssets 客服人員空間
ListAssetVersions 列出資產的歷史版本。 aidevops:ListAssetVersions 客服人員空間
GetAssetContent 下載資產的完整內容做為 zip 套件。 aidevops:GetAssetContent 客服人員空間
CreateAssetFile 將新檔案新增至現有資產。 aidevops:CreateAssetFile 客服人員空間
GetAssetFile 依其路徑從資產擷取單一檔案。 aidevops:GetAssetFile 客服人員空間
UpdateAssetFile 取代資產中現有檔案的內容或中繼資料。 aidevops:UpdateAssetFile 客服人員空間
DeleteAssetFile 從資產移除單一檔案。 aidevops:DeleteAssetFile 客服人員空間
ListAssetFiles 列出資產中的檔案。 aidevops:ListAssetFiles 客服人員空間

範例 IAM 政策

下列政策授予單一代理程式空間中資產的完整管理存取權:

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "aidevops:CreateAsset", "aidevops:GetAsset", "aidevops:UpdateAsset", "aidevops:DeleteAsset", "aidevops:ListAssets", "aidevops:ListAssetVersions", "aidevops:GetAssetContent", "aidevops:CreateAssetFile", "aidevops:GetAssetFile", "aidevops:UpdateAssetFile", "aidevops:DeleteAssetFile", "aidevops:ListAssetFiles" ], "Resource": "arn:aws:aidevops:us-east-1:111122223333:agentspace/8f6187a7-0388-4926-8217-3a0fe32f757c" }, { "Effect": "Allow", "Action": "aidevops:ListAssetTypes", "Resource": "*" } ] }

下列政策授予單一代理程式空間中資產的唯讀存取權:

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "aidevops:GetAsset", "aidevops:ListAssets", "aidevops:ListAssetVersions", "aidevops:GetAssetContent", "aidevops:GetAssetFile", "aidevops:ListAssetFiles" ], "Resource": "arn:aws:aidevops:us-east-1:111122223333:agentspace/8f6187a7-0388-4926-8217-3a0fe32f757c" }, { "Effect": "Allow", "Action": "aidevops:ListAssetTypes", "Resource": "*" } ] }

資產類型

每個資產都有可識別其資源類型的assetType字串。您可以透過資產 API 建立八個資產類型:skill、agents_md、attachmentcustom_agent、、memory_store、memory、 test_profile和 feedback。以下各節說明每種類型。您也可以在執行時間呼叫 ListAssetTypes來擷取類型識別符。

每個資產都有描述資源的自由格式 metadata JSON 物件。內部的金鑰metadata使用 snake_case (例如,agent_types、skill_type)。外部的金鑰metadata,在請求內文的最上層,使用 camelCase agentSpaceId(例如,、assetType、clientToken)。必要和選用metadata金鑰取決於資產類型,如以下各節所述。

當您呼叫 UpdateAsset或 時UpdateAssetFile,服務會將 PATCH 語意套用至 metadata:您包含的金鑰會遭到取代,而您省略的金鑰會保留其儲存的值。您無法在資產建立assetType後變更資產的 。

技能

skill 資產套件指示和參考資料,代理程式會在相關時載入。簡單技能是單一SKILL.md檔案;複雜技能是包含SKILL.md檔案加上選用 references/ 或 assets/ 目錄的 zip 套件。

必要metadata屬性:

  • name (字串) – 技能的唯一識別符。僅限小寫字母、數字和連字號,1-64 個字元。不得以連字號開頭或結尾。僅適用於簡單技能。對於 zip 上傳,系統會忽略name從SKILL.md前端讀取的服務,並忽略此處提供的任何值。

  • description (string) – 客服人員何時應使用技能的 1-1024 字元說明。僅適用於簡單技能。對於 zip 上傳,系統會description忽略從SKILL.md前端讀取的服務,並忽略此處提供的任何值。

  • agent_types (字串陣列) – 此技能適用的一個或多個代理程式類型。使用 ["GENERIC"] 讓所有客服人員類型都能使用技能。其他值包括 CHAT、INCIDENT_TRIAGE、INCIDENT_RCA、INCIDENT_MITIGATION、INCIDENT_UI、RELEASE_READINESS_REVIEW、 PREVENTION和 RELEASE_TESTING。該GENERIC值不能與其他值結合。

選用metadata屬性:

  • skill_type (字串) – 預設為 USER。資產 API 僅允許客戶建立的技能,因此唯一接受的值為 USER。服務會拒絕skill_type設定為 的請求LEARNED,該請求會保留給客服人員本身產生的技能。

  • 狀態 (字串) – 技能的啟用狀態。接受的值為 ACTIVE和 INACTIVE(僅限大寫)。預設為 ACTIVE。非作用中技能會保留在客服人員空間中,但客服人員在調查或聊天期間不會載入。使用 UpdateAsset搭配 metadata.status 來停用或重新啟用技能,而不將其刪除。技能是唯一支援啟用的資產類型;每隔一種資產類型都會忽略 status 欄位。請參閱啟用和停用技能以取得工作範例。

  • enable_tools (字串陣列) – 代理程式載入此技能時可呼叫的工具識別符清單。

範例metadata:

{ "name": "rds-performance-investigation", "description": "Investigation procedures for RDS performance issues including connection exhaustion, slow queries, replication lag, and storage capacity. Use this skill when investigating database latency, connection errors, or read/write performance degradation.", "agent_types": ["GENERIC"] }

限制:Zip 上傳不得超過 6 MB。Agent Space 最多可包含 200 個使用者建立的技能。

agent_md

agents_md 資產是 Markdown 檔案,其中包含特定代理程式類型的常設代理程式指示。代理程式會在每個任務開始時載入相符的 AGENTS.md。如需客服人員指示的詳細資訊,請參閱 客服人員指示。

必要metadata屬性:

  • agent_type (字串) – 適用於 AGENTS.md 檔案的代理程式類型。有效值為 GENERIC、CHAT、INCIDENT_TRIAGE、INCIDENT_RCA、INCIDENT_MITIGATION、INCIDENT_UI、PREVENTION、 RELEASE_READINESS_REVIEW和 RELEASE_TESTING。

範例metadata:

{ "agent_type": "INCIDENT_TRIAGE" }

限制:每個客服人員空間每個 最多可包含一個 AGENTS.mdagent_type。檔案內容必須是 Markdown (text/markdown),且不得超過 25 KB。

attachment

attachment 資產會存放代理程式可在調查期間參考的二進位或文字檔案,例如架構圖表、 Runbook PDF 或範例日誌檔案。

必要metadata屬性:

  • filename (字串) – 原始檔案名稱,包括基本名稱和任何副檔名 (例如 topology.png)。

  • extension (字串) – 沒有前置點的副檔名 png(例如,、pdf、csv)。

  • size (number) – 以位元組為單位的檔案大小。

範例metadata:

{ "filename": "topology.png", "extension": "png", "size": 184320 }

限制:代理程式空間中所有附件的總大小不能超過 10 GB。

custom_agent

custom_agent 資產使用一組精選的工具、技能和連接的記憶體存放區來定義專門的代理程式組態。使用自訂代理程式,將代理程式範圍限定在特定工作流程或一組功能。

必要metadata屬性:

  • name (字串) – 自訂代理程式的唯一識別符。僅限小寫字母、數字和連字號,1-64 個字元。不得以連字號開頭或結尾。

選用metadata屬性:

  • 工具 (字串陣列) – 允許自訂代理程式使用的工具識別符。省略時預設為空白清單。

  • skills (字串陣列) – 自訂代理程式載入之技能的資產 IDs。省略時預設為空白清單。每個項目必須是相同客服人員空間中現有skill資產assetId的 ,而不是技能的 name。

  • memory_stores (字串陣列) – 記憶體存放區的資產 IDs,自訂代理程式可以讀取和寫入。省略時預設為空白清單。每個項目必須是相同客服人員空間中現有memory_store資產assetId的 ,而不是存放區的 name。自訂代理程式只會存取此處列出的存放區。

skills 和 中的每個項目memory_stores都必須解析為客服人員空間中相符類型的現有資產。如果項目未解析,您的請求會因 而失敗ValidationException。由於 name不是資產 ID,因此提供名稱會失敗此檢查。相同的驗證適用於 CreateAsset和 UpdateAsset。

範例metadata:

{ "name": "rds-firefighter", "tools": ["cloudwatch:GetMetricData", "rds:DescribeDBInstances"], "skills": ["ki-7f3c1a92-4d5e-4b8a-9c1f-2e6d8b4a5c70"], "memory_stores": ["ki-1b9e4d07-8a2c-4f61-b3d5-9c7e0a2f8b14"] }

memory_store

memory_store 資產是將相關記憶體檔案分組的容器。代理程式會讀取存放區的名稱和描述,以決定是否開啟它,並在其中列出記憶體。記憶體和記憶體存放區支援代理程式記憶體。如需記憶體的詳細資訊,請參閱 DevOps 代理程式記憶。

以兩個步驟建立記憶。首先,建立 memory_store。然後,建立memory其中的每個項目,如記憶體中所述。

必要metadata屬性:

  • name (字串) – 記憶體存放區的唯一識別符。僅限小寫字母、數字和連字號,1-128 個字元。不得以連字號開頭或結尾。

  • description (字串) – 存放區內容的 1–1024 字元描述。代理程式會使用它來決定是否開啟存放區。

  • agent_types (字串陣列) – 一個或多個可以看到存放區的代理類型。使用 ["GENERIC"] 讓所有客服人員類型都能看見存放區。沒有非空白的CreateAsset請求agent_types會失敗。

範例metadata:

{ "name": "incident-runbooks", "description": "Operational memories about past incidents and their resolutions.", "agent_types": ["GENERIC"] }

memory

memory 資產是屬於記憶體存放區的個別記憶體檔案。代理程式會讀取記憶體的名稱和描述,以決定是否要讀取完整檔案。memory_store 先建立父系,然後在記憶體memory_store_id上將 設定為存放區的資產 ID。

必要metadata屬性:

  • name (字串) – 記憶體的識別符,寫入為小寫 kebab-case 區段的 /分隔路徑,1–255 個字元 (例如 databases/rds-failover)。

  • description (字串) – 記憶體包含內容的 1–1024 字元描述。

  • memory_store_id (字串) – 此記憶體所屬記憶體存放區的資產 ID。

範例metadata:

{ "name": "databases/rds-failover", "description": "Steps that resolved the RDS failover incident in June.", "memory_store_id": "a1b2c3d4-5678-90ab-cdef-example11111" }

test_profile

test_profile 資產會存放可重複使用的發行測試執行組態,包括要執行的測試類型和目標端點。

必要metadata屬性:

  • test_agent_type (字串) – 此設定檔執行的測試類型。有效值為 releaseUiTesting 和 releaseApiTesting。

  • target_url (字串) – 測試執行目標的 URL。

選用metadata屬性:

  • name (字串) – 測試設定檔的人類可讀取識別符。僅限小寫字母、數字和連字號,1-128 個字元。不得以連字號開頭或結尾。

  • description (字串) – 測試描述檔涵蓋內容的 1–1024 字元描述。

  • test_personas (字串陣列) – 在測試執行期間要練習的角色。有效值為 guest 和 authenticated。

  • api_spec (字串) – 測試執行的 API 規格。與 相關releaseApiTesting。

  • credentials_secret_arn (字串) – AWS Secrets Manager 秘密的 ARN,存放測試執行的登入資料。

範例metadata:

{ "name": "checkout-api-tests", "description": "Release API tests for the checkout service.", "test_agent_type": "releaseApiTesting", "target_url": "https://api.example.com", "test_personas": ["guest", "authenticated"], "api_spec": "openapi: 3.0.0", "credentials_secret_arn": "arn:aws:secretsmanager:us-east-1:111122223333:secret:checkout-creds" }

feedback

feedback 資產會記錄客戶針對單一代理程式執行所提供的意見回饋。使用意見回饋資產來擷取下游評估管道可以彙總的判斷和備註。

必要metadata屬性:

  • agent_types (字串陣列) – 產生執行的代理程式類型。必須至少包含一個值 (例如 INCIDENT_TRIAGE)。

選用metadata屬性:

  • execution_id (字串) – 此回饋相關聯的執行。在 上設定此項目CreateAsset;無法由 變更UpdateAsset。

範例metadata:

{ "execution_id": "b2c3d4e5-6789-01ab-cdef-example22222", "agent_types": ["INCIDENT_TRIAGE"] }

資產內容:檔案或 zip

每個CreateAsset請求都包含一個物件,該content物件會保留資產存放區的位元組。的形狀content取決於您是上傳單一檔案還是 zip 套件:

  • 單一文字檔案 – content.file.body.text最多 1.5 MB 的 UTF-8 文字。將此用於簡單的技能和 AGENTS.md 檔案。

json { "content": { "file": { "path": "SKILL.md", "body": { "text": "# Skill\n\nInstructions go here." } } } }

  • 單一二進位檔案 – content.file.body.bytes承載最多 6 MB 的 base64 編碼二進位內容。將此用於連接,例如影像或 PDFs。由於 Blob 在content聯集內部巢狀,因此 base64 會預先編碼檔案,並使用 提交請求 --cli-input-json(請參閱從二進位檔案建立技能以取得工作範例)。

json { "content": { "file": { "path": "topology.png", "body": { "bytes": "<base64-encoded bytes>" } } } }

  • 壓縮套件 – content.zip.zipFile具有最多 6 MB 的 base64 編碼壓縮封存。將此用於在 references/或 assets/目錄中包含SKILL.md加其他檔案的技能。

json { "content": { "zip": { "zipFile": "<base64-encoded zip bytes>" } } }

若要新增、取代或刪除現有資產中的個別檔案,而不重新上傳整個套件,請使用 CreateAssetFile、 UpdateAssetFile和 DeleteAssetFile。

end-to-end管理技能

接下來的演練會以三種不同的方式 (從單一文字檔案、二進位檔案和 zip 套件) 建立技能,然後練習讀取、更新和刪除操作。8f6187a7-0388-4926-8217-3a0fe32f757c 以您的客服人員空間 ID 取代 。

從單一文字檔案建立技能

這是最簡單的路徑:內嵌上傳的單一SKILL.md檔案。由於上傳只包含一個文字檔案,因此您必須在 description中提供 name和 metadata。

AWS CLI:

aws devops-agent create-asset \ --agent-space-id 8f6187a7-0388-4926-8217-3a0fe32f757c \ --asset-type skill \ --metadata '{ "name": "rds-performance-investigation", "description": "Investigation procedures for RDS performance issues. Use when investigating database latency, connection errors, or query timeouts.", "agent_types": ["GENERIC"] }' \ --content '{ "file": { "path": "SKILL.md", "body": { "text": "# RDS Performance Investigation\n\nUse this skill when customers report database latency, connection errors, query timeouts, or read/write performance degradation." } } }'

Python (Boto3):

import boto3 client = boto3.client("devops-agent") response = client.create_asset( agentSpaceId="8f6187a7-0388-4926-8217-3a0fe32f757c", assetType="skill", metadata={ "name": "rds-performance-investigation", "description": ( "Investigation procedures for RDS performance issues. " "Use when investigating database latency, connection errors, " "or query timeouts." ), "agent_types": ["GENERIC"], }, content={ "file": { "path": "SKILL.md", "body": { "text": ( "# RDS Performance Investigation\n\n" "Use this skill when customers report database latency, " "connection errors, query timeouts, or read/write " "performance degradation." ) }, } }, ) asset_id = response["asset"]["assetId"]

從二進位檔案建立技能

當技能內容不是 UTF-8 文字時,請使用二進位上傳。以下範例會將預先轉譯的 PDF 上傳為技能內文。由於請求內文包含在content聯集內巢狀的 base64 編碼 Blob,請事先使用 --cli-input-json和 base64 編碼 Blob 提供來自 JSON 檔案的請求。

以下-w 0旗標base64會指示 GNU 在單行上發出編碼的 Blob;如果沒有預設的 76 個字元換行,則會插入新行,當 Blob 插入至 heredoc 時會產生無效的 JSON。在 macOS 上使用 base64 -i ops-runbook.pdf(BSD 預設base64不會包裝)。

建置請求內文:

base64 -w 0 ops-runbook.pdf > ops-runbook.b64 cat > create-skill.json <<EOF { "agentSpaceId": "8f6187a7-0388-4926-8217-3a0fe32f757c", "assetType": "skill", "metadata": { "name": "ops-runbook", "description": "Operations runbook covering on-call escalation paths.", "agent_types": ["GENERIC"] }, "content": { "file": { "path": "SKILL.pdf", "body": { "bytes": "$(cat ops-runbook.b64)" } } } } EOF

AWS CLI:

aws devops-agent create-asset --cli-input-json file://create-skill.json

Python (Boto3):

with open("ops-runbook.pdf", "rb") as f: body_bytes = f.read() response = client.create_asset( agentSpaceId="8f6187a7-0388-4926-8217-3a0fe32f757c", assetType="skill", metadata={ "name": "ops-runbook", "description": "Operations runbook covering on-call escalation paths.", "agent_types": ["GENERIC"], }, content={ "file": { "path": "SKILL.pdf", "body": {"bytes": body_bytes}, } }, )

從 zip 套件建立技能

當技能包含多個檔案時,請使用 zip 上傳,例如SKILL.md加號參考資料和資產。對於 zip 上傳,服務description會從SKILL.md前端讀取 name和 ,因此請勿將其包含在 中metadata。

zip 配置看起來像:

rds-performance-investigation.zip ├── SKILL.md ├── references/ │ └── rds-metrics-reference.md └── assets/ └── rds-investigation-flowchart.png

SKILL.md 必須包含前綴,以便服務可以擷取名稱和描述:

--- name: rds-performance-investigation description: Investigation procedures for RDS performance issues including connection exhaustion, slow queries, replication lag, and storage capacity. Use this skill when investigating database latency, connection errors, or read/write performance degradation. --- # RDS Performance Investigation ...

建置請求內文:

base64 -w 0 rds-performance-investigation.zip > skill.zip.b64 cat > create-skill.json <<EOF { "agentSpaceId": "8f6187a7-0388-4926-8217-3a0fe32f757c", "assetType": "skill", "metadata": { "agent_types": ["GENERIC"] }, "content": { "zip": { "zipFile": "$(cat skill.zip.b64)" } } } EOF

AWS CLI:

aws devops-agent create-asset --cli-input-json file://create-skill.json

Python (Boto3):

with open("rds-performance-investigation.zip", "rb") as f: zip_bytes = f.read() response = client.create_asset( agentSpaceId="8f6187a7-0388-4926-8217-3a0fe32f757c", assetType="skill", metadata={"agent_types": ["GENERIC"]}, content={"zip": {"zipFile": zip_bytes}}, )

從儲存庫匯入技能

您可以透過直接從 GitHub 儲存庫目錄匯入技能來建立技能。 AWS DevOps 代理程式會擷取技能內容、從 SKILL.md 前端擷取名稱和描述,並在您的代理程式空間中建立技能。這可讓您管理版本控制中的技能,並以程式設計方式匯入或同步這些技能。

先決條件:

  • 您的客服人員空間必須關聯 GitHub 帳戶。請參閱 連接 GitHub。

  • 儲存庫目錄必須包含具有前端的有效 SKILL.md 檔案。

AWS CLI:

aws devops-agent create-asset \ --agent-space-id 8f6187a7-0388-4926-8217-3a0fe32f757c \ --asset-type skill \ --metadata '{ "agent_types": ["GENERIC"] }' \ --content '{"sourceUrl": {"url": "https://github.com/my-org/my-repo/tree/main/skills/rds-investigation"}}'

Python (Boto3):

response = client.create_asset( agentSpaceId="8f6187a7-0388-4926-8217-3a0fe32f757c", assetType="skill", metadata={"agent_types": ["GENERIC"]}, content={ "sourceUrl": { "url": "https://github.com/my-org/my-repo/tree/main/skills/rds-investigation" } }, ) asset_id = response["asset"]["assetId"]

服務會擷取目錄內容、讀取 name和 的 SKILL.md 前綴description,以及匯入所有檔案。請勿在 description中包含 name或 metadata,它們會自動從前端擷取。

同步匯入的技能:

若要從儲存庫提取最新的變更,UpdateAsset請使用 呼叫 content.sourceUrl:

aws devops-agent update-asset \ --agent-space-id 8f6187a7-0388-4926-8217-3a0fe32f757c \ --asset-id <assetId> \ --content '{"sourceUrl": {"url": "https://github.com/my-org/my-repo/tree/main/skills/rds-investigation"}}'
response = client.update_asset( agentSpaceId="8f6187a7-0388-4926-8217-3a0fe32f757c", assetId="<assetId>", content={ "sourceUrl": { "url": "https://github.com/my-org/my-repo/tree/main/skills/rds-investigation" } }, )

同步會將技能內容完全取代為儲存庫目錄的目前狀態。可編輯欄位 (狀態、客服人員類型) 會保留。

檢視匯入來源:

GetAsset 傳回 中metadata.source儲存庫匯入技能的來源資訊:

{ "metadata": { "name": "rds-performance-investigation", "description": "Investigation procedures for RDS performance issues...", "source": { "url": "https://github.com/my-org/my-repo/tree/main/skills/rds-investigation", "lastSyncedAt": 1718467200 }, "agent_types": ["GENERIC"], "skill_type": "USER", "status": "ACTIVE" } }

限制條件:

  • 只接受 GitHub URLs。您可以指向包含 SKILL.md 的目錄 (例如 https://github.com/org/repo/tree/main/skills/my-skill),該目錄會匯入整個目錄,包括參考檔案。如果 SKILL.md 位於儲存庫的根目錄,您也可以直接連結至 檔案 (例如 https://github.com/org/repo/blob/main/SKILL.md),該檔案只會匯入 SKILL.md。

  • 目錄必須包含具有有效前端的 SKILL.md。

  • 目錄大小總計不得超過 6 MB,最多不得超過 100 個檔案。

  • content.sourceUrl 與 content.file和 互斥content.zip,您無法在相同的請求中合併它們。

  • 僅限中繼資料的更新 (不含 content) 會保留現有的匯入來源,而不會從儲存庫重新擷取。

取得、列出、更新和刪除

使用 GetAsset 依 ID 擷取單一資產:

aws devops-agent get-asset \ --agent-space-id 8f6187a7-0388-4926-8217-3a0fe32f757c \ --asset-id <assetId>

ListAssets 使用 分頁代理程式空間中的每個資產:

aws devops-agent list-assets \ --agent-space-id 8f6187a7-0388-4926-8217-3a0fe32f757c \ --max-results 50 aws devops-agent list-assets \ --agent-space-id 8f6187a7-0388-4926-8217-3a0fe32f757c \ --max-results 50 \ --next-token <token>

使用 UpdateAsset 變更一或多個metadata欄位,而無需重新上傳內容。您省略的金鑰會保留其現有值:

aws devops-agent update-asset \ --agent-space-id 8f6187a7-0388-4926-8217-3a0fe32f757c \ --asset-id <assetId> \ --metadata '{ "agent_types": ["INCIDENT_TRIAGE", "INCIDENT_RCA"] }'

使用 ListAssetVersions檢查資產的版本歷史記錄。每個成功 UpdateAsset或 UpdateAssetFile呼叫都會推進資產的版本編號:

aws devops-agent list-asset-versions \ --agent-space-id 8f6187a7-0388-4926-8217-3a0fe32f757c \ --asset-id <assetId>

使用 DeleteAsset移除資產及其所有檔案:

aws devops-agent delete-asset \ --agent-space-id 8f6187a7-0388-4926-8217-3a0fe32f757c \ --asset-id <assetId>

將單一檔案新增至現有技能

如果您已經從 zip bundle 建立技能,並想要新增一個新的參考檔案,則不需要重新上傳整個 bundle。使用 CreateAssetFile:

aws devops-agent create-asset-file \ --agent-space-id 8f6187a7-0388-4926-8217-3a0fe32f757c \ --asset-id <assetId> \ --path references/troubleshooting.md \ --content '{ "text": "# Troubleshooting\n\nAdditional notes." }'

若要取代就地的檔案,請使用 update-asset-file搭配相同的引數。若要移除它,請使用 delete-asset-file。

啟用和停用技能

技能在 中具有啟用狀態metadata.status。ACTIVE 根據預設,新技能由客服人員在調查和聊天期間載入。您可以停用技能使其停止輪換,而不將其刪除,例如當您調查它產生意外結果的原因時,稍後再重新啟用它。

透過在請求中包含 ,在建立時設定初始狀態: metadata.status CreateAsset

aws devops-agent create-asset \ --agent-space-id 8f6187a7-0388-4926-8217-3a0fe32f757c \ --asset-type skill \ --metadata '{ "name": "rds-performance-investigation", "description": "Investigation procedures for RDS performance issues.", "agent_types": ["GENERIC"], "status": "INACTIVE" }' \ --content '{ "file": { "path": "SKILL.md", "body": { "text": "# RDS Performance Investigation" } } }'

使用 停用現有的技能UpdateAsset。由於 metadata 會套用為部分更新,因此傳送只會status讓其他每個欄位保持不變:

aws devops-agent update-asset \ --agent-space-id 8f6187a7-0388-4926-8217-3a0fe32f757c \ --asset-id <assetId> \ --metadata '{ "status": "INACTIVE" }'

使用 以相同方式重新啟用 "status": "ACTIVE":

aws devops-agent update-asset \ --agent-space-id 8f6187a7-0388-4926-8217-3a0fe32f757c \ --asset-id <assetId> \ --metadata '{ "status": "ACTIVE" }'

GetAsset 和 ListAssets一律在 status中包含技能資產metadata的目前 ,因此您可以隨時讀取即時啟用狀態。

status 欄位區分大小寫。僅接受 ACTIVE和 INACTIVE(大寫)。任何其他值都會因 而失敗ValidationException。啟用僅適用於技能;在任何其他資產類型metadata.status上設定 沒有任何效果,且 欄位會從回應中捨棄。

使用 AWS CloudFormation 管理資產

使用資產 API 進行互動式或指令碼驅動的變更。若要宣告地管理資產,請將資產建模為 AWS CloudFormation 中的AWS::DevOpsAgent::Asset資源。透過此方法,您可以與其他基礎設施一起對資產進行版本控制、透過管道部署資產,並在 Agent Spaces 中重現資產。CloudFormation 會將每個資產建立為父代客服人員空間的子系,因此您在範本中定義的資產會對應至CreateAsset呼叫產生的完全相同資源。

您可以透過相同的AWS::DevOpsAgent::Asset資源管理每個資產類型。支援的類型為 skill、agents_md、attachment、custom_agent、memory_store、test_profile、 memory和 feedback。只有 AssetType、 Metadata和 內容因類型而異。下列範例會建立技能和自訂代理程式;其他類型使用資產類型中所述的中繼資料,遵循相同的形狀。

AWS::DevOpsAgent::Asset 資源

資源屬性會直接對應至本主題稍早所述的CreateAsset請求欄位:

CloudFormation 屬性 Type 對應至 備註
AgentSpaceId String agentSpaceId 必要. 僅限建立 - 變更它會取代資產。
AssetType String assetType 必要. 僅限建立。資產類型識別符 - 例如 skill或 custom_agent。資產類型中的任何類型都是有效的。
Metadata JSON metadata 與 API 相同的中繼資料文件 (適用於技能:name、agent_types、 description和選用的 status)。已就地更新。
Files 清單 content.file 內嵌檔案,每個檔案都有 Path和 ContentText或 ContentBytes,加上每個檔案的選用 Metadata。與 Zip 互斥。
Zip String content.zip.zipFile Base64-encoded的壓縮套件。與 Files 互斥。
AssetId String asset.assetId 唯讀。使用 擷取 Fn::GetAtt。
Arn String asset.arn 唯讀。資產 ARN,巢狀在父代理程式空間下。
Version Integer asset.version 唯讀。每次成功更新時都會產生凹凸。
CreatedAt / UpdatedAt String asset.createdAt / updatedAt 唯讀時間戳記。

在您撰寫範本之前,建議您先呼叫兩個行為:

  • AgentSpaceId 和 AssetType是僅限建立的。變更其中一個會取代資產。CloudFormation 會使用新的 AssetId和 建立新的資產Arn,然後刪除舊的資產。內容和中繼資料變更會更新現有的資產。

  • CloudFormation 會整體管理資產,其中繼資料及其完整的檔案集。若要變更技能,請編輯範本並更新堆疊。對資產部分採取動作的操作不是資源的一部分,並且保持僅限 API。這包括每個檔案編輯 (CreateAssetFile、UpdateAssetFile、DeleteAssetFile) 和版本歷史記錄 ()ListAssetVersions。它還包含內容下載 (GetAssetContent) 和儲存庫匯入和同步 (sourceUrl內容類型)。對於這些,請使用 CLI AWS 或 SDK,如本主題先前所示。

建立技能

下列範本會建立 CLI AWS 逐步解說中使用的單一檔案rds-performance-investigation技能。它以父代代理程式空間 ID 做為參數,並匯出新資產的 ID 和 ARN。

AWSTemplateFormatVersion: '2010-09-09' Description: A DevOps Agent skill managed as an AWS::DevOpsAgent::Asset resource. Parameters: AgentSpaceId: Type: String Description: The ID of the Agent Space that owns the skill. Resources: RdsPerformanceSkill: Type: AWS::DevOpsAgent::Asset Properties: AgentSpaceId: !Ref AgentSpaceId AssetType: skill Metadata: name: rds-performance-investigation description: Investigation procedures for RDS performance issues. agent_types: - GENERIC Files: - Path: SKILL.md ContentText: | # RDS Performance Investigation Use this skill when customers report database latency, connection errors, query timeouts, or read/write performance degradation. Outputs: SkillAssetId: Value: !GetAtt RdsPerformanceSkill.AssetId SkillArn: Value: !GetAtt RdsPerformanceSkill.Arn

使用 AWS CLI 部署它,並傳遞您的客服人員空間 ID:

aws cloudformation deploy \ --template-file skill.yaml \ --stack-name DevOpsAgentSkillStack \ --parameter-overrides AgentSpaceId=8f6187a7-0388-4926-8217-3a0fe32f757c \ --region <REGION>

運送多個檔案的技能,例如 SKILL.md加上參考文件,會將更多項目新增至 Files:

Files: - Path: SKILL.md ContentText: | # RDS Performance Investigation Investigation entry point. - Path: references/rds-metrics-reference.md ContentText: | # RDS metrics reference Key CloudWatch metrics to check.

若要建立已停用的技能,或稍後停用,請在 status中設定 Metadata(請參閱啟用和停用技能) 並更新堆疊:

Metadata: name: rds-performance-investigation description: Investigation procedures for RDS performance issues. agent_types: - GENERIC status: INACTIVE

建立自訂代理程式

自訂代理程式是具有不同 AssetType、 Metadata和 內容的相同資源。下列範本會建立incident-runbooks記憶體存放區,然後建立一組工具、技能和連接記憶體存放區的custom_agent資產。

skills 和 會依資產 ID memory_stores列出參考資產,而非依其 列出name。 對於在相同範本中定義的資產,請使用 Fn::GetAtt傳遞其 AssetId- 它會解析為服務預期的裸機 ID,並讓 CloudFormation 訂購兩個資源,因此不需要DependsOn。在這裡,incident-runbooks存放區會與代理程式一起定義,因此它使用 Fn::GetAtt。rds-performance-investigation 技能是由建立技能中的個別堆疊所建立,因此其資產 ID 會做為範本參數傳入,從該堆疊的SkillAssetId輸出取得值。

使用 Fn::GetAtt <Resource>.AssetId而非 Ref <Resource>:資源的主要識別符是 對 AgentSpaceId和 AssetId,因此Ref在資產資源上, 會傳回兩個聯結的垂直長條,驗證失敗。(Ref以下SkillAssetId參數上的 是參數查詢,且正確。)

Parameters: AgentSpaceId: Type: String Description: The ID of the Agent Space that owns these assets. SkillAssetId: Type: String Description: >- The AssetId of the rds-performance-investigation skill, taken from the SkillAssetId output of the skill stack. Resources: IncidentRunbooksStore: Type: AWS::DevOpsAgent::Asset Properties: AgentSpaceId: !Ref AgentSpaceId AssetType: memory_store Metadata: name: incident-runbooks description: Standing runbooks and known issues for incident response. agent_types: - GENERIC Files: - Path: README.md ContentText: | Operational memories for incident response. RdsFirefighter: Type: AWS::DevOpsAgent::Asset Properties: AgentSpaceId: !Ref AgentSpaceId AssetType: custom_agent Metadata: name: rds-firefighter tools: - cloudwatch:GetMetricData - rds:DescribeDBInstances skills: - !Ref SkillAssetId memory_stores: - !GetAtt IncidentRunbooksStore.AssetId Files: - Path: AGENT.md ContentText: | # RDS Firefighter Custom agent for RDS incidents.

如果您要附加的技能是在 CloudFormation 外部建立,或是由不會輸出其資產 ID 的堆疊所建立,請在客服人員空間ListAssets上呼叫 ,以尋找技能並assetId傳遞該值。AWS::DevOpsAgent::Asset 為已存在的技能宣告新的 會建立第二個技能,而不是採用現有的技能。

其他資產類型的運作方式相同:設定AssetType並提供 類型所需的Metadata金鑰 (請參閱資產類型)。例如,包含 Metadataagent_type: INCIDENT_TRIAGE和 AGENTS.md 檔案AssetType: agents_md的agents_md資產集。

使用觸發條件排程自訂代理程式

若要自動執行自訂代理程式,請新增 AWS::DevOpsAgent::Trigger 資源。觸發是客服人員空間的子項。其動作會參考要依資產 ID 執行的自訂代理程式,格式為 custom:<assetId>。使用 Fn::GetAtt傳遞自訂代理程式的 ,AssetId讓 CloudFormation 將兩個資源連接在一起,並訂購其建立。

下列觸發每天執行一次rds-firefighter自訂代理程式:

DailyRdsCheck: Type: AWS::DevOpsAgent::Trigger Properties: AgentSpaceId: !Ref AgentSpaceId Type: TIME_BASED Condition: Schedule: Expression: rate(1 day) Action: actionType: create:task task: agent: !Sub - custom:${AssetId} - AssetId: !GetAtt RdsFirefighter.AssetId Status: Active

AgentSpaceId、Condition、 Type和 Action 屬性僅限建立。變更其中任何一項都會取代觸發條件。Status 屬性接受 Active或 Inactive,並且可以就地更新。將其設定為 Inactive 以暫停觸發,而不將其刪除。如需排程表達式語法的詳細資訊,請參閱 執行自訂代理程式。

AWS::DevOpsAgent::Asset 和 AWS::DevOpsAgent::Trigger 可在提供 AWS DevOps 代理程式的 AWS 區域中使用。如需支援 AWS 區域的詳細資訊,請參閱 支援的區域。若要將父代 Agent Space、IAM 角色和運算子應用程式部署為基礎設施做為程式碼,請參閱 開始使用 AWS CloudFormation 的 AWS DevOps 代理程式。

其他資產類型的範例

上述技能演練適用於所有其他資產類型。唯一的區別是 metadata區塊,以及附件的二進位內容選擇。下面的最小CreateAsset呼叫說明每種類型。

記憶體存放區和記憶體使用相同的CreateAsset操作 - 首先建立存放區,然後在其中建立記憶體。如需各 接受的中繼資料,請參閱 memory_store 和記憶體 ;如需使用 CLI AWS 的記憶體存放區範例,請參閱 AWS DevOps Agent CLI 入門指南。以下使用存放區的 assetId做為 ,在現有存放區中建立記憶體memory_store_id:

aws devops-agent create-asset \ --agent-space-id 8f6187a7-0388-4926-8217-3a0fe32f757c \ --asset-type memory \ --metadata '{ "name": "alarms/checkout-latency", "description": "The checkout latency alarm is expected to spike during nightly batch jobs.", "memory_store_id": "<MEMORY_STORE_ASSET_ID>" }' \ --content '{ "file": { "path": "checkout-latency.md", "body": { "text": "# Checkout latency\n\nExpected to spike during nightly batch jobs." } } }'

建立 AGENTS.md:

aws devops-agent create-asset \ --agent-space-id 8f6187a7-0388-4926-8217-3a0fe32f757c \ --asset-type agents_md \ --metadata '{ "agent_type": "INCIDENT_TRIAGE" }' \ --content '{ "file": { "path": "AGENTS.md", "body": { "text": "# Triage Instructions\n\nFollow these steps for new incidents." } } }'

建立附件 (二進位內容;從 JSON 檔案建置請求,如從二進位檔案建立技能所示):

base64 -w 0 topology.png > topology.png.b64 cat > create-attachment.json <<EOF { "agentSpaceId": "8f6187a7-0388-4926-8217-3a0fe32f757c", "assetType": "attachment", "metadata": { "filename": "topology.png", "extension": "png", "size": 184320 }, "content": { "file": { "path": "topology.png", "body": { "bytes": "$(cat topology.png.b64)" } } } } EOF aws devops-agent create-asset --cli-input-json file://create-attachment.json

建立自訂代理程式:

將skills項目取代為您建立技能時assetId傳回的 。

aws devops-agent create-asset \ --agent-space-id 8f6187a7-0388-4926-8217-3a0fe32f757c \ --asset-type custom_agent \ --metadata '{ "name": "rds-firefighter", "tools": ["cloudwatch:GetMetricData", "rds:DescribeDBInstances"], "skills": ["ki-7f3c1a92-4d5e-4b8a-9c1f-2e6d8b4a5c70"] }' \ --content '{ "file": { "path": "AGENT.md", "body": { "text": "# RDS Firefighter\n\nCustom agent for RDS incidents." } } }'

建立測試設定檔:

aws devops-agent create-asset \ --agent-space-id 8f6187a7-0388-4926-8217-3a0fe32f757c \ --asset-type test_profile \ --metadata '{ "name": "checkout-api-tests", "test_agent_type": "releaseApiTesting", "target_url": "https://api.example.com", "test_personas": ["guest", "authenticated"] }' \ --content '{ "file": { "path": "PROFILE.md", "body": { "text": "# Checkout API test profile" } } }'

建立意見回饋資產:

aws devops-agent create-asset \ --agent-space-id 8f6187a7-0388-4926-8217-3a0fe32f757c \ --asset-type feedback \ --metadata '{ "execution_id": "b2c3d4e5-6789-01ab-cdef-example22222", "agent_types": ["INCIDENT_TRIAGE"] }' \ --content '{ "file": { "path": "FEEDBACK.md", "body": { "text": "{\"verdict\":\"correct\"}" } } }'

列出支援的資產類型:

aws devops-agent list-asset-types