{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "redshiftDataScopeDownPermissions",
      "Effect": "Allow",
      "Action": [
        "redshift-data:BatchExecuteStatement",
        "redshift-data:DescribeTable",
        "redshift-data:ExecuteStatement",
        "redshift-data:ListTables",
        "redshift-data:ListSchemas",
        "redshift-data:ListDatabases"
      ],
      "Resource": [
        "arn:aws:redshift-serverless:*:*:workgroup/*",
        "arn:aws:redshift:*:*:cluster:*"
      ],
      "Condition": {
        "StringEquals": {
          "aws:ResourceAccount": "${aws:PrincipalAccount}"
        }
      }
    },
    {
      "Sid": "listSecretsPermission",
      "Effect": "Allow",
      "Action": "secretsmanager:ListSecrets",
      "Resource": "*"
    },
    {
      "Sid": "getWorkgroupPermission",
      "Effect": "Allow",
      "Action": "redshift-serverless:GetWorkgroup",
      "Resource": [
        "arn:aws:redshift-serverless:*:*:workgroup/*"
      ],
      "Condition": {
        "StringEquals": {
          "aws:ResourceAccount": "${aws:PrincipalAccount}"
        }
      }
    },
    {
      "Sid": "createAndDeleteWorkgroupPermissions",
      "Effect": "Allow",
      "Action": [
        "redshift-serverless:CreateWorkgroup",
        "redshift-serverless:DeleteWorkgroup"
      ],
      "Resource": [
        "arn:aws:redshift-serverless:*:*:workgroup/*"
      ],
      "Condition": {
        "StringEquals": {
          "aws:ResourceAccount": "${aws:PrincipalAccount}"
        },
        "ForAnyValue:StringEquals": {
          "aws:CalledVia": [
            "glue.amazonaws.com",
            "lakeformation.amazonaws.com"
          ]
        }
      }
    },
    {
      "Sid": "getNamespacePermission",
      "Effect": "Allow",
      "Action": "redshift-serverless:GetNamespace",
      "Resource": [
        "arn:aws:redshift-serverless:*:*:namespace/*"
      ],
      "Condition": {
        "StringEquals": {
          "aws:ResourceAccount": "${aws:PrincipalAccount}"
        }
      }
    },
    {
      "Sid": "createAndDeleteNamespacePermissions",
      "Effect": "Allow",
      "Action": [
        "redshift-serverless:CreateNamespace",
        "redshift-serverless:DeleteNamespace"
      ],
      "Resource": [
        "arn:aws:redshift-serverless:*:*:namespace/*"
      ],
      "Condition": {
        "StringEquals": {
          "aws:ResourceAccount": "${aws:PrincipalAccount}"
        },
        "ForAnyValue:StringEquals": {
          "aws:CalledVia": [
            "glue.amazonaws.com",
            "lakeformation.amazonaws.com"
          ]
        }
      }
    },
    {
      "Sid": "redshiftDataPermissions",
      "Effect": "Allow",
      "Action": [
        "redshift-data:DescribeStatement",
        "redshift-data:GetStatementResult",
        "redshift:DescribeClusters"
      ],
      "Resource": "*"
    },
    {
      "Sid": "dataSharesPermissions",
      "Effect": "Allow",
      "Action": [
        "redshift:AuthorizeDataShare",
        "redshift:DescribeDataShares"
      ],
      "Resource": [
        "arn:aws:redshift:*:*:datashare:*/datazone*"
      ],
      "Condition": {
        "StringEquals": {
          "aws:ResourceAccount": "${aws:PrincipalAccount}"
        }
      }
    },
    {
      "Sid": "associateDataShareConsumerPermission",
      "Effect": "Allow",
      "Action": "redshift:AssociateDataShareConsumer",
      "Resource": "arn:aws:redshift:*:*:datashare:*/datazone*"
    }
  ]
}
