{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://api-evangelist.com/schemas/amazon/rds/instance.json",
  "title": "Amazon RDS DB Instance",
  "description": "Represents an Amazon RDS database instance with its associated configuration, state, endpoint, and metadata.",
  "type": "object",
  "required": ["dBInstanceIdentifier", "dBInstanceClass", "engine", "dBInstanceStatus"],
  "properties": {
    "dBInstanceIdentifier": {
      "type": "string",
      "description": "The user-supplied unique key that identifies the DB instance"
    },
    "dBInstanceClass": {
      "type": "string",
      "description": "The name of the compute and memory capacity class of the DB instance (e.g., db.m5.large, db.r5.xlarge)"
    },
    "engine": {
      "type": "string",
      "description": "The database engine for this DB instance",
      "enum": ["mysql", "postgres", "mariadb", "oracle-ee", "oracle-se2", "sqlserver-ee", "sqlserver-se", "sqlserver-ex", "sqlserver-web", "aurora-mysql", "aurora-postgresql"]
    },
    "engineVersion": {
      "type": "string",
      "description": "The version number of the database engine"
    },
    "dBInstanceStatus": {
      "type": "string",
      "description": "The current state of the DB instance",
      "enum": ["available", "backing-up", "creating", "deleting", "failed", "inaccessible-encryption-credentials", "incompatible-network", "incompatible-option-group", "incompatible-parameters", "incompatible-restore", "maintenance", "modifying", "moving-to-vpc", "rebooting", "renaming", "resetting-master-credentials", "restore-error", "starting", "stopped", "stopping", "storage-full", "storage-optimization", "upgrading"]
    },
    "masterUsername": {
      "type": "string",
      "description": "The master username for the DB instance"
    },
    "dBName": {
      "type": "string",
      "description": "The name of the initial database created when the DB instance was created"
    },
    "endpoint": {
      "$ref": "#/$defs/Endpoint"
    },
    "allocatedStorage": {
      "type": "integer",
      "description": "The allocated storage size in gibibytes (GiB)",
      "minimum": 20,
      "maximum": 65536
    },
    "instanceCreateTime": {
      "type": "string",
      "format": "date-time",
      "description": "The date and time the DB instance was created"
    },
    "preferredBackupWindow": {
      "type": "string",
      "description": "The daily time range during which automated backups are created"
    },
    "backupRetentionPeriod": {
      "type": "integer",
      "description": "The number of days for which automatic DB snapshots are retained",
      "minimum": 0,
      "maximum": 35
    },
    "vpcSecurityGroups": {
      "type": "array",
      "description": "The VPC security groups associated with the DB instance",
      "items": {
        "$ref": "#/$defs/VpcSecurityGroupMembership"
      }
    },
    "availabilityZone": {
      "type": "string",
      "description": "The Availability Zone where the DB instance is located"
    },
    "dBSubnetGroup": {
      "$ref": "#/$defs/DBSubnetGroup"
    },
    "multiAZ": {
      "type": "boolean",
      "description": "Whether the DB instance is a Multi-AZ deployment"
    },
    "autoMinorVersionUpgrade": {
      "type": "boolean",
      "description": "Whether minor version patches are applied automatically"
    },
    "storageType": {
      "type": "string",
      "description": "The storage type associated with the DB instance",
      "enum": ["gp2", "gp3", "io1", "standard"]
    },
    "storageEncrypted": {
      "type": "boolean",
      "description": "Whether the DB instance is encrypted"
    },
    "publiclyAccessible": {
      "type": "boolean",
      "description": "Whether the DB instance is publicly accessible"
    },
    "cACertificateIdentifier": {
      "type": "string",
      "description": "The identifier of the CA certificate for this DB instance"
    },
    "dBInstanceArn": {
      "type": "string",
      "description": "The Amazon Resource Name (ARN) for the DB instance",
      "pattern": "^arn:aws:rds:[a-z0-9-]+:[0-9]{12}:db:.+$"
    },
    "tags": {
      "type": "array",
      "description": "Tags assigned to the DB instance",
      "items": {
        "$ref": "#/$defs/Tag"
      }
    },
    "port": {
      "type": "integer",
      "description": "The port that the DB instance listens on"
    },
    "dBClusterIdentifier": {
      "type": "string",
      "description": "If the DB instance is a member of a DB cluster, the cluster identifier"
    },
    "licenseModel": {
      "type": "string",
      "description": "The license model information for this DB instance"
    }
  },
  "$defs": {
    "Endpoint": {
      "type": "object",
      "description": "The connection endpoint for the DB instance",
      "properties": {
        "address": {
          "type": "string",
          "description": "The DNS address of the DB instance"
        },
        "port": {
          "type": "integer",
          "description": "The port that the DB instance listens on"
        },
        "hostedZoneId": {
          "type": "string",
          "description": "The ID of the hosted zone associated with the DB instance"
        }
      }
    },
    "DBSubnetGroup": {
      "type": "object",
      "description": "Information about the subnet group associated with the DB instance",
      "properties": {
        "dBSubnetGroupName": {
          "type": "string",
          "description": "The name of the DB subnet group"
        },
        "dBSubnetGroupDescription": {
          "type": "string",
          "description": "The description of the DB subnet group"
        },
        "vpcId": {
          "type": "string",
          "description": "The VPC ID of the DB subnet group",
          "pattern": "^vpc-[a-f0-9]{8,17}$"
        },
        "subnetGroupStatus": {
          "type": "string",
          "description": "The status of the DB subnet group"
        },
        "subnets": {
          "type": "array",
          "description": "The subnets that belong to the DB subnet group",
          "items": {
            "type": "object",
            "properties": {
              "subnetIdentifier": {
                "type": "string",
                "description": "The identifier of the subnet",
                "pattern": "^subnet-[a-f0-9]{8,17}$"
              },
              "subnetAvailabilityZone": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "description": "The name of the Availability Zone"
                  }
                }
              },
              "subnetStatus": {
                "type": "string",
                "description": "The status of the subnet"
              }
            }
          }
        }
      }
    },
    "VpcSecurityGroupMembership": {
      "type": "object",
      "description": "Describes a VPC security group membership",
      "properties": {
        "vpcSecurityGroupId": {
          "type": "string",
          "description": "The ID of the VPC security group",
          "pattern": "^sg-[a-f0-9]{8,17}$"
        },
        "status": {
          "type": "string",
          "description": "The membership status of the VPC security group"
        }
      }
    },
    "Tag": {
      "type": "object",
      "description": "Describes a resource tag",
      "properties": {
        "key": {
          "type": "string",
          "description": "The key of the tag",
          "maxLength": 128
        },
        "value": {
          "type": "string",
          "description": "The value of the tag",
          "maxLength": 256
        }
      },
      "required": ["key"]
    }
  }
}
