Policy di controllo degli accessi IAM basate su tag - Amazon Athena

Le traduzioni sono generate tramite traduzione automatica. In caso di conflitto tra il contenuto di una traduzione e la versione originale in Inglese, quest'ultima prevarrà.

Policy di controllo degli accessi IAM basate su tag

La presenza di tag consente di scrivere una policy IAM che include il blocco Condition per controllare l'accesso a una risorsa in base ai relativi tag.

Esempi di policy relative ai tag per gruppi di lavoro

Esempio 1. Policy di tagging di base

La policy IAM seguente consente di eseguire query e interagire con i tag per il gruppo di lavoro denominato workgroupA:

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "athena:ListWorkGroups", "athena:ListEngineVersions", "athena:ListDataCatalogs", "athena:ListDatabases", "athena:GetDatabase", "athena:ListTableMetadata", "athena:GetTableMetadata" ], "Resource": "*" }, { "Effect": "Allow", "Action": [ "athena:GetWorkGroup", "athena:TagResource", "athena:UntagResource", "athena:ListTagsForResource", "athena:StartQueryExecution", "athena:GetQueryExecution", "athena:BatchGetQueryExecution", "athena:ListQueryExecutions", "athena:StopQueryExecution", "athena:GetQueryResults", "athena:GetQueryResultsStream", "athena:CreateNamedQuery", "athena:GetNamedQuery", "athena:BatchGetNamedQuery", "athena:ListNamedQueries", "athena:DeleteNamedQuery", "athena:CreatePreparedStatement", "athena:GetPreparedStatement", "athena:ListPreparedStatements", "athena:UpdatePreparedStatement", "athena:DeletePreparedStatement" ], "Resource": "arn:aws:athena:us-east-1:123456789012:workgroup/workgroupA" } ] }
Esempio 2: Blocco di policy che nega operazioni su un gruppo di lavoro in base alla coppia chiave-valore del tag

I tag associati a una risorsa esistente sono definiti tag di risorsa. I tag delle risorse consentono di scrivere blocchi di policy come i seguenti che negano le operazioni elencate su qualsiasi gruppo di lavoro contrassegnato con una coppia chiave-valore come stack, production.

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Deny", "Action": [ "athena:GetWorkGroup", "athena:UpdateWorkGroup", "athena:DeleteWorkGroup", "athena:TagResource", "athena:UntagResource", "athena:ListTagsForResource", "athena:StartQueryExecution", "athena:GetQueryExecution", "athena:BatchGetQueryExecution", "athena:ListQueryExecutions", "athena:StopQueryExecution", "athena:GetQueryResults", "athena:GetQueryResultsStream", "athena:CreateNamedQuery", "athena:GetNamedQuery", "athena:BatchGetNamedQuery", "athena:ListNamedQueries", "athena:DeleteNamedQuery", "athena:CreatePreparedStatement", "athena:GetPreparedStatement", "athena:ListPreparedStatements", "athena:UpdatePreparedStatement", "athena:DeletePreparedStatement" ], "Resource": "arn:aws:athena:us-east-1:123456789012:workgroup/*", "Condition": { "StringEquals": { "aws:ResourceTag/stack": "production" } } } ] }
Esempio 3: Blocco di policy che limita le richieste di operazioni di modifica tag a determinati tag

I tag passati come parametri alle operazioni che modificano i tag (ad esempio TagResource, UntagResource, o CreateWorkGroup con tag) vengono definiti tag di richiesta. Il seguente blocco di policy di esempio consente l'operazione CreateWorkGroup solo se uno dei tag passati ha la chiave costcenter e il valore 1, 2, o 3.

Nota

Se desideri autorizzare un ruolo IAM a passare i tag come parte di un'operazione CreateWorkGroup, assicurati di concedere al ruolo le autorizzazioni per le operazioni TagResource e CreateWorkGroup.

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "athena:CreateWorkGroup", "athena:TagResource" ], "Resource": "arn:aws:athena:us-east-1:123456789012:workgroup/*", "Condition": { "StringEquals": { "aws:RequestTag/costcenter": [ "1", "2", "3" ] } } } ] }

Esempi di policy relative ai tag per cataloghi dati

Esempio 1. Policy di tagging di base

La seguente policy IAM consente di interagire con i tag per il catalogo dati denominato datacatalogA:

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "athena:ListWorkGroups", "athena:ListEngineVersions", "athena:ListDataCatalogs", "athena:ListDatabases", "athena:GetDatabase", "athena:ListTableMetadata", "athena:GetTableMetadata" ], "Resource": "*" }, { "Effect": "Allow", "Action": [ "athena:GetWorkGroup", "athena:TagResource", "athena:UntagResource", "athena:ListTagsForResource", "athena:StartQueryExecution", "athena:GetQueryExecution", "athena:BatchGetQueryExecution", "athena:ListQueryExecutions", "athena:StopQueryExecution", "athena:GetQueryResults", "athena:GetQueryResultsStream", "athena:CreateNamedQuery", "athena:GetNamedQuery", "athena:BatchGetNamedQuery", "athena:ListNamedQueries", "athena:DeleteNamedQuery" ], "Resource": [ "arn:aws:athena:us-east-1:123456789012:workgroup/*" ] }, { "Effect": "Allow", "Action": [ "athena:CreateDataCatalog", "athena:GetDataCatalog", "athena:UpdateDataCatalog", "athena:DeleteDataCatalog", "athena:ListDatabases", "athena:GetDatabase", "athena:ListTableMetadata", "athena:GetTableMetadata", "athena:TagResource", "athena:UntagResource", "athena:ListTagsForResource" ], "Resource": "arn:aws:athena:us-east-1:123456789012:datacatalog/datacatalogA" } ] }
Esempio 2: Blocco di policy che nega operazioni su un catalogo dati in base alla coppia chiave-valore del tag

È possibile utilizzare i tag delle risorse per scrivere blocchi di policy che negano operazioni specifiche nei cataloghi dati contrassegnati con coppie chiave-valore di tag specifiche. La seguente policy di esempio nega le operazioni sui cataloghi dati con la coppia chiave-valore di tag stack, production.

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Deny", "Action": [ "athena:CreateDataCatalog", "athena:GetDataCatalog", "athena:UpdateDataCatalog", "athena:DeleteDataCatalog", "athena:GetDatabase", "athena:ListDatabases", "athena:GetTableMetadata", "athena:ListTableMetadata", "athena:StartQueryExecution", "athena:TagResource", "athena:UntagResource", "athena:ListTagsForResource" ], "Resource": "arn:aws:athena:us-east-1:123456789012:datacatalog/*", "Condition": { "StringEquals": { "aws:ResourceTag/stack": "production" } } } ] }
Esempio 3: Blocco di policy che limita le richieste di operazioni di modifica tag a determinati tag

I tag passati come parametri alle operazioni che modificano i tag (ad esempio TagResource, UntagResource, o CreateDataCatalog con tag) vengono definiti tag di richiesta. Il seguente blocco di policy di esempio consente l'operazione CreateDataCatalog solo se uno dei tag passati ha la chiave costcenter e il valore 1, 2, o 3.

Nota

Se desideri autorizzare un ruolo IAM a passare i tag come parte di un'operazione CreateDataCatalog, assicurati di concedere al ruolo le autorizzazioni per le operazioni TagResource e CreateDataCatalog.

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "athena:CreateDataCatalog", "athena:TagResource" ], "Resource": "arn:aws:athena:us-east-1:123456789012:datacatalog/*", "Condition": { "StringEquals": { "aws:RequestTag/costcenter": [ "1", "2", "3" ] } } } ] }