Use a local emulator
Emulators such as AWS Emulator and LocalStack serve AWS service APIs on your machine. cloudhop gives an emulator an alias like any account, so you work with it the same way:
❯ cloudhop use local[ aws local (us-east-1) ]❯ aws s3 mb s3://test ← goes to the emulator, never to AWS❯ aws dynamodb list-tables❯ cloudhop use acme-dev ← and back to a real accountlocal is an example name; you choose it when you add the emulator.
Add the emulator
Section titled “Add the emulator”Start the emulator as its documentation says, then:
cloudhop addChoose AWS Emulator (local) or LocalStack or another local emulator, accept the defaults (or change the port or endpoint), and name the alias. There is nothing to sign in to. In one line:
cloudhop add aws aws-emulator --name local # https://127.0.0.1:9297cloudhop add aws localstack --name localstack # http://localhost:4566cloudhop add aws localstack --endpoint http://localhost:4567 --name otherYou can also add it from cloudhop ui. Running
one emulator per port, for example one per region? Add each one with its
own port and alias.
Work with it
Section titled “Work with it”Everything you do with an account works with the emulator:
hop local s3 ls # one commandcloudhop use local # this terminal, then plain awscloudhop exec local -- npm test # your tests, with any SDKcloudhop use local --save # this project always uses the emulatorhop local # who am I? account 000000000000Your prompt shows aws local like any alias. A .cloudhoprc with
aws: local is handy for a project whose tests run against the emulator.
What cloudhop sets up
Section titled “What cloudhop sets up”The alias is a profile in ~/.aws/config, so the AWS CLI, SDKs and
Terraform find it too:
[profile local]region = us-east-1endpoint_url = https://127.0.0.1:9297ca_bundle = /Users/you/.aws/emulator/9297/ca.pemcredential_process = cloudhop credentials local- Endpoint. Every request goes to the emulator.
- Keys. AWS Emulator creates new keys every time it starts.
credential_processmakes the AWS CLI ask cloudhop for the current ones on each command, so a restart needs nothing from you and the keys are never written to your config. LocalStack takes the fake keystest/test, written in the profile. - Certificate. AWS Emulator serves HTTPS with a certificate that
changes on every start, in the same file. The profile points at that
file, and
cloudhop execalso passes it to Node.js (NODE_EXTRA_CA_CERTS, when you haven’t set your own). TLS is never turned off.
When the emulator isn’t running
Section titled “When the emulator isn’t running”cloudhop checks before each command and tells you how to start it:
❯ hop local s3 ls✖ The emulator of local isn't running. Start AWS Emulator on port 9297 (`aws-emulator -p 9297` on Linux, its Docker container on macOS and Windows), then try again.cloudhop ls shows emulator running or emulator not running for
each one. cloudhop never starts or stops the emulator for you.
Kept apart from AWS
Section titled “Kept apart from AWS”- An emulator alias never reaches AWS: its endpoint is your machine,
and an endpoint on
amazonaws.comis refused when you add it. - When you switch to it, cloudhop clears any AWS keys left in the terminal,
and
cloudhop execturns off the fallback to a cloud machine’s credentials. - It can’t be marked production and has no web console:
cloudhop console localsays so. - Every emulator answers as account
000000000000. Ifhop localshows another account, something else set an endpoint: checkAWS_ENDPOINT_URLin your terminal.
An operation that answers NotImplemented isn’t covered by the emulator
yet; that is up to the emulator, not cloudhop.