AWS API
Connect the Infinity data source to AWS management APIs to query metrics, list resources, and retrieve cost data.
The Infinity data source supports two AWS authentication providers and optional IAM role assumption for cross-account or role-based access.
Authentication providers
IAM role assumption (AssumeRole)
Both authentication providers support optional IAM role assumption via STS AssumeRole. This is useful for:
- Cross-account access: reach resources in a different AWS account.
- Least privilege: use a base identity with minimal permissions and assume a role that has the specific permissions.
- EKS IRSA: the pod authenticates through IRSA (default credentials) and then assumes a target role that has the required permissions.
Temporary credentials obtained via AssumeRole are automatically refreshed by the AWS SDK when they expire.
Grafana server configuration
The Grafana server controls which AWS authentication providers the data source offers. Add the following to grafana.ini or set equivalent environment variables:
[aws]
allowed_auth_providers = default,keys
assume_role_enabled = true
forward_settings_to_plugins = yesoreyeram-infinity-datasourceOr via environment variables:
GF_AWS_ALLOWED_AUTH_PROVIDERS=default,keys
GF_AWS_ASSUME_ROLE_ENABLED=true
GF_AWS_FORWARD_SETTINGS_TO_PLUGINS=yesoreyeram-infinity-datasourceIf forward_settings_to_plugins already contains other data source plugin IDs, append yesoreyeram-infinity-datasource to the existing comma-separated list instead of replacing it.
forward_settings_to_plugins is what applies allowed_auth_providers and assume_role_enabled to the plugin backend. If the plugin isn’t listed, the backend falls back to the AWS SDK defaults, which permit the default, keys, and credentials providers and allow role assumption, regardless of the server settings. Include the plugin so that your server settings are enforced end to end.
Before you begin
The AWS authentication options depend on the Grafana server configuration described in Grafana server configuration. If the server doesn’t allow the default provider, the AWS SDK Default option isn’t shown, and if assume_role_enabled is disabled, the Assume Role ARN and External ID fields aren’t shown.
On Grafana Cloud, the default provider isn’t allowed, so AWS SDK Default isn’t offered. Use Access and secret key, optionally with an Assume Role ARN, which is supported because role assumption is enabled there.
For Access and secret key authentication:
- Create an AWS IAM user with programmatic access
- Note down your Access Key ID and Secret Access Key
- Assign appropriate IAM permissions for the APIs you want to query (for example, CloudWatch ReadOnly, Cost Explorer ReadOnly)
For AWS SDK Default authentication:
- Ensure the Grafana instance has an IAM role attached (instance profile, task role, or IRSA service account) with the required permissions
Configure the data source
Choose the authentication provider that matches your environment, then configure the data source.
Configure with access and secret key
In Grafana, navigate to Connections > Data sources.
Click Add new data source and select Infinity.
Expand the Authentication section and select AWS.
Select Access and secret key as the Authentication Provider.
Configure the following settings:
In Allowed hosts, enter your AWS endpoint (for example,
https://monitoring.us-east-1.amazonaws.com).Click Save & test.
AWS SDK Default
This method is suitable for EC2 instances, ECS tasks, and EKS pods with IRSA.
- In Grafana, navigate to Connections > Data sources.
- Click Add new data source and select Infinity.
- Expand the Authentication section and select AWS.
- Select AWS SDK Default as the Authentication Provider.
- Select a Region.
- Enter a Service.
- Optionally, enter an Assume Role ARN for cross-account access.
- In Allowed hosts, enter your AWS endpoint.
- Click Save & test.
EKS IRSA example
When running on EKS with IAM Roles for Service Accounts (IRSA):
- Create an IAM role with the required permissions and a trust policy that allows the Kubernetes service account.
- Annotate the Kubernetes service account:
apiVersion: v1 kind: ServiceAccount metadata: name: grafana annotations: eks.amazonaws.com/role-arn: arn:aws:iam::123456789012:role/GrafanaRole - Configure the data source with AWS SDK Default. No static keys are needed.
- If the IRSA role only has
sts:AssumeRolepermissions, set the Assume Role ARN to the target role.
Tip
Find the appropriate service name in the AWS service endpoints documentation.
Common AWS service identifiers
Query examples
List CloudWatch metrics
Set the URL to:
https://monitoring.us-east-1.amazonaws.com?Action=ListMetrics&Version=2010-08-01Set Type to XML (AWS returns XML by default).
Set Parser to Backend.
Set the Root selector to extract the metrics array.
CloudWatch metrics with UQL
Use UQL to transform and filter the AWS XML response:
parse-xml
| scope "ListMetricsResponse.ListMetricsResult.Metrics.member"
| project "Namespace", "MetricName", "Dimensions"List EC2 instances
URL:
https://ec2.us-east-1.amazonaws.com?Action=DescribeInstances&Version=2016-11-15UQL query:
parse-xml
| scope "DescribeInstancesResponse.reservationSet.item.instancesSet.item"
| project "InstanceId"="instanceId", "State"="instanceState.name", "Type"="instanceType"Cost Explorer data
Note
Cost Explorer API requires the
ceservice and is only available inus-east-1.
URL:
https://ce.us-east-1.amazonaws.comMethod: POST
Body (JSON):
{
"TimePeriod": {
"Start": "${__from:date:YYYY-MM-DD}",
"End": "${__to:date:YYYY-MM-DD}"
},
"Granularity": "DAILY",
"Metrics": ["UnBlendedCost"]
}Provision the data source
Access Key & Secret Key
apiVersion: 1
datasources:
- name: AWS Infinity
type: yesoreyeram-infinity-datasource
jsonData:
auth_method: aws
aws:
authType: keys
region: us-east-1
service: monitoring
allowedHosts:
- https://monitoring.us-east-1.amazonaws.com
secureJsonData:
awsAccessKey: YOUR_ACCESS_KEY
awsSecretKey: YOUR_SECRET_KEYAccess Key & Secret Key + AssumeRole
apiVersion: 1
datasources:
- name: AWS Infinity (AssumeRole)
type: yesoreyeram-infinity-datasource
jsonData:
auth_method: aws
aws:
authType: keys
region: us-east-1
service: monitoring
assumeRoleArn: arn:aws:iam::123456789012:role/MyRole
externalId: my-external-id
allowedHosts:
- https://monitoring.us-east-1.amazonaws.com
secureJsonData:
awsAccessKey: YOUR_ACCESS_KEY
awsSecretKey: YOUR_SECRET_KEYAWS SDK Default
apiVersion: 1
datasources:
- name: AWS Infinity (IAM Role)
type: yesoreyeram-infinity-datasource
jsonData:
auth_method: aws
aws:
authType: default
region: us-east-1
service: monitoring
allowedHosts:
- https://monitoring.us-east-1.amazonaws.comDefault Credentials + AssumeRole
apiVersion: 1
datasources:
- name: AWS Infinity (IAM Role + AssumeRole)
type: yesoreyeram-infinity-datasource
jsonData:
auth_method: aws
aws:
authType: default
region: us-east-1
service: monitoring
assumeRoleArn: arn:aws:iam::123456789012:role/MyRole
allowedHosts:
- https://monitoring.us-east-1.amazonaws.com

