Turn S3 off or on in LocalStack with Commandeer

...
  • Localstack
  • S3
  • Commandeer
  • Start service
  • Stop service
About 1 min

# Turn S3 off or on in LocalStack with Commandeer

Sometimes for testing, you may want to test with a non-responsive S3 endpoint, to simulate a network outage. You can turn it on or off when connected to your local environment via LocalStack.

# 1. Connect to a local account

Your local account points to LocalStack for AWS api calls to over 24 services.

# 2. Go to the LocalStack Dashboard

On the localstack dashboard, you can filter to see the status of S3. Here you can see it is on and has 22 buckets.

# 3. Select the S3 service

Once selected, you can view the S3 service here.

# 4. Press the Stop Button

You will see it says running or loading. This is the status while it is stopping.

You can also start and stop the services in their entirety. Back on the LocalStack Dashboard page you can see the status of starting up the LocalStack docker instance in the terminal.

Under the hood, LocalStack is running in a Docker Container, and pressing the Docker Container button will take you to the instance.

# 5. S3 is off

Normally, you will be hitting http://localhost:4572 to get data from S3 on LocalStack. As you can see below, that port is now off.

# 6. Test it out

If you go to the S3 Dashboard under AWS. You should not see any data any longer. You also will get a Network Failure when pressing the refresh button. You can now run your suite of unit tests against a broken S3 connection.

# 7. Turn S3 back on

You can turn the service back on by pressing the Start button back on the LocalStack S3 instance.

You can see that the status is 'Connection failed'. Pressing the Start button will bring it back up.

# 8. S3 is back on

Below you can see that you can now create buckets, add files, etc. to S3. It is fully operational.

# Conclusion

Turning S3 on and off is a very helpful way to test out catastrophic failures on your system, such as if a data center goes down, or a network connection is lost by a user. Testing this out on your local environment is a great way to do this. By turning your own wifi off, and having no connection, being able to see how your api endpoints behave can be invaluable.

Last update: July 26, 2020 22:45