- Newest
- Most votes
- Most comments
To update the columns of a Glue table defined in a CloudFormation template, you need to include the table name in your TableInput properties. When you're updating an existing table, you must specify the same table name that was created during the initial deployment.
The issue you're encountering is related to how CloudFormation handles updates to AWS Glue tables. When you don't specify a name in the TableInput properties, CloudFormation generates one using the resource name with a random suffix. During updates, you need to maintain this name.
Here's how to fix your template:
-
First, retrieve the actual name of the deployed table from the AWS Glue console or using AWS CLI.
-
Then, add this name to your TableInput properties in the CloudFormation template:
"TableInput": {
"Name": "your-actual-table-name",
"TableType": "EXTERNAL_TABLE",
...
}
- When you update the stack with this modified template, CloudFormation will update the existing table rather than trying to create a new one.
This approach allows you to add, modify, or remove columns while maintaining the same table. The key is ensuring the Name property in TableInput matches exactly with the deployed table name.
If you're still encountering issues, you might need to use the VersionId parameter in your update operation, which specifies the version ID at which to update the table contents. However, this is typically not required for simple column additions.
Sources
UpdateTable - AWS Glue
Work with CSV data in AWS Glue - Amazon Athena
Examples of CloudFormation stack operation commands for the AWS CLI and PowerShell - AWS CloudFormation
answered a year ago

I've don't experience the behaviour as described. I updated the TableInput section of the template, and performed a direct update of the stack using the CloudFormation console. The update failed with a "Table already exists." error.