Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Move to terraform-json (CLI Schema) internally #262

Open
turkenh opened this issue Mar 14, 2022 · 3 comments
Open

Move to terraform-json (CLI Schema) internally #262

turkenh opened this issue Mar 14, 2022 · 3 comments
Labels
enhancement New feature or request wontfix This will not be worked on

Comments

@turkenh
Copy link
Member

turkenh commented Mar 14, 2022

What problem are you facing?

Recently we introduced generating resources from CLI schema with a conversion function which still converts input schema to SDK v2 schema. This was originally done to gradually move to the new schema and make sure it works fine.

We should completely move to terraform-json (CLI Schema) also as an internal representation to get rid of conversions and simplify the codebase.

How could Terrajet help solve your problem?

Use terraform-json as internal representation and remove dependency to Terraform SDK v2.

@turkenh turkenh added the enhancement New feature or request label Mar 14, 2022
@ezgidemirel
Copy link
Member

Here is the MSSQL DB server schema:

"azurerm_mssql_database": {
  "version": 1,
  "block": {
    "attributes": {
      "auto_pause_delay_in_minutes": {
        "type": "number",
        "description_kind": "plain",
        "optional": true,
        "computed": true
      },
      "collation": {
        "type": "string",
        "description_kind": "plain",
        "optional": true,
        "computed": true
      },
      "create_mode": {
        "type": "string",
        "description_kind": "plain",
        "optional": true
      },
      "creation_source_database_id": {
        "type": "string",
        "description_kind": "plain",
        "optional": true,
        "computed": true
      },
      "elastic_pool_id": {
        "type": "string",
        "description_kind": "plain",
        "optional": true
      },
      "extended_auditing_policy": {
        "type": [
          "list",
          [
            "object",
            {
              "log_monitoring_enabled": "bool",
              "retention_in_days": "number",
              "storage_account_access_key": "string",
              "storage_account_access_key_is_secondary": "bool",
              "storage_endpoint": "string"
            }
          ]
        ],
        "description_kind": "plain",
        "deprecated": true,
        "optional": true,
        "computed": true
      },
      "geo_backup_enabled": {
        "type": "bool",
        "description_kind": "plain",
        "optional": true
      },
      "id": {
        "type": "string",
        "description_kind": "plain",
        "optional": true,
        "computed": true
      },
      "license_type": {
        "type": "string",
        "description_kind": "plain",
        "optional": true,
        "computed": true
      },
      "max_size_gb": {
        "type": "number",
        "description_kind": "plain",
        "optional": true,
        "computed": true
      },
      "min_capacity": {
        "type": "number",
        "description_kind": "plain",
        "optional": true,
        "computed": true
      },
      "name": {
        "type": "string",
        "description_kind": "plain",
        "required": true
      },
      "read_replica_count": {
        "type": "number",
        "description_kind": "plain",
        "optional": true,
        "computed": true
      },
      "read_scale": {
        "type": "bool",
        "description_kind": "plain",
        "optional": true,
        "computed": true
      },
      "recover_database_id": {
        "type": "string",
        "description_kind": "plain",
        "optional": true
      },
      "restore_dropped_database_id": {
        "type": "string",
        "description_kind": "plain",
        "optional": true
      },
      "restore_point_in_time": {
        "type": "string",
        "description_kind": "plain",
        "optional": true,
        "computed": true
      },
      "sample_name": {
        "type": "string",
        "description_kind": "plain",
        "optional": true,
        "computed": true
      },
      "server_id": {
        "type": "string",
        "description_kind": "plain",
        "required": true
      },
      "sku_name": {
        "type": "string",
        "description_kind": "plain",
        "optional": true,
        "computed": true
      },
      "storage_account_type": {
        "type": "string",
        "description_kind": "plain",
        "optional": true
      },
      "tags": {
        "type": [
          "map",
          "string"
        ],
        "description_kind": "plain",
        "optional": true
      },
      "zone_redundant": {
        "type": "bool",
        "description_kind": "plain",
        "optional": true,
        "computed": true
      }
    },
    "block_types": {
      "long_term_retention_policy": {
        "nesting_mode": "list",
        "block": {
          "attributes": {
            "monthly_retention": {
              "type": "string",
              "description_kind": "plain",
              "optional": true,
              "computed": true
            },
            "week_of_year": {
              "type": "number",
              "description_kind": "plain",
              "optional": true,
              "computed": true
            },
            "weekly_retention": {
              "type": "string",
              "description_kind": "plain",
              "optional": true,
              "computed": true
            },
            "yearly_retention": {
              "type": "string",
              "description_kind": "plain",
              "optional": true,
              "computed": true
            }
          },
          "description_kind": "plain"
        },
        "max_items": 1
      },
      "short_term_retention_policy": {
        "nesting_mode": "list",
        "block": {
          "attributes": {
            "retention_days": {
              "type": "number",
              "description_kind": "plain",
              "required": true
            }
          },
          "description_kind": "plain"
        },
        "max_items": 1
      },
      "threat_detection_policy": {
        "nesting_mode": "list",
        "block": {
          "attributes": {
            "disabled_alerts": {
              "type": [
                "set",
                "string"
              ],
              "description_kind": "plain",
              "optional": true
            },
            "email_account_admins": {
              "type": "string",
              "description_kind": "plain",
              "optional": true
            },
            "email_addresses": {
              "type": [
                "set",
                "string"
              ],
              "description_kind": "plain",
              "optional": true
            },
            "retention_days": {
              "type": "number",
              "description_kind": "plain",
              "optional": true
            },
            "state": {
              "type": "string",
              "description_kind": "plain",
              "optional": true
            },
            "storage_account_access_key": {
              "type": "string",
              "description_kind": "plain",
              "optional": true,
              "sensitive": true
            },
            "storage_endpoint": {
              "type": "string",
              "description_kind": "plain",
              "optional": true
            },
            "use_server_default": {
              "type": "string",
              "description_kind": "plain",
              "optional": true
            }
          },
          "description_kind": "plain"
        },
        "max_items": 1
      },
      "timeouts": {
        "nesting_mode": "single",
        "block": {
          "attributes": {
            "create": {
              "type": "string",
              "description_kind": "plain",
              "optional": true
            },
            "delete": {
              "type": "string",
              "description_kind": "plain",
              "optional": true
            },
            "read": {
              "type": "string",
              "description_kind": "plain",
              "optional": true
            },
            "update": {
              "type": "string",
              "description_kind": "plain",
              "optional": true
            }
          },
          "description_kind": "plain"
        }
      }
    },
    "description_kind": "plain"
  }
}

As you can see, we cannot identify if "storage_account_access_key" is sensitive or not:

      "extended_auditing_policy": {
        "type": [
          "list",
          [
            "object",
            {
              "log_monitoring_enabled": "bool",
              "retention_in_days": "number",
              "storage_account_access_key": "string",
              "storage_account_access_key_is_secondary": "bool",
              "storage_endpoint": "string"
            }
          ]
        ],
        "description_kind": "plain",
        "deprecated": true,
        "optional": true,
        "computed": true
      },

@ezgidemirel
Copy link
Member

In provider-jet-aws, we noticed that some of the required fields are not marked with required: "true" in cli schema which causes information lost in CRDs. You may check EC2 securitygroups as an example.

@stale
Copy link

stale bot commented Aug 13, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants