PSTerraformParser-Classes.psm1

class attributevalue {
    [attributetype] $type
    [string] $value

    attributevalue([string]$data) {
        if ($data -eq "<computed>") {
            $this.type = [attributetype]::computed
        } elseif ($data -like '"*') {
            $this.type = [attributetype]::string
            $this.value = $data.trim('"')
        } else {
            $this.type = [attributetype]::unknown
            $this.value = $data
        }
    }
}

enum attributetype {
    unknown
    string
    computed
}
class change {
    [string] $module
    [action] $action
    [string] $type
    [string] $name
    [string] $path
    [hashtable] $changedAttributes
    [bool] $newResourceRequired
    [bool] $tainted
}

enum action {
    create
    destroy
    replace
    update
    read
}

class changedattribute {
    [attributevalue] $old
    [attributevalue] $new
    [bool] $forcesNewResource
}
class error {
    [string] $code
    [string] $message
}

class terraformplan {
    [error[]] $errors
    [change[]] $changedResources
    [change[]] $changedDataSources
}