maintenance/aws-janitor/resources/nat_gateway.go
func (NATGateway) MarkAndSweep(sess *session.Session, acct string, region string, set *Set) error {
	svc := ec2.New(sess, &aws.Config{Region: aws.String(region)})

	inp := &ec2.DescribeNatGatewaysInput{}
	if err := svc.DescribeNatGatewaysPages(inp, func(page *ec2.DescribeNatGatewaysOutput, _ bool) bool {
		for _, gw := range page.NatGateways {
			g := &natGateway{
				Account: acct,
				Region:  region,
				ID:      *gw.NatGatewayId,
			}

			if set.Mark(g) {
				inp := &ec2.DeleteNatGatewayInput{NatGatewayId: gw.NatGatewayId}
				if _, err := svc.DeleteNatGateway(inp); err != nil {
					klog.Warningf("%v: delete failed: %v", g.ARN(), err)
				}
			}
		}
		return true
	}); err != nil {
		return err
	}

	return nil
}
func (NATGateway) MarkAndSweep(sess *session.Session, acct string, region string, set *Set) error {
	svc := ec2.New(sess, &aws.Config{Region: aws.String(region)})

	inp := &ec2.DescribeNatGatewaysInput{}
	if err := svc.DescribeNatGatewaysPages(inp, func(page *ec2.DescribeNatGatewaysOutput, _ bool) bool {
		for _, gw := range page.NatGateways {
			g := &natGateway{
				Account: acct,
				Region:  region,
				ID:      *gw.NatGatewayId,
			}

			if set.Mark(g) {
				inp := &ec2.DeleteNatGatewayInput{NatGatewayId: gw.NatGatewayId}
				if _, err := svc.DeleteNatGateway(inp); err != nil {
					klog.Warningf("%v: delete failed: %v", g.ARN(), err)
				}
			}
		}
		return true
	}); err != nil {
		return err
	}

	return nil
}
func ( NATGateway ) MarkAndSweep ( sess * session . Session , acct string , region string , set * Set ) error { svc := ec2 . New ( sess , & aws . Config { Region : aws . String ( region ) } ) inp := & ec2 . DescribeNatGatewaysInput { } if err := svc . DescribeNatGatewaysPages ( inp , func ( page * ec2 . DescribeNatGatewaysOutput , _ bool ) bool { for _ , gw := range page . NatGateways { g := & natGateway { Account : acct , Region : region , ID : * gw . NatGatewayId , } if set . Mark ( g ) { inp := & ec2 . DeleteNatGatewayInput { NatGatewayId : gw . NatGatewayId } if _ , err := svc . DeleteNatGateway ( inp ) ; err != nil { klog . Warningf ( " " , g . ARN ( ) , err ) } } } return true } ) ; err != nil { return err } return nil }
// MarkAndSweep looks at the provided set, and removes resources older than its TTL that have been previously tagged.
MarkAndSweep looks at the provided set and removes resources older than its TTL that have been previously tagged .