diff --git a/app/collectors/rds.scala b/app/collectors/rds.scala deleted file mode 100644 index 7fec2140..00000000 --- a/app/collectors/rds.scala +++ /dev/null @@ -1,104 +0,0 @@ -package collectors - -import java.time.Instant - -import agent._ -import conf.AWS -import controllers.routes -import play.api.mvc.Call -import software.amazon.awssdk.services.rds.RdsClient -import software.amazon.awssdk.services.rds.model.{ - DBInstance, - DescribeDbInstancesRequest -} -import utils.Logging - -import scala.jdk.CollectionConverters._ -import scala.language.postfixOps - -class RdsCollectorSet(accounts: Accounts) - extends CollectorSet[Rds](ResourceType("rds"), accounts, Some(Regional)) { - val lookupCollector: PartialFunction[Origin, Collector[Rds]] = { - case amazon: AmazonOrigin => - AWSRdsCollector(amazon, resource, amazon.crawlRate(resource.name)) - } -} - -case class AWSRdsCollector( - origin: AmazonOrigin, - resource: ResourceType, - crawlRate: CrawlRate -) extends Collector[Rds] - with Logging { - - val client: RdsClient = RdsClient.builder - .credentialsProvider(origin.credentials.provider) - .region(origin.awsRegionV2) - .overrideConfiguration(AWS.clientConfig) - .build - - def crawl: Iterable[Rds] = - client - .describeDBInstancesPaginator(DescribeDbInstancesRequest.builder.build) - .dbInstances - .asScala - .map(Rds.fromApiData(_)) -} - -object Rds { - def fromApiData(db: DBInstance): Rds = Rds( - arn = db.dbInstanceArn, - allocatedStorage = db.allocatedStorage, - availabilityZone = db.availabilityZone, - secondaryAvailabilityZone = Option(db.secondaryAvailabilityZone), - engineVersion = db.engineVersion, - instanceCreateTime = db.instanceCreateTime, - dbInstanceClass = db.dbInstanceClass, - dbInstanceStatus = db.dbInstanceStatus, - caCertificateIdentifier = db.caCertificateIdentifier, - dbiResourceId = db.dbiResourceId, - dbInstanceIdentifier = db.dbInstanceIdentifier, - engine = db.engine, - publiclyAccessible = db.publiclyAccessible, - iamDatabaseAuthenticationEnabled = db.iamDatabaseAuthenticationEnabled, - performanceInsightsEnabled = db.performanceInsightsEnabled, - multiAZ = db.multiAZ, - storageEncrypted = db.storageEncrypted, - vpcId = db.dbSubnetGroup.vpcId, - dbSubnetGroupName = db.dbSubnetGroup.dbSubnetGroupName, - vpcSecurityGroupId = - db.vpcSecurityGroups.asScala.map(_.vpcSecurityGroupId).toList, - storageType = db.storageType, - autoMinorVersionUpgrade = db.autoMinorVersionUpgrade, - tags = db.tagList.asScala.map(t => t.key -> t.value).toMap - ) -} - -case class Rds( - arn: String, - allocatedStorage: Int, - availabilityZone: String, - secondaryAvailabilityZone: Option[String], - engineVersion: String, - instanceCreateTime: Instant, - dbInstanceClass: String, - dbInstanceStatus: String, - caCertificateIdentifier: String, - dbiResourceId: String, - dbInstanceIdentifier: String, - engine: String, - publiclyAccessible: Boolean, - iamDatabaseAuthenticationEnabled: Boolean, - performanceInsightsEnabled: Boolean, - multiAZ: Boolean, - storageEncrypted: Boolean, - vpcId: String, - dbSubnetGroupName: String, - vpcSecurityGroupId: List[String], - storageType: String, - autoMinorVersionUpgrade: Boolean, - tags: Map[String, String] = Map.empty -) extends IndexedItemWithStage - with IndexedItemWithStack { - def callFromArn: String => Call = arn => routes.Api.rds(arn) -} diff --git a/app/controllers/Api.scala b/app/controllers/Api.scala index b17e5d91..bc882d8c 100644 --- a/app/controllers/Api.scala +++ b/app/controllers/Api.scala @@ -257,13 +257,6 @@ class Api( Api.singleItem(prismDataStore.reservationAgent, arn) } - def rdsList = Action.async { implicit request => - Api.itemList(prismDataStore.rdsAgent, "rds-instances") - } - def rds(arn: String) = Action.async { implicit request => - Api.singleItem(prismDataStore.rdsAgent, arn) - } - def vpcList = Action.async { implicit request => Api.itemList(prismDataStore.vpcAgent, "vpcs") } diff --git a/app/controllers/Prism.scala b/app/controllers/Prism.scala index 18eb0446..43d5a7b2 100644 --- a/app/controllers/Prism.scala +++ b/app/controllers/Prism.scala @@ -78,11 +78,6 @@ class Prism(prismConfiguration: PrismConfiguration)(actorSystem: ActorSystem) { sourceStatusAgent, lazyStartup )(actorSystem) - val rdsAgent = new CollectorAgent[Rds]( - new RdsCollectorSet(accounts), - sourceStatusAgent, - lazyStartup - )(actorSystem) val vpcAgent = new CollectorAgent[Vpc]( new VpcCollectorSet(accounts), sourceStatusAgent, @@ -102,7 +97,6 @@ class Prism(prismConfiguration: PrismConfiguration)(actorSystem: ActorSystem) { elbAgent, bucketAgent, reservationAgent, - rdsAgent, vpcAgent ) } diff --git a/app/jsonimplicits/implicits.scala b/app/jsonimplicits/implicits.scala index ff1cac0f..d8b7fff6 100644 --- a/app/jsonimplicits/implicits.scala +++ b/app/jsonimplicits/implicits.scala @@ -71,44 +71,6 @@ object model { Json.writes[RecurringCharge] Json.writes[Reservation] } - // json-play does not support automatically generating a writer for case clases with 22+ fields. - // Manually write one to get around this limitation. - implicit val rdsWriter: Writes[Rds] = OWrites[Rds](obj => - JsObject( - Seq( - "arn" -> Json.toJson(obj.arn), - "allocatedStorage" -> Json.toJson(obj.allocatedStorage), - "availabilityZone" -> Json.toJson(obj.availabilityZone), - "secondaryAvailabilityZone" -> Json.toJson( - obj.secondaryAvailabilityZone - ), - "engineVersion" -> Json.toJson(obj.engineVersion), - "instanceCreateTime" -> Json.toJson(obj.instanceCreateTime), - "dbInstanceClass" -> Json.toJson(obj.dbInstanceClass), - "dbInstanceStatus" -> Json.toJson(obj.dbInstanceStatus), - "caCertificateIdentifier" -> Json.toJson(obj.caCertificateIdentifier), - "dbiResourceId" -> Json.toJson(obj.dbiResourceId), - "dbInstanceIdentifier" -> Json.toJson(obj.dbInstanceIdentifier), - "engine" -> Json.toJson(obj.engine), - "publiclyAccessible" -> Json.toJson(obj.publiclyAccessible), - "iamDatabaseAuthenticationEnabled" -> Json.toJson( - obj.iamDatabaseAuthenticationEnabled - ), - "performanceInsightsEnabled" -> Json.toJson( - obj.performanceInsightsEnabled - ), - "multiAZ" -> Json.toJson(obj.multiAZ), - "storageEncrypted" -> Json.toJson(obj.storageEncrypted), - "vpcId" -> Json.toJson(obj.vpcId), - "dbSubnetGroupName" -> Json.toJson(obj.dbSubnetGroupName), - "vpcSecurityGroupId" -> Json.toJson(obj.vpcSecurityGroupId), - "storageType" -> Json.toJson(obj.storageType), - "autoMinorVersionUpgrade" -> Json.toJson(obj.autoMinorVersionUpgrade), - "tags" -> Json.toJson(obj.tags) - ) - ) - ) - implicit val domainResourceRecordWriter: Writes[DomainResourceRecord] = Json.writes[DomainResourceRecord] implicit val domainValidationWriter: Writes[DomainValidation] = diff --git a/build.sbt b/build.sbt index 78226502..6848bd99 100644 --- a/build.sbt +++ b/build.sbt @@ -52,7 +52,6 @@ lazy val root = (project in file(".")) "software.amazon.awssdk" % "elasticloadbalancing" % awsVersion, "software.amazon.awssdk" % "route53" % awsVersion, "software.amazon.awssdk" % "iam" % awsVersion, - "software.amazon.awssdk" % "rds" % awsVersion, "software.amazon.awssdk" % "cloudformation" % awsVersion, "com.beust" % "jcommander" % "1.82", // TODO: remove once security vulnerability introduced by aws sdk v2 fixed: https://snyk.io/vuln/maven:com.beust%3Ajcommanderbu "com.amazonaws" % "aws-java-sdk-dynamodb" % awsVersionOne, diff --git a/cdk/lib/__snapshots__/prism-access.test.ts.snap b/cdk/lib/__snapshots__/prism-access.test.ts.snap index da1e0a63..ae1b2a25 100644 --- a/cdk/lib/__snapshots__/prism-access.test.ts.snap +++ b/cdk/lib/__snapshots__/prism-access.test.ts.snap @@ -49,7 +49,6 @@ exports[`The PrismAccess stack matches the snapshot 1`] = ` "elasticloadbalancing:Describe*", "lambda:ListFunctions", "lambda:ListTags", - "rds:Describe*", "cloudformation:Describe*", "cloudformation:Get*", ], diff --git a/cdk/lib/prism-access.ts b/cdk/lib/prism-access.ts index 92728f7d..a8ff2783 100644 --- a/cdk/lib/prism-access.ts +++ b/cdk/lib/prism-access.ts @@ -65,7 +65,6 @@ export class PrismAccess extends GuStack { "elasticloadbalancing:Describe*", "lambda:ListFunctions", "lambda:ListTags", - "rds:Describe*", "cloudformation:Describe*", "cloudformation:Get*", ], diff --git a/conf/routes b/conf/routes index 746da16a..1a375a26 100644 --- a/conf/routes +++ b/conf/routes @@ -58,9 +58,6 @@ GET /data/keys controllers.Api.dataKeysList GET /data/lookup/:key controllers.Api.dataLookup(key) GET /data/:arn controllers.Api.data(arn) -GET /rds-instances controllers.Api.rdsList -GET /rds-instances/:arn controllers.Api.rds(arn) - GET /vpcs controllers.Api.vpcList GET /vpcs/:arn controllers.Api.vpcs(arn)