Hi, we're looking to use wiremock to mock AWS SSM ...
# help
g
Hi, we're looking to use wiremock to mock AWS SSM locally to pull in env vars using the following:
Copy code
env:
    image: wiremock/wiremock
    healthcheck:
      test:
        - CMD-SHELL
        - wget --server-response -qO /dev/null <http://localhost:8080/__admin> 2>&1 | grep 'HTTP/1.1 200 OK' || exit 1
      interval: 10s
      timeout: 3s
      retries: 30
    command:
      - --disable-banner
      - --global-response-templating
      - --permitted-system-keys=.*
    env_file:
      - /location/of/locally/decrypted/vars/.env
    volumes:
      - /location/of/wiremock/files:/home/wiremock:ro
And want to use the following but keep getting an error when trying to set
key
to something "dynamic"
Copy code
{
  "request": {
    "method": "GET",
    "urlPath": "/systemsmanager/parameters/get/",
    "queryParameters": {
      "name": {
        "matches": "^/path/to/env/var/([A-Z_]+)$"
      }
    }
  },
  "response": {
    "jsonBody": {
      "Name": "{{request.query.name}}",
      "SecretString": "{{systemValue type='ENVIRONMENT' key='{{regexExtract request.query.name '[A-Z_]+'}}'}}"
    }
  }
}
Is what we're trying to do even possible? Or do we have to explicitly set "key" to a string value?
t
You’re pretty close but need to use an inner Handlebars expression for the key:
Copy code
{{systemValue type='ENVIRONMENT' key=(regexExtract request.query.name '[A-Z_]+')}}
g
Ah cool, thanks, I wondered if I was missing something but couldn’t quite find it in the docs
I will try this tomorrow
👍 1
Works perfectly, thanks
t
Glad to hear it!
g
This is going to make replicating the AWS Secrets Lambda Layer locally so much easier
t
Good to hear you're getting value from it. AWS services can be a pain to test against.