销毁AWS资源:Cloud-Nuke还是AWS-Nuke?

胡飞舟
2023-12-01

因此,您在开发帐户上工作,并且Terraform陷入了一个循环,难道不让您轻易销毁剩余资源吗? 进入nuke CLI的世界!

在撰写本文时,我使用的是v0.1.16版

用Go语言编写的《 Gruntwork》不会破坏掉aws-nuke那样多的对象; 自2017年5月以来一直存在

如果您使用~/.aws/credentials ,请在~/.aws/credentials选择(明智地!)帐户别名(在我的情况下为myenv-dev ),然后:

AWS_PROFILE=myenv-dev ~/Downloads/cloud-nuke_darwin_amd64 aws

但是实际上,您可能希望将范围缩小到单个区域。 因此您必须在命令行中指定它:

AWS_PROFILE=myenv-dev ~/Downloads/cloud-nuke_darwin_amd64 aws  --region=eu-west-1

如果使用list参数aws --list-resource-types调用,则会获得支持删除哪些资源的列表:

ami
asg
ebs
ec2
ecsserv
eip
ekscluster
elb
elbv2
lc
rds
snap

在撰写本文时,我使用的是v2.14.0版本

用Ruby编写的rebuy.de将破坏许多对象(如果不是全部),则支持过滤器,需要配置文件; 自2016年6月以来一直存在。

您需要提供一个配置文件。 最小的文件可能是这样的nuke.yml文件

regions:
- eu-west-1
- global # for resources not bound to a specific region, such as Route53 zones for example
account-blacklist:
- "111222333444" # production
 
accounts:
  "999888777666": {} # aws-nuke-example

如果您使用~/.aws/credentials ,请在~/.aws/credentials选择(明智地!)帐户别名(在我的情况下为myenv-dev ),然后:

AWS_PROFILE=myenv-dev ~/Downloads/aws-nuke-v2.14.0-darwin-amd64 --config nuke.yml

如果使用list参数resource-types调用,则会获得支持删除哪些资源的列表:

ACMCertificate
ACMPCACertificateAuthority
ACMPCACertificateAuthorityState
APIGatewayAPIKey
APIGatewayClientCertificate
APIGatewayDomainName
APIGatewayRestAPI
APIGatewayUsagePlan
APIGatewayVpcLink
AWSBackupPlan
AWSBackupRecoveryPoint
AWSBackupSelection
AWSBackupVault
AppStreamDirectoryConfig
AppStreamFleet
AppStreamFleetState
AppStreamImage
AppStreamImageBuilder
AppStreamImageBuilderWaiter
AppStreamStack
AppStreamStackFleetAttachment
AutoScalingGroup
AutoScalingPlansScalingPlan
BatchComputeEnvironment
BatchComputeEnvironmentState
BatchJobQueue
BatchJobQueueState
Cloud9Environment
CloudDirectoryDirectory
CloudDirectorySchema
CloudFormationStack
CloudFrontDistribution
CloudFrontDistributionDeployment
CloudHSMV2Cluster
CloudHSMV2ClusterHSM
CloudSearchDomain
CloudTrailTrail
CloudWatchAlarm
CloudWatchDashboard
CloudWatchEventsRule
CloudWatchEventsTarget
CloudWatchLogsDestination
CloudWatchLogsLogGroup
CodeBuildProject
CodeCommitRepository
CodeDeployApplication
CodePipelinePipeline
CodeStarProject
CognitoIdentityPool
CognitoUserPool
CognitoUserPoolDomain
ConfigServiceConfigRule
ConfigServiceConfigurationRecorder
ConfigServiceDeliveryChannel
DAXCluster
DAXParameterGroup
DAXSubnetGroup
DataPipelinePipeline
DatabaseMigrationServiceCertificate
DatabaseMigrationServiceEndpoint
DatabaseMigrationServiceEventSubscription
DatabaseMigrationServiceReplicationInstance
DatabaseMigrationServiceReplicationTask
DatabaseMigrationServiceSubnetGroup
DeviceFarmProject
DirectoryServiceDirectory
DynamoDBTable
DynamoDBTableItem
EC2Address
EC2ClientVpnEndpoint
EC2ClientVpnEndpointAttachment
EC2CustomerGateway
EC2DHCPOption
EC2Image
EC2Instance
EC2InternetGateway
EC2InternetGatewayAttachment
EC2KeyPair
EC2LaunchTemplate
EC2NATGateway
EC2NetworkACL
EC2NetworkInterface
EC2PlacementGroup
EC2RouteTable
EC2SecurityGroup
EC2Snapshot
EC2SpotFleetRequest
EC2Subnet
EC2TGW
EC2TGWAttachment
EC2VPC
EC2VPCEndpoint
EC2VPCEndpointServiceConfiguration
EC2VPCPeeringConnection
EC2VPNConnection
EC2VPNGateway
EC2VPNGatewayAttachment
EC2Volume
ECRRepository
ECSCluster
ECSClusterInstance
ECSService
ECSTaskDefinition
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
IAMPolicy
IAMRole
IAMRolePolicy
IAMRolePolicyAttachment
IAMSAMLProvider
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
MachineLearningBranchPrediction
MachineLearningDataSource
MachineLearningEvaluation
MachineLearningMLModel
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

结论

好吧,如果您需要删除everything并能够过滤掉一些资源,那么我想aws-nuke是您的最佳选择!

翻译自: https://www.javacodegeeks.com/2020/04/destroy-aws-resources-cloud-nuke-or-aws-nuke.html

 类似资料: