Skip to content

Commit cb3d997

Browse files
committed
feat: adding a submodule to generate a nuke configuration
1 parent 5f51ba3 commit cb3d997

File tree

12 files changed

+838
-0
lines changed

12 files changed

+838
-0
lines changed

modules/configuration/README.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<!-- BEGIN_TF_DOCS -->
2+
## Requirements
3+
4+
| Name | Version |
5+
|------|---------|
6+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0.7 |
7+
8+
## Providers
9+
10+
No providers.
11+
12+
## Modules
13+
14+
No modules.
15+
16+
## Resources
17+
18+
No resources.
19+
20+
## Inputs
21+
22+
| Name | Description | Type | Default | Required |
23+
|------|-------------|------|---------|:--------:|
24+
| <a name="input_accounts"></a> [accounts](#input\_accounts) | A collection of accounts to nuke | `list(string)` | n/a | yes |
25+
| <a name="input_regions"></a> [regions](#input\_regions) | A collection of regions to nuke | `list(string)` | n/a | yes |
26+
| <a name="input_blocklist"></a> [blocklist](#input\_blocklist) | A collection of resources to block from deletion | `list(string)` | <pre>[<br/> "123456789012"<br/>]</pre> | no |
27+
| <a name="input_excluded"></a> [excluded](#input\_excluded) | A collection of resources to exclude from the nuke | `list(string)` | <pre>[<br/> "Cloud9Environment",<br/> "CloudSearchDomain",<br/> "CodeStarConnection",<br/> "CodeStarNotification",<br/> "CodeStarProject",<br/> "EC2DHCPOption",<br/> "EC2NetworkACL",<br/> "EC2NetworkInterface",<br/> "ECSCluster",<br/> "ECSClusterInstance",<br/> "ECSService",<br/> "ECSTaskDefinition",<br/> "FMSNotificationChannel",<br/> "FMSPolicy",<br/> "IAMRole",<br/> "IAMUser",<br/> "MachineLearningBranchPrediction",<br/> "MachineLearningDataSource",<br/> "MachineLearningEvaluation",<br/> "MachineLearningMLModel",<br/> "OpsWorksApp",<br/> "OpsWorksApp",<br/> "OpsWorksCMBackup",<br/> "OpsWorksCMServer",<br/> "OpsWorksCMServerState",<br/> "OpsWorksInstance",<br/> "OpsWorksLayer",<br/> "OpsWorksUserProfile",<br/> "RedshiftServerlessNamespace",<br/> "RedshiftServerlessSnapshot",<br/> "RedshiftServerlessWorkgroup",<br/> "RoboMakerDeploymentJob",<br/> "RoboMakerFleet",<br/> "RoboMakerRobot",<br/> "RoboMakerRobotApplication",<br/> "RoboMakerSimulationApplication",<br/> "RoboMakerSimulationJob",<br/> "S3Object",<br/> "ServiceCatalogTagOption",<br/> "ServiceCatalogTagOptionPortfolioAttachment"<br/>]</pre> | no |
28+
| <a name="input_filters"></a> [filters](#input\_filters) | A collection of filters are applied to all resources | <pre>list(object({<br/> property = string<br/> type = string<br/> value = string<br/> }))</pre> | `[]` | no |
29+
| <a name="input_include_presets"></a> [include\_presets](#input\_include\_presets) | A collection of preset filters to use for nuke | <pre>object({<br/> enable_control_tower = optional(bool, true)<br/> enable_cost_intelligence = optional(bool, true)<br/> enable_landing_zone = optional(bool, true)<br/> })</pre> | <pre>{<br/> "enable_control_tower": true,<br/> "enable_cost_intelligence": true,<br/> "enable_landing_zone": true<br/>}</pre> | no |
30+
| <a name="input_included"></a> [included](#input\_included) | A collection of resources to include in the nuke | `list(string)` | <pre>[<br/> "AWSBackupRecoveryPoint",<br/> "AWSBackupSelection",<br/> "BackupVault",<br/> "AppStreamDirectoryConfig",<br/> "AppStreamFleet",<br/> "AppStreamFleetState",<br/> "AppStreamImage",<br/> "AppStreamImageBuilder",<br/> "AppStreamImageBuilderWaiter",<br/> "AppStreamStack",<br/> "AppStreamStackFleetAttachment",<br/> "AutoScalingGroup",<br/> "AutoScalingPlansScalingPlan",<br/> "BatchComputeEnvironment",<br/> "BatchComputeEnvironmentState",<br/> "BatchJobQueue",<br/> "BatchJobQueueState",<br/> "Cloud9Environment",<br/> "CloudDirectoryDirectory",<br/> "CloudDirectorySchema",<br/> "CloudFrontDistribution",<br/> "CloudFrontDistributionDeployment",<br/> "CloudHSMV2Cluster",<br/> "CloudHSMV2ClusterHSM",<br/> "CloudSearchDomain",<br/> "CloudWatchAlarm",<br/> "CloudWatchDashboard",<br/> "CloudWatchLogsDestination",<br/> "CloudWatchLogsLogGroup",<br/> "CodeBuildProject",<br/> "CodeCommitRepository",<br/> "CodeDeployApplication",<br/> "CodePipelinePipeline",<br/> "CodeStarProject",<br/> "CognitoIdentityPool",<br/> "CognitoUserPool",<br/> "CognitoUserPoolDomain",<br/> "DAXCluster",<br/> "DAXParameterGroup",<br/> "DAXSubnetGroup",<br/> "DataPipelinePipeline",<br/> "DatabaseMigrationServiceCertificate",<br/> "DatabaseMigrationServiceEndpoint",<br/> "DatabaseMigrationServiceEventSubscription",<br/> "DatabaseMigrationServiceReplicationInstance",<br/> "DatabaseMigrationServiceReplicationTask",<br/> "DatabaseMigrationServiceSubnetGroup",<br/> "DeviceFarmProject",<br/> "DirectoryServiceDirectory",<br/> "DynamoDBTable",<br/> "EC2Address",<br/> "EC2ClientVpnEndpoint",<br/> "EC2ClientVpnEndpointAttachment",<br/> "EC2CustomerGateway",<br/> "EC2Image",<br/> "EC2Instance",<br/> "EC2InternetGateway",<br/> "EC2InternetGatewayAttachment",<br/> "EC2KeyPair",<br/> "EC2LaunchTemplate",<br/> "EC2NATGateway",<br/> "EC2NetworkACL",<br/> "EC2PlacementGroup",<br/> "EC2RouteTable",<br/> "EC2SecurityGroup",<br/> "EC2Snapshot",<br/> "EC2SpotFleetRequest",<br/> "EC2Subnet",<br/> "EC2TGW",<br/> "EC2TGWAttachment",<br/> "EC2VPC",<br/> "EC2VPCEndpoint",<br/> "EC2VPCEndpointServiceConfiguration",<br/> "EC2VPCPeeringConnection",<br/> "EC2VPNConnection",<br/> "EC2VPNGatewayAttachment",<br/> "EC2Volume",<br/> "ECRRepository",<br/> "EFSFileSystem",<br/> "EFSMountTarget",<br/> "EKSCluster",<br/> "ELB",<br/> "ELBv2",<br/> "ELBv2TargetGroup",<br/> "EMRCluster",<br/> "EMRSecurityConfiguration",<br/> "ESDomain",<br/> "ElasticBeanstalkApplication",<br/> "ElasticBeanstalkEnvironment",<br/> "ElasticTranscoderPipeline",<br/> "ElasticacheCacheCluster",<br/> "ElasticacheReplicationGroup",<br/> "ElasticacheSubnetGroup",<br/> "FSxBackup",<br/> "FSxFileSystem",<br/> "FirehoseDeliveryStream",<br/> "GlueClassifier",<br/> "GlueConnection",<br/> "GlueCrawler",<br/> "GlueDatabase",<br/> "GlueDevEndpoint",<br/> "GlueJob",<br/> "GlueTrigger",<br/> "IAMGroup",<br/> "IAMGroupPolicy",<br/> "IAMGroupPolicyAttachment",<br/> "IAMInstanceProfile",<br/> "IAMInstanceProfileRole",<br/> "IAMLoginProfile",<br/> "IAMOpenIDConnectProvider",<br/> "IAMRole",<br/> "IAMServerCertificate",<br/> "IAMServiceSpecificCredential",<br/> "IAMUser",<br/> "IAMUserAccessKey",<br/> "IAMUserGroupAttachment",<br/> "IAMUserPolicy",<br/> "IAMUserPolicyAttachment",<br/> "IAMVirtualMFADevice",<br/> "IoTAuthorizer",<br/> "IoTCACertificate",<br/> "IoTCertificate",<br/> "IoTJob",<br/> "IoTOTAUpdate",<br/> "IoTPolicy",<br/> "IoTRoleAlias",<br/> "IoTStream",<br/> "IoTThing",<br/> "IoTThingGroup",<br/> "IoTThingType",<br/> "IoTThingTypeState",<br/> "IoTTopicRule",<br/> "KMSAlias",<br/> "KMSKey",<br/> "KinesisAnalyticsApplication",<br/> "KinesisStream",<br/> "KinesisVideoProject",<br/> "LambdaEventSourceMapping",<br/> "LambdaFunction",<br/> "LaunchConfiguration",<br/> "LifecycleHook",<br/> "LightsailDisk",<br/> "LightsailDomain",<br/> "LightsailInstance",<br/> "LightsailKeyPair",<br/> "LightsailLoadBalancer",<br/> "LightsailStaticIP",<br/> "MQBroker",<br/> "MSKCluster",<br/> "MediaConvertJobTemplate",<br/> "MediaConvertPreset",<br/> "MediaConvertQueue",<br/> "MediaLiveChannel",<br/> "MediaLiveInput",<br/> "MediaLiveInputSecurityGroup",<br/> "MediaPackageChannel",<br/> "MediaPackageOriginEndpoint",<br/> "MediaStoreContainer",<br/> "MediaStoreDataItems",<br/> "MediaTailorConfiguration",<br/> "MobileProject",<br/> "NeptuneCluster",<br/> "NeptuneInstance",<br/> "NetpuneSnapshot",<br/> "OpsWorksApp",<br/> "OpsWorksCMBackup",<br/> "OpsWorksCMServer",<br/> "OpsWorksCMServerState",<br/> "OpsWorksInstance",<br/> "OpsWorksLayer",<br/> "OpsWorksUserProfile",<br/> "RDSDBCluster",<br/> "RDSDBClusterParameterGroup",<br/> "RDSDBParameterGroup",<br/> "RDSDBSubnetGroup",<br/> "RDSInstance",<br/> "RDSSnapshot",<br/> "RedshiftCluster",<br/> "RedshiftParameterGroup",<br/> "RedshiftSnapshot",<br/> "RedshiftSubnetGroup",<br/> "RekognitionCollection",<br/> "ResourceGroupGroup",<br/> "RoboMakerDeploymentJob",<br/> "RoboMakerFleet",<br/> "RoboMakerRobot",<br/> "RoboMakerRobotApplication",<br/> "RoboMakerSimulationApplication",<br/> "RoboMakerSimulationJob",<br/> "Route53HostedZone",<br/> "Route53ResourceRecordSet",<br/> "S3Bucket",<br/> "S3MultipartUpload",<br/> "S3Object",<br/> "SESConfigurationSet",<br/> "SESIdentity",<br/> "SESReceiptFilter",<br/> "SESReceiptRuleSet",<br/> "SESTemplate",<br/> "SFNStateMachine",<br/> "SNSEndpoint",<br/> "SNSPlatformApplication",<br/> "SNSSubscription",<br/> "SNSTopic",<br/> "SQSQueue",<br/> "SSMActivation",<br/> "SSMAssociation",<br/> "SSMDocument",<br/> "SSMMaintenanceWindow",<br/> "SSMParameter",<br/> "SSMPatchBaseline",<br/> "SSMResourceDataSync",<br/> "SageMakerEndpoint",<br/> "SageMakerEndpointConfig",<br/> "SageMakerModel",<br/> "SageMakerNotebookInstance",<br/> "SageMakerNotebookInstanceState",<br/> "SecretsManagerSecret",<br/> "ServiceCatalogConstraintPortfolioAttachment",<br/> "ServiceCatalogPortfolio",<br/> "ServiceCatalogPortfolioProductAttachment",<br/> "ServiceCatalogPortfolioShareAttachment",<br/> "ServiceCatalogPrincipalPortfolioAttachment",<br/> "ServiceCatalogProduct",<br/> "ServiceCatalogProvisionedProduct",<br/> "ServiceCatalogTagOption",<br/> "ServiceCatalogTagOptionPortfolioAttachment",<br/> "ServiceDiscoveryInstance",<br/> "ServiceDiscoveryNamespace",<br/> "ServiceDiscoveryService",<br/> "SimpleDBDomain",<br/> "StorageGatewayFileShare",<br/> "StorageGatewayGateway",<br/> "StorageGatewayTape",<br/> "StorageGatewayVolume",<br/> "WAFRegionalByteMatchSet",<br/> "WAFRegionalByteMatchSetIP",<br/> "WAFRegionalIPSet",<br/> "WAFRegionalIPSetIP",<br/> "WAFRegionalRateBasedRule",<br/> "WAFRegionalRateBasedRulePredicate",<br/> "WAFRegionalRegexMatchSet",<br/> "WAFRegionalRegexMatchTuple",<br/> "WAFRegionalRegexPatternSet",<br/> "WAFRegionalRegexPatternString",<br/> "WAFRegionalRule",<br/> "WAFRegionalRulePredicate",<br/> "WAFRegionalWebACL",<br/> "WAFRegionalWebACLRuleAttachment",<br/> "WAFRule",<br/> "WAFWebACL",<br/> "WAFWebACLRuleAttachment",<br/> "WorkLinkFleet",<br/> "WorkSpacesWorkspace"<br/>]</pre> | no |
31+
| <a name="input_presets"></a> [presets](#input\_presets) | A collection of presets used in the nuke | <pre>map(map(list(object({<br/> property = string<br/> type = string<br/> value = string<br/> }))))</pre> | `{}` | no |
32+
33+
## Outputs
34+
35+
| Name | Description |
36+
|------|-------------|
37+
| <a name="output_configuration"></a> [configuration](#output\_configuration) | The rendered configuration file for the nuke service |
38+
<!-- END_TF_DOCS -->
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
---
2+
#
3+
## The configuration has been automatically generated - please do not
4+
## modify it manually. Instead, use the `config.yml` file in the root
5+
## of the repository to update the configuration.
6+
#
7+
8+
blocklist:
9+
%{ for account in blocklist }- ${account}%{ endfor }
10+
11+
regions:
12+
- global
13+
%{ for region in regions ~}- ${region}
14+
%{ endfor ~}
15+
16+
bypass-alias-check-accounts:
17+
%{ for account in accounts ~}- ${account}
18+
%{ endfor ~}
19+
20+
resource-types:
21+
## The following resource types included in the deletion process
22+
includes:
23+
%{ for resource, filters in included ~}- ${resource}
24+
%{ endfor ~}
25+
26+
## The following resources are excluded from the deletion process
27+
excludes:
28+
%{ for resource in excluded ~}- ${resource}
29+
%{ endfor ~}
30+
31+
presets:
32+
%{ for preset_name in keys(presets) }
33+
${preset_name}:
34+
filters:
35+
%{ for resource, filters in presets[preset_name] ~}${resource}:
36+
%{ for filter in filters ~}- property: "${filter.property}"
37+
type: "${filter.type}"
38+
value: "${filter.value}"
39+
%{ endfor }
40+
%{ endfor ~}
41+
%{ endfor }
42+
43+
## Iteratation of all the accounts, the resources and the filters
44+
## we should apply against those resources
45+
accounts:
46+
%{ for account in accounts }${account}:
47+
presets:
48+
%{ for name in keys(presets) ~}- ${name}
49+
%{ endfor }
50+
filters:
51+
%{ for resource, filters in included ~}${resource}:
52+
%{ for filter in filters ~}- property: "${filter.property}"
53+
type: "${filter.type}"
54+
value: "${filter.value}"
55+
%{ endfor }
56+
%{ endfor }
57+
%{ endfor }

modules/configuration/examples/basic/.terraform.lock.hcl

Lines changed: 25 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#####################################################################################
2+
# Terraform module examples are meant to show an _example_ on how to use a module
3+
# per use-case. The code below should not be copied directly but referenced in order
4+
# to build your own root module that invokes this module
5+
#####################################################################################
6+
7+
locals {
8+
tags = {
9+
"Environment" = "Sandbox"
10+
"GitRepo" = "https://github.com/appvia/terraform-aws-nuke"
11+
"Owner" = "Support"
12+
"Product" = "Sandbox"
13+
}
14+
}
15+
16+
module "configuration" {
17+
source = "../.."
18+
19+
accounts = [123456789012, 123456789013]
20+
regions = ["us-east-1", "us-west-2"]
21+
22+
presets = {
23+
"default" = {
24+
"IAMRole" = [
25+
{
26+
property = "roleName"
27+
type = "regex"
28+
value = "^AWSControlTower.*"
29+
}
30+
]
31+
}
32+
}
33+
34+
filters = [
35+
{
36+
property = "tag:Environment"
37+
type = "string"
38+
value = "Sandbox"
39+
},
40+
{
41+
property = "tag:Owner"
42+
type = "string"
43+
value = "Support"
44+
}
45+
]
46+
47+
include_presets = {
48+
enable_control_tower = true
49+
enable_cost_intelligence = true
50+
enable_landing_zone = true
51+
}
52+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
output "configuration" {
3+
description = "The rendered configuration file for the nuke service"
4+
value = module.configuration.configuration
5+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
terraform {
3+
required_version = ">= 1.0.0"
4+
5+
required_providers {
6+
aws = {
7+
source = "hashicorp/aws"
8+
version = ">= 5.0.0"
9+
}
10+
}
11+
}

modules/configuration/examples/basic/variables.tf

Whitespace-only changes.

0 commit comments

Comments
 (0)