Aller au contenu principal
Version : v1.2.0

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. If the call is denied in every region, all regions are scanned.
account:ListRegionsLists enabled regions when ec2:DescribeRegions failsNot called when ec2:DescribeRegions works.
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 122 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. A second statement allows apigateway:GET only on /restapis, /domainnames and /usageplans, so API key values cannot be read.

v1.2.0 added these 17 actions for the new services and the region fallback: account:ListRegions, appsync:ListGraphqlApis, athena:ListWorkGroups, autoscaling:DescribeAutoScalingGroups, backup:ListBackupVaults, cognito-idp:ListUserPools, ec2:DescribeNetworkInterfaces, ecr:DescribeRepositories, elasticbeanstalk:DescribeApplications, elasticbeanstalk:DescribeEnvironments, elasticfilesystem:DescribeFileSystems, elasticmapreduce:ListClusters, es:ListDomainNames, firehose:ListDeliveryStreams, kafka:ListClustersV2, redshift-serverless:ListNamespaces, redshift-serverless:ListWorkgroups. It also removed cloudtrail:LookupEvents, which the inventag command does not call.

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.