本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
您可以使用 CodeArtifact 主控台或 刪除儲存庫 AWS CLI。刪除儲存庫之後,您就無法再將套件推送至其中或從中提取套件。儲存庫中的所有套件都會永久無法使用且無法還原。您可以建立同名的儲存庫,但其內容會是空的。
重要
刪除儲存庫無法復原。刪除儲存庫之後,您就無法再進行復原,也無法還原。
刪除儲存庫 (主控台)
-
開啟位於 https://console.aws.amazon.com/codesuite/codeartifact/home
的 AWS CodeArtifact 主控台。 -
在導覽窗格中,選擇儲存庫,然後選擇您要刪除的儲存庫。
-
選擇刪除,然後依照步驟刪除網域。
刪除儲存庫 (AWS CLI)
使用 delete-repository
命令來刪除儲存庫。
aws codeartifact delete-repository --domain
my_domain
--domain-owner111122223333
--repositorymy_repo
輸出範例:
{
"repository": {
"name": "my_repo
",
"administratorAccount": "123456789012
",
"domainName": "my_domain
",
"domainOwner": "123456789012
",
"arn": "arn:aws:codeartifact:region-id
:123456789012
:repository/my_domain
/my_repo
",
"description": "My new repository
",
"upstreams": [],
"externalConnections": []
}
}
防止儲存庫遭到刪除
您可以包含類似下列的網域政策,防止儲存庫意外刪除:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "DenyRepositoryDeletion",
"Action": [
"codeartifact:DeleteRepository"
],
"Effect": "Deny",
"Resource": "*",
"Principal": *
}
]
}
此政策可防止所有主體刪除儲存庫,但如果您稍後決定需要刪除儲存庫,您可以依照下列步驟執行:
-
在網域政策中,將政策更新為下列項目:
{ "Version": "2012-10-17", "Statement": [ { "Sid": "DenyRepositoryDeletion", "Action": [ "codeartifact:DeleteRepository" ], "Effect": "Deny", "NotResource": "
repository-arn
", "Principal": * } ] }將
repository-arn
取代為您要刪除之儲存庫的 ARN。 -
在 AWS CodeArtifact 主控台中,選擇儲存庫並刪除您選擇的儲存庫。
-
刪除儲存庫之後,您可以變更政策,以防止意外的偏離。
{ "Version": "2012-10-17", "Statement": [ { "Sid": "DenyRepositoryDeletion", "Action": [ "codeartifact:DeleteRepository" ], "Effect": "Deny", "Resource": "*", "Principal": * } ] }
或者,您可以在儲存庫政策中包含相同的拒絕陳述式。這可讓您有更多彈性來保護高價值儲存庫免於刪除。