{
    "AWSTemplateFormatVersion": "2010-09-09",
    "Parameters": {
    },
    "Resources": {
      "adminconsoledb": {
          "Type": "AWS::Glue::Database",
          "Properties": {
              "CatalogId": {
                  "Ref": "AWS::AccountId"
              },
              "DatabaseInput": {
                  "Name": "admin-console"
              }
          }
  },
      "groupmembership": {"Type": "AWS::Glue::Table",
      "Properties": {
        "CatalogId": {
          "Ref": "AWS::AccountId"
        },
        "DatabaseName":  {"Ref": "adminconsoledb"},
        "TableInput": {
          "Description": "group and user information which is generated by the data_prepare lambda function",
          "Name": "group_membership",
          "Parameters": {
            "has_encrypted_data": false,
            "classification": "csv",
            "areColumnsQuoted": "false",
            "typeOfData": "file",
            "columnsOrdered": "true",
            "delimiter": ","
          },
          "StorageDescriptor": {
            "Columns": [
              {
                "Comment": "aws account_id",
                "Name": "account_id",
                "Type": "string"
              },
              {
                "Comment": "quicksight namespace",
                "Name": "namespace",
                "Type": "string"
              },
              {
                "Comment": "quicksight group",
                "Name": "group",
                "Type": "string"
              },
              {
                "Comment": "quicksight user",
                "Name": "user",
                "Type": "string"
              },
              {
                "Comment": "email of quicksight user",
                "Name": "email",
                "Type": "string"
              },
              {
                "Comment": "role of quicksight user: admin, author, reader",
                "Name": "role",
                "Type": "string"
              },
              {
                "Comment": "identity_type of quicksight user: IAM, quicksight",
                "Name": "identity_type",
                "Type": "string"
              }
            ],
            "Compressed": false,
            "InputFormat": "org.apache.hadoop.mapred.TextInputFormat",
            "Location": "value of groupmembership in Lambda stack",
            "OutputFormat": "org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat",
            "SerdeInfo": {
              "Parameters": {
                "field.delim": ","
              },
              "SerializationLibrary": "org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe"
            },
            "StoredAsSubDirectories": false
          },
          "TableType": "EXTERNAL_TABLE"
        }
      }
    },
      "objectaccess": {"Type": "AWS::Glue::Table",
  "Properties": {
    "CatalogId": {
      "Ref": "AWS::AccountId"
    },
    "DatabaseName": {"Ref": "adminconsoledb"},
    "TableInput": {
      "Description": "objects and access information which is generated by the data_prepare lambda function",
      "Name": "object_access",
      "Parameters": {
        "has_encrypted_data": false,
        "classification": "csv",
        "areColumnsQuoted": "false",
        "typeOfData": "file",
        "columnsOrdered": "true",
        "delimiter": ","
      },
      "StorageDescriptor": {
        "Columns": [
          {
            "Comment": "aws account_id",
            "Name": "account_id",
            "Type": "string"
          },
          {
            "Comment": "aws region name",
            "Name": "aws_region",
            "Type": "string"
          },
          {
            "Comment": "quicksight object type: dashboard, dataset and etc..",
            "Name": "object_type",
            "Type": "string"
          },
          {
            "Comment": "quicksight object name",
            "Name": "object_name",
            "Type": "string"
          },
          {
            "Comment": "quicksight object id",
            "Name": "object_id",
            "Type": "string"
          },
          {
            "Comment": "quicksight principal type",
            "Name": "principal_type",
            "Type": "string"
          },
          {
            "Comment": "quicksight principal name",
            "Name": "principal_name",
            "Type": "string"
          },
          {
            "Comment": "quicksight namespace",
            "Name": "namespace",
            "Type": "string"
          },
          {
            "Comment": "access permissions of quicksight objects: who can do what on a dashboard",
            "Name": "permissions",
            "Type": "string"
          }
        ],
        "Compressed": false,
        "InputFormat": "org.apache.hadoop.mapred.TextInputFormat",
        "Location": "value of objectaccess in Lambda stack outputs",
        "OutputFormat": "org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat",
        "SerdeInfo": {
              "Parameters": {
                "field.delim": ","
              },
              "SerializationLibrary": "org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe"
            },
        "StoredAsSubDirectories": false
      },
      "TableType": "EXTERNAL_TABLE"
    }
  }
},
      "cloudtraillog": {"Type": "AWS::Glue::Table",
"Properties": {
"CatalogId": {
  "Ref": "AWS::AccountId"
},
"DatabaseName": {"Ref": "adminconsoledb"},
"TableInput": {
  "Description": "cloudtrail logs",
  "Name": "value of ccloudtraillogtablename in Lambda stack outputs",
  "Parameters": {
    "classification": "cloudtrail"
  },
  "StorageDescriptor": {
    "Columns": [
      {
        "Comment": "eventversion",
        "Name": "eventversion",
        "Type": "string"
      },
      {
        "Comment": "useridentity",
        "Name": "useridentity",
        "Type": "struct<type:string,principalid:string,arn:string,accountid:string,invokedby:string,accesskeyid:string,username:string,sessioncontext:struct<attributes:struct<mfaauthenticated:string,creationdate:string>,sessionissuer:struct<type:string,principalid:string,arn:string,accountid:string,username:string>>>"
      },
      {
        "Comment": "eventtime",
        "Name": "eventtime",
        "Type": "string"
      },
      {
        "Comment": "eventsource",
        "Name": "eventsource",
        "Type": "string"
      },
      {
        "Comment": "eventname",
        "Name": "eventname",
        "Type": "string"
      },
      {
        "Comment": "awsregion",
        "Name": "awsregion",
        "Type": "string"
      },
      {
        "Comment": "sourceipaddress",
        "Name": "sourceipaddress",
        "Type": "string"
      },
      {
        "Comment": "useragent",
        "Name": "useragent",
        "Type": "string"
      },
      {
        "Comment": "errorcode",
        "Name": "errorcode",
        "Type": "string"
      },
      {
        "Comment": "errormessage",
        "Name": "errormessage",
        "Type": "string"
      },
      {
        "Comment": "requestparameters",
        "Name": "requestparameters",
        "Type": "string"
      },
      {
        "Comment": "responseelements",
        "Name": "responseelements",
        "Type": "string"
      },
      {
        "Comment": "additionaleventdata",
        "Name": "additionaleventdata",
        "Type": "string"
      },
      {
        "Comment": "requestid",
        "Name": "requestid",
        "Type": "string"
      },
      {
        "Comment": "eventid",
        "Name": "eventid",
        "Type": "string"
      },
      {
        "Comment": "resources",
        "Name": "resources",
        "Type": "array<struct<arn:string,accountid:string,type:string>>"
      },
      {
        "Comment": "eventtype",
        "Name": "eventtype",
        "Type": "string"
      },
      {
        "Comment": "apiversion",
        "Name": "apiversion",
        "Type": "string"
      },
      {
        "Comment": "readonly",
        "Name": "readonly",
        "Type": "string"
      },
      {
        "Comment": "recipientaccountid",
        "Name": "recipientaccountid",
        "Type": "string"
      },
      {
        "Comment": "serviceeventdetails",
        "Name": "serviceeventdetails",
        "Type": "string"
      },
      {
        "Comment": "sharedeventid",
        "Name": "sharedeventid",
        "Type": "string"
      },
      {
        "Comment": "vpcendpointid",
        "Name": "vpcendpointid",
        "Type": "string"
      }
    ],
    "InputFormat": "com.amazon.emr.cloudtrail.CloudTrailInputFormat",
    "Location": "value of cloudtraillog in Lambda stack",
    "OutputFormat": "org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat",
    "SerdeInfo": {
              "SerializationLibrary": "com.amazon.emr.hive.serde.CloudTrailSerde"
            },
    "StoredAsSubDirectories": false
  },
  "TableType": "EXTERNAL_TABLE"
}
}
},
      "datadict": {"Type": "AWS::Glue::Table",
"Properties": {
"CatalogId": {
"Ref": "AWS::AccountId"
},
"DatabaseName": {"Ref": "adminconsoledb"},
"TableInput": {
"Description": "data dictionry",
"Name": "data_dict",
"Parameters": {
"classification": "csv"
},
"StorageDescriptor": {
"Columns": [
{
  "Comment": "datasetname",
  "Name": "datasetname",
  "Type": "string"
},
{
  "Comment": "datasetid",
  "Name": "datasetid",
  "Type": "string"
},
{
  "Comment": "columnname",
  "Name": "columnname",
  "Type": "string"
},
{
  "Comment": "columntype",
  "Name": "columntype",
  "Type": "string"
},
{
  "Comment": "columndesc",
  "Name": "columndesc",
  "Type": "string"
}
],
"Compressed": false,
            "InputFormat": "org.apache.hadoop.mapred.TextInputFormat",
            "Location": "value of datadict in Lambda stack",
            "OutputFormat": "org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat",
            "SerdeInfo": {
              "Parameters": {
                "field.delim": ","
              },
              "SerializationLibrary": "org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe"
            },
            "StoredAsSubDirectories": false
          },
          "TableType": "EXTERNAL_TABLE"
}
}
},
      "datasetsinfo": {"Type": "AWS::Glue::Table",
"Properties": {
"CatalogId": {
"Ref": "AWS::AccountId"
},
"DatabaseName": {"Ref": "adminconsoledb"},
"TableInput": {
"Description": "datasets info",
"Name": "datasets_info",
"Parameters": {
"classification": "csv"
},
"StorageDescriptor": {
"Columns": [
{
  "Comment": "aws_region",
  "Name": "aws_region",
  "Type": "string"
},
{
  "Comment": "dashboard_name",
  "Name": "dashboard_name",
  "Type": "string"
},
{
  "Comment": "dashboardid",
  "Name": "dashboardid",
  "Type": "string"
},
{
  "Comment": "analysis",
  "Name": "analysis",
  "Type": "string"
},
{
  "Comment": "analysis_id",
  "Name": "analysis_id",
  "Type": "string"
},
{
  "Comment": "dataset_name",
  "Name": "dataset_name",
  "Type": "string"
},
{
  "Comment": "dataset_id",
  "Name": "dataset_id",
  "Type": "string"
},
{
  "Comment": "lastupdatedtime",
  "Name": "lastupdatedtime",
  "Type": "string"
},
{
  "Comment": "data_source_name",
  "Name": "data_source_name",
  "Type": "string"
},
{
  "Comment": "data_source_id",
  "Name": "data_source_id",
  "Type": "string"
},
{
  "Comment": "catalog",
  "Name": "catalog",
  "Type": "string"
},
{
  "Comment": "sqlname/schema",
  "Name": "sqlname/schema",
  "Type": "string"
},
{
  "Comment": "sqlquery/table_name",
  "Name": "sqlquery/table_name",
  "Type": "string"
}
],
"Compressed": false,
            "InputFormat": "org.apache.hadoop.mapred.TextInputFormat",
            "Location": "value of dataset info in Lambda stack",
            "OutputFormat": "org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat",
            "SerdeInfo": {
              "Parameters": {
                "field.delim": "|"
              },
              "SerializationLibrary": "org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe"
            },
            "StoredAsSubDirectories": false
          },
          "TableType": "EXTERNAL_TABLE"
}
}
}

    }
}
