CloudFormation - Stackcounter

CloudFormation Stack Counter

With the client initialization concept from Chapter S3 we can create a stack-counter quite easily:

Counter

func Count() (int){
	input := &cloudformation.DescribeStacksInput{}
	resp, _ := client.DescribeStacks(context.TODO(), input)
	count := len(resp.Stacks)
	return count
}

And the main function is quite short:

func main(){
	count := stackcount.Count()
	fmt.Println("Counting CloudFormation Stacks: ",count)
}

Source

See the full source on github.

Sources