5

Does any AWS service or solution offer sequence functionality similar to SQL Sequences as found in Postgres or Oracle (or any other RDBMS), without having to maintain an entire Postgres instance?

I do have access to RDS if needed, but I'm wondering if it's overkill just for one sequence and whether theres a simpler/cheaper solution.

Ideally the sequence would be 8 digit numbers, and not needed at a particularly high volume (just a few thousand per day).

Edit: Possible duplicate of Distributed sequence number generation?

Edit 2: To clarify, the goal is to have uniqueness, with simple numbers. Number order is not important, as long as they are unique.

James Daily
  • 587
  • 6
  • 21
  • 2
    I believe that DynamoDB supports atomic update of numeric values, but don't have the time right now to verify or give a code example (what language are you using?). Also, given that you've looked at the other question, are you able to use a UUID rather than an atomic sequence? – kdgregory Sep 13 '18 at 20:21
  • Thank you, language is Java. These are for customer-facing ID's similar to order numbers, so a UUID isn't quite right for my use case. – James Daily Sep 14 '18 at 16:03

1 Answers1

10

If you are okay with simply having unique IDs (without being sequential), AWS Key Management Service (KMS) has a GenerateRandom function. The chance of duplication is very small.

Or, you could go with a traditional GUID/UUID.

However, if you want the IDs to be sequential, then you will need somewhere to store the value:

  • Amazon DynamoDB is a convenient datastore that offers a much lower cost than an Amazon RDS instance. There is even an Atomic counter that can increment and return the count.
  • If your volume isn't very high, you could consider storing the value in the AWS Systems Manager Parameter Store, which has simple Put/Get capabilities and zero cost.
John Rotenstein
  • 241,921
  • 22
  • 380
  • 470