Error: Unsupported attribute , each.value is object with 2 attributes

The object key corresponding to the security groups in the value for the map with the a key needs to match the keys in the other object values in the maps:

a = {
  subnet_id       = module.vpc.public_subnets[0],
  security_groups = [aws_security_group.ssh.id],
},