ISO 3166-2 is an ISO standard which defines geocodes. The section that applies to Spain codes the provinces of Spain. There are codes provided for the autonomous communities of Spain but they are not part of the standard.
ES-A
ES-AB
ES-AL
ES-AV
ES-B
ES-BA
ES-BI
ES-BU
ES-C
ES-CA
ES-CC
ES-CE
ES-CO
ES-CR
ES-CS
ES-CU
ES-GC
ES-GI
ES-GR
ES-GU
ES-H
ES-HU
ES-J
ES-L
ES-LE
ES-LO
ES-LU
ES-M
ES-MA
ES-ML
ES-MU
ES-NA
ES-O
ES-OR
ES-P
ES-PM
ES-PO
ES-S
ES-SA
ES-SE
ES-SG
ES-SO
ES-SS
ES-T
ES-TE
ES-TF
ES-TO
ES-V
ES-VA
ES-VI
ES-Z
ES-ZA
_____
ES-AN
ES-AR
ES-IB
ES-PV
ES-CN
ES-CM
ES-CL
ES-CT
ES-EX
ES-GA
ES-VC