Skip to main content
Glama

get_resource_version_compatibility

Verify resource compatibility across Terraform provider versions by inputting provider, resource, and target version details to ensure alignment and prevent errors in Infrastructure-as-Code deployments.

Instructions

Check resource compatibility across provider versions

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
provider_nameYesName of the Terraform provider
resource_nameYesName of the resource to check
versionYesTarget provider version to check compatibility against

Implementation Reference

  • JSON schema definition for the 'get_resource_version_compatibility' tool, specifying input parameters and description.
    "get_resource_version_compatibility": { "type": "object", "description": "Check resource compatibility across provider versions", "required": ["provider_name", "resource_name", "version"], "properties": { "provider_name": { "type": "string", "description": "Name of the Terraform provider", }, "resource_name": { "type": "string", "description": "Name of the resource to check", }, "version": { "type": "string", "description": "Target provider version to check compatibility against", }, }, },
  • Core helper function that implements the compatibility checking logic for Terraform resources across different provider versions by querying database schemas and comparing required fields and property types.
    def check_resource_version_compatibility( db: DatabaseManager, provider_name: str, resource_name: str, version: str ) -> Dict: """Check resource compatibility across provider versions. Args: db: Database manager instance provider_name: Name of the provider resource_name: Name of the resource version: Target provider version to check against Returns: Dictionary containing compatibility status and potential issues """ logger.info( "Checking resource version compatibility", extra={ "provider": provider_name, "resource": resource_name, "target_version": version, "operation": "check_resource_version_compatibility", }, ) try: with db.get_connection() as conn: # Get resource info for current version current = conn.execute( """ SELECT r.*, p.version as provider_version FROM terraform_resources r JOIN terraform_providers p ON r.provider_id = p.id WHERE p.name = ? AND r.name = ? ORDER BY p.created_at DESC LIMIT 1 """, (provider_name, resource_name), ).fetchone() if not current: raise ValueError( f"Resource {resource_name} not found for provider {provider_name}" ) # Get resource info for target version target = conn.execute( """ SELECT r.*, p.version as provider_version FROM terraform_resources r JOIN terraform_providers p ON r.provider_id = p.id WHERE p.name = ? AND r.name = ? AND p.version = ? """, (provider_name, resource_name, version), ).fetchone() if not target: return { "is_compatible": False, "current_version": current["provider_version"], "target_version": version, "issues": [ f"Resource {resource_name} not found in provider version {version}" ], } # Compare schemas to determine compatibility import json current_schema = json.loads(current["schema"]) target_schema = json.loads(target["schema"]) issues = [] # Check for removed required fields current_required = set(current_schema.get("required", [])) target_required = set(target_schema.get("required", [])) removed_required = current_required - target_required if removed_required: issues.append( f"Required fields removed in target version: {', '.join(removed_required)}" ) # Check for changed field types current_props = current_schema.get("properties", {}) target_props = target_schema.get("properties", {}) for field, props in current_props.items(): if field in target_props: if props.get("type") != target_props[field].get("type"): issues.append( f"Field type changed for '{field}': " f"{props.get('type')} -> {target_props[field].get('type')}" ) return { "is_compatible": len(issues) == 0, "current_version": current["provider_version"], "target_version": version, "issues": issues if issues else ["No compatibility issues found"], } except sqlite3.Error as e: error_msg = f"Failed to check resource compatibility: {str(e)}" logger.error(error_msg) raise DatabaseError(error_msg)

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/AgentWong/iac-memory-mcp-server-project'

If you have feedback or need assistance with the MCP directory API, please join our Discord server