tnc-ca-geo / animl-ingest

Lambda function for processing camera trap images
Other
0 stars 1 forks source link

Could you please provide an example of your SSM config dictionary #41

Closed postfalk closed 1 year ago

postfalk commented 1 year ago

Thank you!

postfalk commented 1 year ago

Why does it have this path names that just get chopped off. Couldn't we just store the plain key in that dic?

nathanielrindlaub commented 1 year ago

Mind elaborating on the path names getting chopped off questions?

postfalk commented 1 year ago

Well put that in the wrong issue, never mind.

postfalk commented 1 year ago

Oh, no I didn't. I am a little bit overwhelmed currently. Ok, here is the example:

Why do we have

SSM_NAMES = {
    'ANIML_API_URL': f'/api/url-{config.STAGE}',
    'BATCH_QUEUE': f'/images/batch-queue-{config.STAGE}',
    'BATCH_JOB': f'/images/batch-job-{config.STAGE}',
    'ARCHIVE_BUCKET': f'/images/archive-bucket-{config.STAGE}',
    'SERVING_BUCKET': f'/images/serving-bucket-{config.STAGE}',
    'DEADLETTER_BUCKET': f'/images/dead-letter-bucket-{config.STAGE}'}

Just to do

param_name = value.split("/")[-1]

further down? Could just be

SSM_NAMES = {
    'ANIML_API_URL': f'url-{config.STAGE}',
    'BATCH_QUEUE': f'batch-queue-{config.STAGE}',
    'BATCH_JOB': f'batch-job-{config.STAGE}',
    'ARCHIVE_BUCKET': f'archive-bucket-{config.STAGE}',
    'SERVING_BUCKET': f'serving-bucket-{config.STAGE}',
    'DEADLETTER_BUCKET': f'dead-letter-bucket-{config.STAGE}'}

We are not using this anywhere else. And if we were to I would think constructing these path names would be better than deconstructing them.

nathanielrindlaub commented 1 year ago

Do you have access to the Animl AWS account? If you do, check out the Systems Manger > Parameter Store (SSM) values. We use the "paths" just for organizational purposes b/c there are a lot of params in there and a bunch of the other animl services/repos draw from them too (that's a recommended best practice I read about in the AWS docs).

Your question about why we chop off the path is a good one though and I had to look into it to refresh my memory - it's because the Python lambda-cache utility we use stores the name of the parameter as the string after the last slash('/') character of its name (see "Change cache entry settings" section of the lambda-cache docs for more on that). I'm not totally sure why it does that but it's the default behavior.

Does that answer your question?