From 33b270915f2acdd3f2265ea0f394c97127fabf5d Mon Sep 17 00:00:00 2001 From: Rohith Jayawardene Date: Sun, 10 Nov 2024 13:19:07 +0000 Subject: [PATCH] feat: adding a filters for aws managed resources --- modules/configuration/README.md | 2 +- modules/configuration/locals.tf | 10 ++++++++++ modules/configuration/variables.tf | 2 ++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/modules/configuration/README.md b/modules/configuration/README.md index 0f560ab..921ec75 100644 --- a/modules/configuration/README.md +++ b/modules/configuration/README.md @@ -26,7 +26,7 @@ No resources. | [blocklist](#input\_blocklist) | A collection of resources to block from deletion | `list(string)` |
[
"123456789012"
]
| no | | [excluded](#input\_excluded) | A collection of resources to exclude from the nuke |
object({
add = optional(list(string), [])
# Additional resources to exclude from the nuke configuration on top of the default ones below
remove = optional(list(string), [])
# Resources to exclude from the nuke configuration
all = optional(list(string), [
"Cloud9Environment",
"CloudSearchDomain",
"CodeStarConnection",
"CodeStarNotification",
"CodeStarProject",
"EC2DHCPOption",
"EC2NetworkACL",
"EC2NetworkInterface",
"ECSCluster",
"ECSClusterInstance",
"ECSService",
"ECSTaskDefinition",
"FMSNotificationChannel",
"FMSPolicy",
"IAMUser",
"MachineLearningBranchPrediction",
"MachineLearningDataSource",
"MachineLearningEvaluation",
"MachineLearningMLModel",
"OpsWorksApp",
"OpsWorksCMBackup",
"OpsWorksCMServer",
"OpsWorksCMServerState",
"OpsWorksInstance",
"OpsWorksLayer",
"OpsWorksUserProfile",
"RedshiftServerlessNamespace",
"RedshiftServerlessSnapshot",
"RedshiftServerlessWorkgroup",
"RoboMakerDeploymentJob",
"RoboMakerFleet",
"RoboMakerRobot",
"RoboMakerRobotApplication",
"RoboMakerSimulationApplication",
"RoboMakerSimulationJob",
"S3Object",
"ServiceCatalogTagOption",
"ServiceCatalogTagOptionPortfolioAttachment",
])
## Default resources to exclude from the nuke configuration
})
| `{}` | no | | [filters](#input\_filters) | A collection of global filters are applied to all resources |
list(object({
invert = optional(bool, null)
property = string
type = string
value = string
}))
| `[]` | no | -| [include\_filters](#input\_include\_filters) | A collection of predefined filters to use for nuke |
object({
enable_control_tower = optional(bool, true)
enable_cost_intelligence = optional(bool, true)
enable_landing_zone = optional(bool, true)
})
|
{
"enable_control_tower": true,
"enable_cost_intelligence": true,
"enable_landing_zone": true
}
| no | +| [include\_filters](#input\_include\_filters) | A collection of predefined filters to use for nuke |
object({
enable_aws_managed = optional(bool, true)
enable_control_tower = optional(bool, true)
enable_cost_intelligence = optional(bool, true)
enable_landing_zone = optional(bool, true)
})
|
{
"enable_aws_managed": true,
"enable_control_tower": true,
"enable_cost_intelligence": true,
"enable_landing_zone": true
}
| no | | [included](#input\_included) | A collection of resources to include in the nuke |
object({
add = optional(list(string), [])
# Resources to remove from the nuke configuration
all = optional(list(string), [
"AWSBackupRecoveryPoint",
"AWSBackupSelection",
"BackupVault",
"AppStreamDirectoryConfig",
"AppStreamFleet",
"AppStreamFleetState",
"AppStreamImage",
"AppStreamImageBuilder",
"AppStreamImageBuilderWaiter",
"AppStreamStack",
"AppStreamStackFleetAttachment",
"AutoScalingGroup",
"AutoScalingPlansScalingPlan",
"BatchComputeEnvironment",
"BatchComputeEnvironmentState",
"BatchJobQueue",
"BatchJobQueueState",
"Cloud9Environment",
"CloudDirectoryDirectory",
"CloudDirectorySchema",
"CloudFrontDistribution",
"CloudFrontDistributionDeployment",
"CloudHSMV2Cluster",
"CloudHSMV2ClusterHSM",
"CloudSearchDomain",
"CloudWatchAlarm",
"CloudWatchDashboard",
"CloudWatchLogsDestination",
"CloudWatchLogsLogGroup",
"CodeBuildProject",
"CodeCommitRepository",
"CodeDeployApplication",
"CodePipelinePipeline",
"CodeStarProject",
"CognitoIdentityPool",
"CognitoUserPool",
"CognitoUserPoolDomain",
"DAXCluster",
"DAXParameterGroup",
"DAXSubnetGroup",
"DataPipelinePipeline",
"DatabaseMigrationServiceCertificate",
"DatabaseMigrationServiceEndpoint",
"DatabaseMigrationServiceEventSubscription",
"DatabaseMigrationServiceReplicationInstance",
"DatabaseMigrationServiceReplicationTask",
"DatabaseMigrationServiceSubnetGroup",
"DeviceFarmProject",
"DirectoryServiceDirectory",
"DynamoDBTable",
"EC2Address",
"EC2ClientVpnEndpoint",
"EC2ClientVpnEndpointAttachment",
"EC2CustomerGateway",
"EC2Image",
"EC2Instance",
"EC2InternetGateway",
"EC2InternetGatewayAttachment",
"EC2KeyPair",
"EC2LaunchTemplate",
"EC2NATGateway",
"EC2NetworkACL",
"EC2PlacementGroup",
"EC2RouteTable",
"EC2SecurityGroup",
"EC2Snapshot",
"EC2SpotFleetRequest",
"EC2Subnet",
"EC2TGW",
"EC2TGWAttachment",
"EC2VPC",
"EC2VPCEndpoint",
"EC2VPCEndpointServiceConfiguration",
"EC2VPCPeeringConnection",
"EC2VPNConnection",
"EC2VPNGatewayAttachment",
"EC2Volume",
"ECRRepository",
"EFSFileSystem",
"EFSMountTarget",
"EKSCluster",
"ELB",
"ELBv2",
"ELBv2TargetGroup",
"EMRCluster",
"EMRSecurityConfiguration",
"ESDomain",
"ElasticBeanstalkApplication",
"ElasticBeanstalkEnvironment",
"ElasticTranscoderPipeline",
"ElasticacheCacheCluster",
"ElasticacheReplicationGroup",
"ElasticacheSubnetGroup",
"FSxBackup",
"FSxFileSystem",
"FirehoseDeliveryStream",
"GlueClassifier",
"GlueConnection",
"GlueCrawler",
"GlueDatabase",
"GlueDevEndpoint",
"GlueJob",
"GlueTrigger",
"IAMGroup",
"IAMGroupPolicy",
"IAMGroupPolicyAttachment",
"IAMInstanceProfile",
"IAMInstanceProfileRole",
"IAMLoginProfile",
"IAMOpenIDConnectProvider",
"IAMRole",
"IAMServerCertificate",
"IAMServiceSpecificCredential",
"IAMUser",
"IAMUserAccessKey",
"IAMUserGroupAttachment",
"IAMUserPolicy",
"IAMUserPolicyAttachment",
"IAMVirtualMFADevice",
"IoTAuthorizer",
"IoTCACertificate",
"IoTCertificate",
"IoTJob",
"IoTOTAUpdate",
"IoTPolicy",
"IoTRoleAlias",
"IoTStream",
"IoTThing",
"IoTThingGroup",
"IoTThingType",
"IoTThingTypeState",
"IoTTopicRule",
"KMSAlias",
"KMSKey",
"KinesisAnalyticsApplication",
"KinesisStream",
"KinesisVideoProject",
"LambdaEventSourceMapping",
"LambdaFunction",
"LaunchConfiguration",
"LifecycleHook",
"LightsailDisk",
"LightsailDomain",
"LightsailInstance",
"LightsailKeyPair",
"LightsailLoadBalancer",
"LightsailStaticIP",
"MQBroker",
"MSKCluster",
"MediaConvertJobTemplate",
"MediaConvertPreset",
"MediaConvertQueue",
"MediaLiveChannel",
"MediaLiveInput",
"MediaLiveInputSecurityGroup",
"MediaPackageChannel",
"MediaPackageOriginEndpoint",
"MediaStoreContainer",
"MediaStoreDataItems",
"MediaTailorConfiguration",
"MobileProject",
"NeptuneCluster",
"NeptuneInstance",
"NetpuneSnapshot",
"OpsWorksApp",
"OpsWorksCMBackup",
"OpsWorksCMServer",
"OpsWorksCMServerState",
"OpsWorksInstance",
"OpsWorksLayer",
"OpsWorksUserProfile",
"RDSDBCluster",
"RDSDBClusterParameterGroup",
"RDSDBParameterGroup",
"RDSDBSubnetGroup",
"RDSInstance",
"RDSSnapshot",
"RedshiftCluster",
"RedshiftParameterGroup",
"RedshiftSnapshot",
"RedshiftSubnetGroup",
"RekognitionCollection",
"ResourceGroupGroup",
"RoboMakerDeploymentJob",
"RoboMakerFleet",
"RoboMakerRobot",
"RoboMakerRobotApplication",
"RoboMakerSimulationApplication",
"RoboMakerSimulationJob",
"Route53HostedZone",
"Route53ResourceRecordSet",
"S3Bucket",
"S3MultipartUpload",
"S3Object",
"SESConfigurationSet",
"SESIdentity",
"SESReceiptFilter",
"SESReceiptRuleSet",
"SESTemplate",
"SFNStateMachine",
"SNSEndpoint",
"SNSPlatformApplication",
"SNSSubscription",
"SNSTopic",
"SQSQueue",
"SSMActivation",
"SSMAssociation",
"SSMDocument",
"SSMMaintenanceWindow",
"SSMParameter",
"SSMPatchBaseline",
"SSMResourceDataSync",
"SageMakerEndpoint",
"SageMakerEndpointConfig",
"SageMakerModel",
"SageMakerNotebookInstance",
"SageMakerNotebookInstanceState",
"SecretsManagerSecret",
"ServiceCatalogConstraintPortfolioAttachment",
"ServiceCatalogPortfolio",
"ServiceCatalogPortfolioProductAttachment",
"ServiceCatalogPortfolioShareAttachment",
"ServiceCatalogPrincipalPortfolioAttachment",
"ServiceCatalogProduct",
"ServiceCatalogProvisionedProduct",
"ServiceCatalogTagOption",
"ServiceCatalogTagOptionPortfolioAttachment",
"ServiceDiscoveryInstance",
"ServiceDiscoveryNamespace",
"ServiceDiscoveryService",
"SimpleDBDomain",
"StorageGatewayFileShare",
"StorageGatewayGateway",
"StorageGatewayTape",
"StorageGatewayVolume",
"WAFRegionalByteMatchSet",
"WAFRegionalByteMatchSetIP",
"WAFRegionalIPSet",
"WAFRegionalIPSetIP",
"WAFRegionalRateBasedRule",
"WAFRegionalRateBasedRulePredicate",
"WAFRegionalRegexMatchSet",
"WAFRegionalRegexMatchTuple",
"WAFRegionalRegexPatternSet",
"WAFRegionalRegexPatternString",
"WAFRegionalRule",
"WAFRegionalRulePredicate",
"WAFRegionalWebACL",
"WAFRegionalWebACLRuleAttachment",
"WAFRule",
"WAFWebACL",
"WAFWebACLRuleAttachment",
"WorkLinkFleet",
"WorkSpacesWorkspace",
])
# A collection of resources to include in the nuke
})
| `{}` | no | | [presets](#input\_presets) | A collection of presets used in the nuke |
map(map(list(object({
property = string
type = string
value = string
}))))
| `{}` | no | diff --git a/modules/configuration/locals.tf b/modules/configuration/locals.tf index 78dd136..39f03e7 100644 --- a/modules/configuration/locals.tf +++ b/modules/configuration/locals.tf @@ -5,6 +5,7 @@ locals { var.include_filters.enable_control_tower ? local.control_tower_filters : [], var.include_filters.enable_cost_intelligence ? local.cost_intelligence_filters : [], var.include_filters.enable_landing_zone ? local.landing_zone_filters : [], + var.include_filters.enable_aws_managed_services ? local.aws_managed_services_filters : [], var.filters ) @@ -67,6 +68,15 @@ locals { } ] + ## AWS managed services filters + aws_managed_services_filters = [ + { + property = "Name" + type = "regex" + value = "^(AWSService|AWSReservedSSO_).*" + }, + ] + ## Cost Intelligence filters cost_intelligence_filters = [ { diff --git a/modules/configuration/variables.tf b/modules/configuration/variables.tf index e484a39..83357fe 100644 --- a/modules/configuration/variables.tf +++ b/modules/configuration/variables.tf @@ -28,11 +28,13 @@ variable "presets" { variable "include_filters" { description = "A collection of predefined filters to use for nuke" type = object({ + enable_aws_managed = optional(bool, true) enable_control_tower = optional(bool, true) enable_cost_intelligence = optional(bool, true) enable_landing_zone = optional(bool, true) }) default = { + enable_aws_managed = true enable_control_tower = true enable_cost_intelligence = true enable_landing_zone = true