AnalyticDB for PostgreSQL custom policies
When system policies don't provide the granularity you need, create custom policies to enforce least privilege. Custom policies let you write precise Deny rules — for example, blocking RAM users from disabling SSL or creating unencrypted instances.
What is a custom policy?
Resource Access Management (RAM) has two policy types: system policies (managed by Alibaba Cloud) and custom policies (managed by you).
Custom policies work as follows:
After you create a custom policy, attach it to a RAM user, RAM user group, or RAM role to grant the permissions specified in the policy to that principal.
To delete a custom policy that is attached to a principal, detach it from the principal first.
Custom policies support version control. Use RAM's version management mechanism to track and roll back policy changes.
Custom policy examples
Scenario 1: Prohibit disabling SSL encryption
This policy prevents RAM users from calling gpdb:ModifyDBInstanceSSL when the SSLEnabled value is set to Disable.
Supported versions: AnalyticDB for PostgreSQL V6.0 in elastic storage mode and AnalyticDB for PostgreSQL in Serverless mode.
{
"Version": "1",
"Statement": [
{
"Effect": "Deny",
"Action": "gpdb:ModifyDBInstanceSSL",
"Resource": "*",
"Condition": {
"StringEquals": {
"gpdb:SSLEnabled": [
"Disable"
]
}
}
}
]
}How this policy works:
| Field | Value | Meaning |
|---|---|---|
Effect | Deny | Blocks the action when all conditions match |
Action | gpdb:ModifyDBInstanceSSL | Targets the SSL configuration API |
Resource | * | Applies to all AnalyticDB for PostgreSQL instances |
Condition operator | StringEquals | Matches when the condition key equals the specified value |
gpdb:SSLEnabled | Disable | Triggers the block when the request attempts to disable SSL |
Scenario 2: Prohibit creating instances without disk encryption
This policy prevents RAM users from calling gpdb:CreateDBInstance unless the EncryptionType is set to CloudDisk.
Supported versions: AnalyticDB for PostgreSQL V6.0 in elastic storage mode and AnalyticDB for PostgreSQL V7.0 in elastic storage mode.
{
"Version": "1",
"Statement": [
{
"Effect": "Deny",
"Action": "gpdb:CreateDBInstance",
"Resource": "*",
"Condition": {
"StringNotEquals": {
"gpdb:EncryptionType": [
"CloudDisk"
]
}
}
}
]
}How this policy works:
| Field | Value | Meaning |
|---|---|---|
Effect | Deny | Blocks the action when all conditions match |
Action | gpdb:CreateDBInstance | Targets the instance creation API |
Resource | * | Applies to all AnalyticDB for PostgreSQL instances |
Condition operator | StringNotEquals | Matches when the condition key does not equal the specified value |
gpdb:EncryptionType | CloudDisk | Triggers the block when the request omits cloud disk encryption |
Authorization information
To write effective custom policies, understand which actions, resources, and condition keys AnalyticDB for PostgreSQL exposes. For the full list of supported actions and condition keys (including gpdb:SSLEnabled and gpdb:EncryptionType), see RAM authorization.