Esempio n. 1
0
func Process(ctx context.Context, region string) {
	ctx.Print("  Processing elastic search resources...")
	svc := elasticsearchservice.New(ctx.AwsSession, &aws.Config{Region: aws.String(region)})

	processARNs := func(resourceIds []*string) {
		nextWindow := func(ids []*string) ([]*string, []*string) {
			w := int(math.Min(float64(len(ids)), float64(200)))
			return ids[0:w], ids[w:]
		}

		for thisRound, remaining := nextWindow(resourceIds); len(thisRound) > 0; thisRound, remaining = nextWindow(remaining) {
			updateTags(ctx, *svc, thisRound)
			deleteTags(ctx, *svc, thisRound)
			printTags(ctx, *svc, thisRound)
		}
	}

	processARNs(getArns(svc))
}
Esempio n. 2
0
func Process(ctx context.Context, region string) {
	svc := ec2.New(ctx.AwsSession, &aws.Config{Region: aws.String(region)})

	switch {

	case ctx.TagFlags.Ec2Instances:
		ctx.Print("  Processing EC2 instances...")
		processInstances(svc, &ctx.BatchSize, applyTags(ctx, svc))
		fallthrough

	case ctx.TagFlags.Ec2Amis:
		ctx.Print("  Processing EC2 AMIs...")
		processAmis(svc, ctx.BatchSize, applyTags(ctx, svc))
		fallthrough

	case ctx.TagFlags.Ec2Volumes:
		ctx.Print("  Processing EC2 volumes...")
		processVolumes(svc, ctx.BatchSize, applyTags(ctx, svc))
		fallthrough

	case ctx.TagFlags.Ec2Snapshots:
		ctx.Print("  Processing EC2 snapshots...")
		processSnapshots(svc, ctx.BatchSize, applyTags(ctx, svc))
		fallthrough

	case ctx.TagFlags.Ec2Vpcs:
		ctx.Print("  Processing EC2 VPCs...")
		processVpcs(svc, ctx.BatchSize, applyTags(ctx, svc))
		fallthrough

	case ctx.TagFlags.Ec2SecurityGroups:
		ctx.Print("  Processing EC2 security groups...")
		processSecurityGroups(svc, ctx.BatchSize, applyTags(ctx, svc))
		fallthrough

	case ctx.TagFlags.Ec2NetInterfaces:
		ctx.Print("  Processing EC2 network interfaces...")
		processNetInterfaces(svc, ctx.BatchSize, applyTags(ctx, svc))
	}
}