{
  "id": "queue/heartbeat",
  "description": "Allows readonly monitoring and health checks for queue resources",
  "platforms": {
    "aws": [
      {
        "grant": {
          "actions": ["sqs:GetQueueAttributes", "sqs:ListQueueTags"]
        },
        "binding": {
          "stack": {
            "resources": ["arn:aws:sqs:${awsRegion}:${awsAccountId}:${stackPrefix}-*"]
          },
          "resource": {
            "resources": ["arn:aws:sqs:${awsRegion}:${awsAccountId}:${resourceName}"]
          }
        }
      }
    ],
    "gcp": [
      {
        "grant": {
          "permissions": [
            "pubsub.topics.get",
            "pubsub.topics.list",
            "pubsub.subscriptions.get",
            "pubsub.subscriptions.list"
          ]
        },
        "binding": {
          "stack": {
            "scope": "projects/${projectName}",
            "condition": {
              "title": "Queue management access",
              "expression": "(resource.type == 'pubsub.googleapis.com/Topic' && resource.name.startsWith('projects/${projectName}/topics/${stackPrefix}-')) || (resource.type == 'pubsub.googleapis.com/Subscription' && resource.name.startsWith('projects/${projectName}/subscriptions/${stackPrefix}-'))"
            }
          },
          "resource": {
            "scope": "projects/${projectName}",
            "condition": {
              "title": "Queue management access",
              "expression": "(resource.type == 'pubsub.googleapis.com/Topic' && resource.name.startsWith('projects/${projectName}/topics/${resourceName}')) || (resource.type == 'pubsub.googleapis.com/Subscription' && resource.name.startsWith('projects/${projectName}/subscriptions/${resourceName}'))"
            }
          }
        }
      }
    ],
    "azure": [
      {
        "grant": {
          "actions": [
            "Microsoft.ServiceBus/namespaces/read",
            "Microsoft.ServiceBus/namespaces/queues/read",
            "Microsoft.ServiceBus/namespaces/authorizationRules/read"
          ]
        },
        "binding": {
          "stack": {
            "scope": "/subscriptions/${subscriptionId}/resourceGroups/${resourceGroup}"
          },
          "resource": {
            "scope": "/subscriptions/${subscriptionId}/resourceGroups/${resourceGroup}/providers/Microsoft.ServiceBus/namespaces/${resourceName}-sb"
          }
        }
      }
    ]
  }
}
