跳到主要內容
版本:v1.1.2

IAM permissions

Who this is for: you review or write the IAM policy for InvenTag.

What you can do after reading: grant exactly what InvenTag needs and explain each permission to a reviewer.

For step-by-step setup, see Set up read-only access.

What every run needs​

PermissionWhyNotes
sts:GetCallerIdentityFinds out which account the credentials belong toAWS allows this for every identity; you don't need to grant it.
ec2:DescribeRegionsLists enabled regions, and checks each region you scanThe check runs for every region, even with --account-regions. A region that fails it is skipped with a warning.
tag:GetResourcesFinds tagged resources (Resource Groups Tagging API)The IAM prefix is tag, not resourcegroupstaggingapi.
ce:GetCostAndUsageFinds services with spendAWS charges per request. In our offline test a run made two for each account. If denied, discovery continues without billing data. --no-billing-validation stops the calls, and then you can leave this permission out.
List*, Describe*, Get* for each service you want in the reportPer-service discoveryFor example s3:ListAllMyBuckets, s3:GetBucketTagging, lambda:ListFunctions, dynamodb:ListTables. The AWS managed ReadOnlyAccess policy covers these.

What some features need​

FeatureExtra permission
Scanning other accounts through a rolests:AssumeRole on those roles, and a trust policy in each account that allows your identity
--enable-cost-analysispricing:GetProducts, and cloudwatch:GetMetricStatistics (both are in the repository policy)
--s3-buckets3:PutObject on that bucket (and kms:GenerateDataKey on the key if you use aws:kms)

What InvenTag never needs​

Any write, create, delete or tag action, apart from s3:PutObject on a reports bucket if you upload reports. If a reviewer finds another one in your InvenTag policy, remove it. InvenTag's read-only guard blocks such calls anyway. Two library functions in the code can write to AWS when called from your own Python code (the CLI does not call them); see Feature status.

The policy in the repository​

config/defaults/iam-policy-read-only.json is generated from an explicit list of 106 read actions in the code (inventag/security/iam_policy.py), so it matches what InvenTag calls. It includes tag:GetResources, ce:GetCostAndUsage, pricing:GetProducts and lambda:GetFunctionConfiguration.

Its OptionalS3ReportUpload statement allows s3:PutObject, but only with server-side encryption. Put your bucket name in place of YOUR-REPORTS-BUCKET-NAME, or remove the statement if you don't use --s3-bucket.

Check a policy​

Shell
aws iam simulate-principal-policy \
--policy-source-arn arn:aws:iam::123456789012:role/InvenTagReadOnly \
--action-names tag:GetResources ce:GetCostAndUsage s3:PutObject \
--query "EvaluationResults[].[EvalActionName,EvalDecision]" --output table

The first two should be allowed, and s3:PutObject should be denied.