Datadog Database Monitoring (DBM) allows you to view explain plans and query samples running on your database hosts. This guide shows you how to use cloud managed authentication features, such as IAM, to connect the Agent to your database. This provides a more secure way to authenticate and saves you from having to manage database credentials across your agent hosts.
AWS supports IAM authentication to RDS and Aurora databases. Starting with Datadog Agent version 7.57, cross-account IAM authentication is supported for RDS and Aurora databases.
In order to configure the Agent to connect using IAM, follow the steps to complete the setup for the database and the Datadog Agent.
AWS also supports wildcards for specifying the resource, for example if you wanted to allow the datadog user to authenticate across all instances for an account add the following:
Create an IAM role and attach the IAM policy created for DB authentication to the role.
# Create an IAM role for EC2 instance# Replace `<YOUR_IAM_AUTH_DB_ROLE>` with the name of the IAM roleaws iam create-role --role-name <YOUR_IAM_AUTH_DB_ROLE> --assume-role-policy-document '{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": "ec2.amazonaws.com"
},
"Action": "sts:AssumeRole"
}
]
}'# Attach the IAM policy to the IAM role# Replace `<YOUR_IAM_AUTH_DB_POLICY_ARN>` with the ARN of the IAM policy from step 2aws iam attach-role-policy --role-name <YOUR_IAM_AUTH_DB_ROLE> --policy-arn <YOUR_IAM_AUTH_DB_POLICY_ARN>
Attach the IAM role to the EC2 instance where the Agent is running. For more information, see IAM roles for Amazon EC2.
Create an IAM role and attach the IAM policy created for DB authentication to the role.
# Create an IAM role for ECS task# Replace `<YOUR_IAM_AUTH_DB_ROLE>` with the name of the IAM roleaws iam create-role --role-name <YOUR_IAM_AUTH_DB_ROLE> --assume-role-policy-document '{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": "ecs-tasks.amazonaws.com"
},
"Action": "sts:AssumeRole"
}
]
}'# Attach the IAM policy to the IAM role# Replace `<YOUR_IAM_AUTH_DB_POLICY_ARN>` with the ARN of the IAM policy from step 2aws iam attach-role-policy --role-name <YOUR_IAM_AUTH_DB_ROLE> --policy-arn <YOUR_IAM_AUTH_DB_POLICY_ARN>
In the ECS task definition, attach the IAM role to the task role where the Agent container is defined. For more information, see IAM roles for Amazon ECS.
Create an IAM role and attach the IAM policy created for DB authentication to the role.
# Create an IAM OIDC provider for your cluster# Replace `<YOUR_ESK_REGION>` and `<YOUR_ESK_CLUSTER>` with the region and name of your ESK cluster$ eksctl utils associate-iam-oidc-provider \
--region=<YOUR_ESK_REGION> \
--cluster=<YOUR_ESK_CLUSTER> \
--approve
# Create a service account# Replace `<YOUR_IAM_AUTH_DB_POLICY_ARN>` with the ARN of the IAM policy from step 2# Replace `<YOUR_IAM_AUTH_SERVICE_ACCOUNT>` and `<YOUR_IAM_AUTH_SERVICE_ACCOUNT_NAMESPACE>` with the name and namespace of the service account$ eksctl create iamserviceaccount \
--cluster <YOUR_ESK_CLUSTER> \
--name <YOUR_IAM_AUTH_SERVICE_ACCOUNT> \
--namespace <YOUR_IAM_AUTH_SERVICE_ACCOUNT_NAMESPACE> \
--attach-policy-arn <YOUR_IAM_AUTH_DB_POLICY_ARN> \
--override-existing-serviceaccounts \
--approve
Create an IAM role in the account where the RDS instance is located, and attach the IAM policy created for DB authentication to the role using the example below.
Replace <YOUR_IAM_AUTH_DB_ROLE> with the name of the IAM role
Replace <YOUR_AWS_ACCOUNT_FOR_AGENT> with the AWS account ID where the Agent is running
Replace <YOUR_AGENT_EC2_ROLE> with the IAM role of the EC2 instance where the Agent is running
Replace <YOUR_IAM_AUTH_DB_POLICY_ARN> with the ARN of the IAM policy created for DB authentication
Create an IAM role in the account where the RDS instance is located, and attach the IAM policy created for DB authentication to the role using the example below.
Replace <YOUR_IAM_AUTH_DB_ROLE> with the name of the IAM role created for DB authentication
Replace <YOUR_AWS_ACCOUNT_FOR_AGENT> with the AWS account ID where the Agent is running
Replace <YOUR_AGENT_ECS_ROLE> with the IAM role of the ECS task where the Agent is running
Replace <YOUR_IAM_AUTH_DB_POLICY_ARN> with the ARN of the IAM policy created for DB authentication
Modify the IAM role permission policies of the ECS task where the Agent is running to allow the agent to assume the IAM role created in the previous step.
Replace <YOUR_AGENT_ECS_ROLE> with the IAM role of the ECS task where the Agent is running
Replace <YOUR_IAM_AUTH_DB_ROLE> with the name of the IAM role
Replace <YOUR_AWS_ACCOUNT_FOR_DB> with the AWS account ID where the RDS instance is located
Create an IAM role in the account where the RDS instance is located, and attach the IAM policy created for DB authentication to the role using the example below.
Replace <YOUR_IAM_AUTH_DB_ROLE> with the name of the IAM role
Replace <YOUR_AWS_ACCOUNT_FOR_AGENT> with the AWS account ID where the Agent is running
Replace <YOUR_AGENT_EKS_ROLE> with the IAM role to be used by the EKS pods where the Agent is running
Replace <YOUR_IAM_AUTH_DB_POLICY_ARN> with the ARN of the IAM policy created for DB authentication
Update your Postgres instance config with an aws block as shown below:
Specify the region of the RDS instance
Set managed_authentication.enabled to true
Specify the role ARN, replacing <YOUR_AWS_ACCOUNT_FOR_DB> with the AWS account ID where the RDS instance is located, and <YOUR_IAM_AUTH_DB_ROLE> with the name of the IAM role created in step 1
Azure allows users to configure managed identity authentication for any resource that can access Microsoft Entra ID, formerly Azure Active Directory. The Datadog Agent supports user-assigned managed identity authentication to your cloud databases.
Configure your instance config with the azure.managed_authentication YAML block, where the CLIENT_ID is the Client ID of the Managed Identity:
instances:- host:example-flex-server.postgres.database.azure.comdbm:trueusername:"<IDENTITY_NAME>"ssl:"require"azure:deployment_type:flexible_serverfully_qualified_domain_name:example-flex-server.postgres.database.azure.commanaged_authentication:enabled:trueclient_id:"<CLIENT_ID>"# Optionally set the scope from where to request the identity tokenidentity_scope:"https://ossrdbms-aad.database.windows.net/.default"