I have this in a Dockerfile:
ARG aws_access_key_id
ARG aws_secret_access_key
even though I did not use any --build-arg options, it still built successfully, how can I make it fail if those arguments are missing?
You can set some default values that will never be used and then test if those are the values. For example:
FROM alpine
ARG arg=NO_VALUE
RUN [ ! "${arg}" == "NO_VALUE" ]