Analyze terraform template files to return infrastructure cost
Usually, the code is a bit worse, indentation-wise:

if res, ok := decodedOutput["resource"].([]map[string]interface{}); ok {
    for _, resource := range res {
        for key := range resource {
            switch key {
            case "aws_instance":
                if rk, ok := resource[key].([]map[string]interface{}); ok {
                    for resourceKey := range rk[0] {
                        if itype, ok := resourceKeys[0][resourceKey].([]map[string]interface{}); ok {
                            if d, ok := itype[0]["instance_type"].(string); ok {
                                masterResourceMap = countResource(masterResourceMap, key, d)
                            }
                        }
                    }
                }

            default:
                fmt.Println("resource type not recognized: ", key)
            }
        }
    }
}


Now, from a Terraform point-of-view, you already have a semi-assurance that the type you're trying to cast has been cleaned up, this due to how you declare the values of the terraform file. You usually define it with the schema package, so while it's running, you know Terraform already checked the types for you. 

The overall I've seen is that providers, for example, do not tests against a true type casting from interfaces, again, due to Terraform pre-checking the information to match the schema definition, so if it is a string but someone passed an int, then Terraform will exit and fail way earlier than reaching your type casting.