use crate::resources::{Param, PreferredParam, ResourceDefinition, SecurityParam};
use crate::types::ResolvedType;
pub fn rds_create_database() -> ResourceDefinition {
ResourceDefinition {
module: "RDS",
function: "createDatabase",
required_params: vec![
Param::string("identifier"),
Param::string("engine"),
Param::string("engineVersion"),
Param::new("subnet", ResolvedType::Subnet),
],
optional_params: vec![
Param::string("username"), Param::string("instanceClass"), Param::number("allocatedStorage"), Param::string("storageType"), Param::string("kmsKeyId"), Param::number("port"),
Param::string("maintenanceWindow"),
Param::string("backupWindow"),
Param::tags("tags"),
],
preferred_params: vec![
PreferredParam::bool("multiAz", true),
PreferredParam::number("backupRetention", 7.0),
PreferredParam::bool("deletionProtection", true),
PreferredParam::bool("performanceInsights", true),
PreferredParam::bool("autoMinorVersionUpgrade", true),
PreferredParam::bool("enhancedMonitoring", true),
],
security_params: vec![
SecurityParam::new("encryption", true, false),
SecurityParam::new("publiclyAccessible", false, true),
SecurityParam::new("iamAuth", true, false),
SecurityParam::new("skipFinalSnapshot", false, true), SecurityParam::presence("password"), ],
returns: ResolvedType::Database,
}
}
#[allow(dead_code)]
mod security_rules {
pub const RDS_001: &str = "Database storage must be encrypted at rest";
pub const RDS_002: &str = "Databases should not be publicly accessible";
pub const RDS_003: &str = "IAM authentication provides better access control";
}
#[allow(dead_code)]
mod preferred_rules {
pub const RDS_P01: &str = "Multi-AZ recommended for production workloads";
pub const RDS_P02: &str = "Backup retention of 7+ days recommended";
pub const RDS_P03: &str = "Deletion protection recommended for production";
pub const RDS_P04: &str = "Performance Insights aids in troubleshooting";
pub const RDS_P05: &str = "Auto upgrades keep database patched";
}