With the client initialization concept from Chapter S3 we can create a stack-counter quite easily:
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)
}
See the full source on github.