You have it exactly right: use a before a consonant sound and an before a vowel sound. If the abbreviation is read as its letters, the initial sound of the name of the first letter dictates.
I would make two notes, however. First, either article may be acceptable in cases where there are multiple accepted pronunciations, one starting with a vowel sound and one with a consonant sound. For example, an history is generally a hypercorrection for a history in American English, since Americans almost always pronounce the h. But it isn't strictly incorrect, because there are dialects of English where the h is dropped. Some abbreviations (initialisms as another answer points out) are read as letters, others (acronyms) as words, and depending on the author's usage you may see both
an SQL query = an ess cue ell query
an FAQ document = an eff aiee cue document
an NAS system = an enn aiee ess system
and
a SQL query = a sequel query
a FAQ document = a fack document
a NAS system = a nazz system
The key in your writing (and speaking) is to be consistent. There are many opinions in the technology world about how to vocalize a term; try a web search on "gif pronunciation" some time.
Second, as a matter of usage one can be a U.S. citizen, a United States citizen, an American citizen, or a citizen of the United States of America, but one is hardly ever referred to as a USA citizen.