Glue
Overview
Glue is a serverless AWS offering used for data cataloging, transformation, integration, and orchestration. The Monte Carlo integration is primarily interested in the cataloging features of the Glue Metastore. The Glue Metastore provides Monte Carlo with the databases, tables, and partition information of data stored in AWS S3 Buckets.
How does Monte Carlo use Glue?
The catalog information in Glue powers the Monte Carlo Assets view providing users with
- The ability to discover and explore data assets cataloged by Glue
- Table metadata type, schema, column, and partition information
- Schema monitoring
- Query Engines (Other data lake components rely on the Glue metastore to effectively map their queries to your data assets)
- Discovery of additional Glue catalogs beyond the default
AwsDataCatalog— federated catalogs and Amazon S3 Tables (s3tablescatalog) are auto-discovered from a single metadata connection (databases, tables, columns, and types), with no per-catalog configuration
Databricks with GlueIf you are using Databricks with an external Glue catalog, please follow the Databricks documentation. Setting up Glue as a separate integration is not necessary.
What features are not enabled by a Glue integration?
Monte Carlo monitors a data lake by integrating the entire data lake stack. The Glue metastore is a critical piece of that stack, but does not enable the full suite of data monitoring features on its own. In order to get the best coverage for your data lake you will need to include a Query Engine integration to work in conjunction with Glue. Below is a list of Monte Carlo features that are not available with Glue alone.
- Automated Freshness and Volume Monitoring
- Data monitoring and breach/anomaly alerting
- Query Logs
- Importance scores
- Insight Reports
How does Monte Carlo integrate with Glue?
Monte Carlo reads your Glue metastore with an IAM policy that you control. There are two authentication options:
- IAM assume role (default): you create an IAM role with the Glue policy, and Monte Carlo assumes it. You give Monte Carlo the role ARN and, if you use one, the external ID. This option works with the deployment hosted by Monte Carlo and with the AWS agent, including the proxied AWS agent.
- IAM (agent's role): you attach the same Glue policy to the IAM role your Monte Carlo agent already runs as. There is no role to assume, so you don't enter a role ARN or an external ID. This option is available only when the integration uses an AWS agent, including the proxied AWS agent. See Use the agent's IAM role.
With either option, you also give Monte Carlo the region, the database names, and the S3 buckets you want to monitor.
A generic agent uses neither option: it uses customer-managed credentials, and can still use its own IAM role. See Generic agent: customer-managed credentials.
There are three options to set up the integration with an assumable role:
- The Monte Carlo UI (Option 1), with the optional ability to add an Athena query engine at the same time.
- The Monte Carlo CLI (Option 2) completely automates the infrastructure creation and policy configuration.
- Alternatively (Option 3), you can manually configure the IAM role and policy via the AWS console and then use the CLI to register the integration with Monte Carlo.
To use the agent's role instead, follow Use the agent's IAM role. That option is set up in the Monte Carlo UI only.
Prerequisites
- Permission to create IAM roles and policies in AWS
- Monte Carlo CLI configured with API keys for CLI options (Please follow this guide to install and configure the CLI on your local machine)
Option 1: Use the Monte Carlo UI
The Monte Carlo UI provides a guided setup experience for configuring your Glue integration. You can optionally add an Athena query engine during this process or add one later from the integration details page.
- Navigate to the Integrations page in Monte Carlo, click Add
- Under the Data Lake and Warehouses section, click AWS Glue & Athena
- Provide your AWS account details (Account ID and Region) and configure your Glue connection:
- Specify which databases Monte Carlo should access (all or specific databases)
- Optionally specify S3 data buckets (if not specified, they'll be derived from your tables)
- (Optional) Enable an Athena query engine connection to create monitors on your Glue tables
- Provide a connection name and specify the S3 result bucket for query results
- Optionally configure the workgroup (defaults to
primary) and data catalog (defaults toAwsDataCatalog) - By default, Athena will use the same databases and data buckets configured for Glue. Specify different ones if necessary
- A single Athena connection can monitor tables across all catalogs it has access to — a separate Athena not required
-
An IAM policy will be generated based on your configuration, this policy is configurable and can be modified to fit your security requirements.
The generated policy already includes catalog-discovery permissions (
glue:GetCatalogs), so additional Glue catalogs are discovered automatically. If you use Amazon S3 Tables, add the S3Tables permissions described in Collecting additional Glue catalogs to both the Glue and Athena roles (or to the agent's role, if you use it). - Create an IAM role in AWS with the generated IAM policy (follow the steps outlined in Creating IAM Roles)
- Provide the Role ARN and External ID (if applicable) to complete the connection
To attach the generated policy to your agent's role instead of creating a role, see Use the agent's IAM role.
Option 2: Use the Monte Carlo CLI
The CLI supports the IAM assume role option only: add-glue requires --role. To use the agent's role, use the Monte Carlo UI.
- Generate the Glue access policy
- Create an access role
- Provide role information to Monte Carlo
1. Generate the Glue access policy
- Run
montecarlo discovery glue-policy-gen [parameters] > glue_access_policy.jsonwith the necessary parameters. If the data account is not the same as the collector account, use--resource-aws-regionand--resource-aws-profileto pass
the data account profile.
$ montecarlo discovery glue-policy-gen --help
Usage: montecarlo discovery glue-policy-gen [OPTIONS]
Generate an IAM policy for Glue. After review, output of this command can
be redirected into `montecarlo integrations create-role` or `montecarlo
discovery cf-role-gen` if you prefer IaC.
Options:
--database-name TEXT Glue/Athena database name to generate a policy
from. Enter '\*' to give Monte Carlo access to
all databases. This option can be passed
multiple times for more than one database.
[required]
--data-bucket-name TEXT Name of a S3 bucket storing the data for your
Glue/Athena tables. If this option is not
specified the bucket names are derived (looked
up) from the tables in your databases. This
option can be passed multiple times for more
than one bucket. Enter '\*' to give Monte Carlo
access to all buckets.
--resource-aws-region TEXT Override the AWS region where the resource is
located. Defaults to the region where the
collector is hosted.
--resource-aws-profile TEXT Override the AWS profile use by the CLI for the
resource. This can be helpful if the resource
and collector are in different accounts.
--collector-id UUID ID for the data collector. To disambiguate
accounts with multiple collectors.
--help Show this message and exit.2. Create an access role
- Run
montecarlo integrations create-role glue_access_policy.json. If the data account is not the same as the collector account, use--aws-profileto pass the data account profile. - The command prints a role ARN and an external id, they are used in the next section.
$ montecarlo integrations create-role --help
Usage: montecarlo integrations create-role [OPTIONS] FILE
Create an IAM role from a policy FILE. The returned role ARN and external
id should be used for adding lake assets.
Options:
--aws-profile TEXT Override the AWS profile used by the CLI, which
determines where the role is created. This can be
helpful when the account that manages the asset is not
the same as the collector.
--help Show this message and exit.3. Provide role information to Monte Carlo
- Run
montecarlo integrations add-gluewith the necessary parameters.
$ montecarlo integrations add-glue --help
Usage: montecarlo integrations add-glue [OPTIONS]
Setup a Glue integration. For metadata.
Options:
--region TEXT Glue catalog region. If not specified the region the
collector is deployed in is used.
--role TEXT Assumable role ARN to use for accessing AWS resources.
[required]
--external-id TEXT An external id, per assumable role conditions.
--name TEXT Friendly name for the created warehouse. Name must be
unique.
--collector-id UUID ID for the data collector. To disambiguate accounts
with multiple collectors.
--skip-validation Skip all connection tests. This option cannot be used
with 'validate-only'.
--validate-only Run connection tests without adding. This option cannot
be used with 'skip-validation'.
--auto-yes Skip any interactive approval.
--option-file FILE Read configuration from FILE.
--help Show this message and exit.Option 3: Use the AWS UI
1. Create an access role
- Follow the steps outlined in Creating IAM Roles to create a role with the policy below, replacing the values REGION, ACCOUNT_ID, S3_ARN (of the S3 bucket(s) storing the data for your Glue/Athena tables
- you can alternatively pass
"*"to give access to all buckets), and DATABASE_NAME.
- The role ARN and external ID should be saved to be used in the next step.
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:ListBucket",
"s3:GetBucketLocation"
],
"Resource": [
"<S3_ARN>"
]
},
{
"Effect": "Allow",
"Action": "glue:GetConnections",
"Resource": [
"arn:aws:glue:<REGION>:<ACCOUNT_ID>:catalog",
"arn:aws:glue:<REGION>:<ACCOUNT_ID>:connection/*"
]
},
{
"Effect": "Allow",
"Action": "glue:GetCatalogs",
"Resource": [
"arn:aws:glue:<REGION>:<ACCOUNT_ID>:catalog",
"arn:aws:glue:<REGION>:<ACCOUNT_ID>:catalog/*"
]
},
{
"Effect": "Allow",
"Action": "glue:GetDatabases",
"Resource": [
"arn:aws:glue:<REGION>:<ACCOUNT_ID>:catalog",
"arn:aws:glue:<REGION>:<ACCOUNT_ID>:catalog/*",
"arn:aws:glue:<REGION>:<ACCOUNT_ID>:database/<DATABASE_NAME>"
]
},
{
"Effect": "Allow",
"Action": [
"glue:GetTables",
"glue:GetTable",
"glue:GetPartitions",
"glue:GetPartition"
],
"Resource": [
"arn:aws:glue:<REGION>:<ACCOUNT_ID>:catalog",
"arn:aws:glue:<REGION>:<ACCOUNT_ID>:catalog/*",
"arn:aws:glue:<REGION>:<ACCOUNT_ID>:database/<DATABASE_NAME>",
"arn:aws:glue:<REGION>:<ACCOUNT_ID>:table/<DATABASE_NAME>/*"
]
}
]
}2. Provide role information to Monte Carlo
- Run
montecarlo integrations add-gluewith the necessary parameters.
$ montecarlo integrations add-glue --help
Usage: montecarlo integrations add-glue [OPTIONS]
Setup a Glue integration. For metadata.
Options:
--region TEXT Glue catalog region. If not specified the region the
collector is deployed in is used.
--role TEXT Assumable role ARN to use for accessing AWS resources.
[required]
--external-id TEXT An external id, per assumable role conditions.
--name TEXT Friendly name for the created warehouse. Name must be
unique.
--collector-id UUID ID for the data collector. To disambiguate accounts
with multiple collectors.
--skip-validation Skip all connection tests. This option cannot be used
with 'validate-only'.
--validate-only Run connection tests without adding. This option cannot
be used with 'skip-validation'.
--auto-yes Skip any interactive approval.
--option-file FILE Read configuration from FILE.
--help Show this message and exit.Use the agent's IAM role
With the IAM (agent's role) option, Monte Carlo uses the IAM role your agent already runs as. You attach the Glue policy to that role, and there is no role for Monte Carlo to assume.
When you can use it
- The integration must use an AWS agent, including the proxied AWS agent.
- A deployment hosted by Monte Carlo can't use the agent's role. It always uses an assumable role.
- A generic agent can't use this option. It uses customer-managed credentials, which can also use the agent's own role.
- The agent's role reads the Glue catalog in the agent's own AWS account. If your Glue catalog is in another account, use the IAM assume role option.
1. Find the agent's role
-
AWS agent: the agent's Lambda function execution role. For a CloudFormation deployment, it is the
ExecutionRoleresource of the agent stack. You can also read it from the function:aws lambda get-function-configuration --function-name <agent-function-name> --query Role --output text -
Proxied AWS agent: the IAM role attached to the infrastructure the agent runs on, for example the ECS task role. It is the role you created for the agent's storage bucket and log group.
2. Attach the Glue policy to the agent's role
Attach the policy from Option 3 to the agent's role, replacing the placeholders, or the policy that the Monte Carlo UI generates for you. Use the AWS Console, the AWS CLI, or your infrastructure as code. If you also add an Athena connection, attach the Athena policy to the same role.
You don't need a trust policy, an external ID, or the MonteCarloData tag for this option.
3. Connect in the Monte Carlo UI
- Navigate to the Integrations page in Monte Carlo, click Add.
- Under the Data Lake and Warehouses section, click AWS Glue & Athena.
- Select the AWS agent deployment to use for this integration.
- For Authentication type, choose IAM (agent's role). This choice applies to both the Glue connection and the Athena connection.
- Enter the AWS Account ID and Region, and configure your Glue connection and, optionally, your Athena connection as in Option 1. You don't enter a role ARN or an external ID.
- Test the connection, then save.
To add Athena later, open the Glue integration's details page. The Athena form has the same Authentication type selector. To move an existing Glue or Athena connection to the agent's role, edit the connection and change Authentication type.
If you get an access denied error, see Access denied for the agent's role.
Private networking
If the agent reaches AWS through private networking (a VPC without internet access), the agent's VPC needs VPC endpoints with private DNS for:
- Glue (
com.amazonaws.<region>.glue) - Athena (
com.amazonaws.<region>.athena), if you add an Athena connection - S3 (
com.amazonaws.<region>.s3) - STS (
com.amazonaws.<region>.sts), only if a role is assumed (the IAM assume role option, or a role ARN in a customer-managed secret) or the agent gets its credentials through EKS IRSA. The agent calls the regional STS endpoint, so assuming a role works over the private path. - Secrets Manager (
com.amazonaws.<region>.secretsmanager), only for customer-managed credentials stored in AWS Secrets Manager
Generic agent: customer-managed credentials
A generic agent can't use the IAM assume role or IAM (agent's role) options, because Monte Carlo doesn't hold credentials for integrations on a generic agent. Instead, you store the connection settings in a secret that the agent reads at runtime, as described in Self-hosted credentials.
The secret decides which role the agent uses:
- No role ARN in the secret: the agent uses its own IAM role. This is the direct option for a generic agent: attach the Glue policy to the agent's role.
- A role ARN (and, if you use one, an external ID) in the secret: the agent assumes that role. Create the role with the Glue policy as in Option 3, and allow the agent's role to assume it.
1. Find the generic agent's role
- Amazon EKS: the role associated with the agent's Kubernetes service account through EKS Pod Identity or IRSA. With the EKS Terraform module, it is the
agent_role_arnoutput. - Amazon ECS: the task role of the agent's task definition (not the task execution role).
- Amazon EC2 (for example with Docker Compose): the role of the instance profile.
- Outside AWS: the agent has no AWS role of its own. Give it AWS credentials, such as access keys, and use the identity those credentials belong to.
This is the same role that reads the agent's object storage and secrets on AWS.
2. Grant the permissions
Attach the policy from Option 3 to the agent's role, or to the role named in the secret, replacing the placeholders. If you also add an Athena connection, attach the Athena policy as well. If you store the secret in AWS Secrets Manager, the agent's role also needs secretsmanager:GetSecretValue on the secret, as described in Self-hosted credentials.
3. Store the connection settings
Store the settings in a secret store the agent supports, following Self-hosted credentials. One secret serves both the Glue connection and the Athena connection:
connect_args(required): wraps the settings below.aws_region(optional, recommended): the region of your Glue catalog and Athena workgroup. Without it, the agent uses itsAWS_REGIONenvironment variable, and the connection fails if that isn't set.assumable_role(optional): the ARN of a role for the agent to assume. Leave it out to use the agent's own role.external_id(optional): the external ID in the role's trust policy. Use it only withassumable_role.
The Athena workgroup and data catalog don't go in the secret. You enter them in the Monte Carlo form.
{
"connect_args": {
"aws_region": "us-east-1"
}
}{
"connect_args": {
"aws_region": "us-east-1",
"assumable_role": "arn:aws:iam::123456789012:role/example",
"external_id": "example-external-id"
}
}4. Connect in the Monte Carlo UI
- Navigate to the Integrations page in Monte Carlo, click Add.
- Under the Data Lake and Warehouses section, click AWS Glue & Athena.
- Select Customer managed credentials, then select the generic agent deployment. When you select a generic agent, the form switches to customer managed credentials on its own.
- Choose the secret store, for example AWS Secrets Manager, and enter the secret's reference.
- Configure your Glue connection and, optionally, your Athena connection, as in Option 1.
- Test the connection, then save.
To add Athena later, open the Glue integration's details page. Editing a connection saved with customer managed credentials opens the same customer managed form.
The private networking endpoints are the same as for the IAM (agent's role) option. If the secret is in AWS Secrets Manager, the agent's VPC also needs a Secrets Manager endpoint (com.amazonaws.<region>.secretsmanager).
Collecting additional Glue catalogs (Amazon S3 Tables & federated)
Monte Carlo auto-discovers all Glue catalogs from a single metadata connection: the default AwsDataCatalog, federated catalogs, and Amazon S3 Tables (s3tablescatalog, one child catalog per S3 table bucket). The glue:GetCatalogs and nested catalog/* permissions in the policies above enable this; without them, collection covers only the default catalog.
Amazon S3 Tables additionally requires S3 Tables permissions, because Glue federates the catalog to the S3 Tables service. These are an opt-in add-on — grant them only if you use S3 Tables. With the IAM assume role option, a Data Lake integration has two roles, and each
needs its own additions:
Metadata (Glue) role — to discover & collect:
{
"Effect": "Allow",
"Action": [
"s3tables:GetTableBucket",
"s3tables:ListNamespaces",
"s3tables:GetNamespace",
"s3tables:ListTables",
"s3tables:GetTable",
"s3tables:GetTableMetadataLocation"
],
"Resource": "arn:aws:s3tables:<REGION>:<ACCOUNT_ID>:bucket/*"
},
{
"Effect": "Allow",
"Action": "s3tables:ListTableBuckets",
"Resource": "*"
},
{
"Effect": "Allow",
"Action": "lakeformation:GetDataAccess",
"Resource": "*"
}Athena (query) role — to monitor & query: the same as above plus s3tables:GetTableData (to read table data):
{
"Effect": "Allow",
"Action": [
"s3tables:GetTableBucket",
"s3tables:ListNamespaces",
"s3tables:GetNamespace",
"s3tables:ListTables",
"s3tables:GetTable",
"s3tables:GetTableMetadataLocation",
"s3tables:GetTableData"
],
"Resource": "arn:aws:s3tables:<REGION>:<ACCOUNT_ID>:bucket/*"
},
{
"Effect": "Allow",
"Action": "s3tables:ListTableBuckets",
"Resource": "*"
},
{
"Effect": "Allow",
"Action": "lakeformation:GetDataAccess",
"Resource": "*"
}
s3tables:ListTableBucketsis required for discovery. Without it, only the top-levels3tablescatalogis found, not the per-bucket catalogs that hold your tables.- S3 Tables access is governed by these
s3tablesIAM actions pluslakeformation:GetDataAccess. If your account enforces AWS Lake Formation on the catalog, also grant the role Lake FormationDESCRIBE/SELECTon the S3 Tables catalog.- With the IAM assume role option, the metadata (Glue) role and the Athena (query) role are separate roles: grant the S3 Tables permissions to each. With the agent's role, both connections use the agent's role, so grant the Athena (query) set to it.
Troubleshooting
Validation error
User: arn:aws:iam::<aws_account_id>:user/<user> is not authorized to perform: <action> on resource: arn:aws:glue:<region>:<aws_account_id>:<resource>Potential Causes
- AWS policy is not attached to a Role
- Policy is misconfigured. This often happens when the policy is created by hand. Try generating the policy with the Monte Carlo UI (Option 1) or CLI (Option 2) and performing a diff between your policy and the generated one
- A resource policy (e.g. bucket policy) is denying access
- Other types of policies are denying access, see AWS doc, but keep in mind that this is less likely, things like permission boundaries are not common.
CATALOG_NOT_FOUND when creating or running a monitor
CATALOG_NOT_FOUND when creating or running a monitorCATALOG_NOT_FOUND: line 2:15: Catalog 's3tablescatalog/<bucket>' does not existThe Athena query connection's role is missing S3 Tables access. Lake Formation hides catalogs the principal can't reach, so Athena reports them as non-existent rather than access-denied. Grant the Athena role the S3 Tables permissions in
Collecting additional Glue catalogs. With the IAM assume role option, note that this is a different role from the Glue metadata connection: both need the grants.
AccessDenied for s3tablescatalog in the collection logs
s3tablescatalog in the collection logsIf you don't use Amazon S3 Tables and haven't granted the S3 Tables permissions, collections can log an AccessDenied for the s3tablescatalog catalog. It is harmless: the other catalogs are still collected. Grant the permissions in Collecting additional Glue catalogs only if you use S3 Tables.
Access denied for the agent's role
The connection test checks the Glue permissions, so a missing permission fails the test with an AccessDenied that names the action, such as glue:GetDatabases. When the agent uses its own role (the IAM (agent's role) option, or customer-managed credentials with no role ARN), the error names the agent's role:
User: arn:aws:sts::123456789012:assumed-role/<agent-role>/<session> is not authorized to perform: glue:GetDatabases on resource: arn:aws:glue:<region>:123456789012:catalogPotential Causes
- The Glue policy is not attached to the agent's role, or it is attached to a different role. On ECS, attach it to the task role, not the task execution role. For a generic agent on EKS, attach it to the service account's role, not the node role.
- The policy's account ID, region, database names, or buckets don't match your resources.
- The Glue catalog is in a different AWS account from the agent. Use the IAM assume role option for that case.
- A resource policy, permission boundary, or service control policy denies access.
The test fails right after you change IAM policies or create VPC endpoints
AWS takes a short time to apply these changes: usually seconds for an IAM policy, and a few minutes for a new VPC endpoint. A test run in that window can fail with an access or connection error. Wait, then run the test again.
IAM (agent's role) is not available for this deployment
The IAM (agent's role) option works only with an AWS agent, including the proxied AWS agent. It is not available on the deployment hosted by Monte Carlo or on a generic agent.
- Deployment hosted by Monte Carlo: use the IAM assume role option.
- Generic agent: use customer-managed credentials. With no role ARN in the secret, the agent uses its own IAM role.
Assume role error
User: arn:aws:sts::<dc_account_id>:assumed-role/<role> is not authorized to perform: sts:AssumeRole on resource: arn:aws:iam::<data_account_id>:role/<role>Potential Causes
- The role was created under the wrong AWS account. The IAM role must exist in the same account as Glue
- The trust relationship account is wrong - the account in the trust relationship must be the data collector account
- A trust relationship is missing (step 2 of Creating a role for Monte Carlo's data collector)
- The MonteCarloData tag is missing or contains a value - value must be absent (step 7 of Creating a role for Monte Carlo's data collector)
Connection timeout to https://sts.amazonaws.com/
https://sts.amazonaws.com/If you're using an AWS agent with the IAM assume role option and getting this error:
Connect timeout on endpoint URL: "https://sts.amazonaws.com/"
This is probably caused by the agent running on a VPC without Internet access, you need to:
-
Add a VPCE (Private Endpoint) to the VPC hosting the agent for the "STS" service (
com.amazonaws.<region>.sts) and enable "Private DNS" for it. -
If the URL in the error is "sts.amazonaws.com" instead of "sts.[region].amazonaws.com" you also need to add the following environment variable to the Lambda Function for the agent:
AWS_STS_REGIONAL_ENDPOINTS=regional
Updated about 17 hours ago
