Is there a way to wait for snap to be available on boot?

Hi, I hope this is the right place to ask this :slight_smile:

I’m running an AWS AMI based off ubuntu-bionic-18.04-amd64-server- which comes bundled with a snap called “aws”.

I also have some bash scripts running on boot, which I believe run at the same time snap is getting setup (in parallel).

One of my scripts executes /snap/bin/aws, which intermittently fails with the message:

error: unknown command “s3”, see ‘snap help’

I believe there is a race condition between the bash scripts I am running on startup and the availability of the snap aws binary.

If I put a sleep in my script, or call /snap/bin/aws later on, say after 30 seconds, then this is not an issue, it works perfectly.

My question: is there a way I can wait for snaps to be available before running scripts which depend on them?