Simple Wiremock deployment
- Install Scala and ElasticBeanstalkCli on MacOS
$ brew install scala@2.11 $ brew install sbt $ brew install awsebcli (optional - if you want to deploy to aws) $ sbt "runMain com.github.mideo.mockserver.MockServer" (run the app)
Verify the JDK installation on your windows machine by typing the following commands in the command prompt.
-
Ensure javac is added you your windows PATH (if not, add it)
javac -version
-
Installing scala
Download Scala binaries from http://www.scala-lang.org/download/. The Scala installer file will be downloaded with .msi extension. Double Click or Open scala-2.11.6.msi file and select Run. The Setup Wizard appears, click on Next and complete the installation process. Scala installer will set the Path environment variable too, so that you can run it from anywhere.
-
Install ElasticBeanstalkCli on MacOS
$ brew install awsebcli
-
Set up
~/.aws/config
with aws_access_key_id and aws_secret_access_key see documentation[profile eb-cli] aws_access_key_id = XXXX aws_secret_access_key = XXZZZZ
For more information see documentation here
-
Add mapping and files as per example below:
./mocks/mappings/ping.json
{ "request": { "method": "GET", "url": "/ping" }, "response": { "status": 200, "bodyFileName": "ping.json" } }
./mocks/__files/ping.json
{ "ping":"pong" }
Example http request below:
POST /__admin/mappings
Body: {
"request": {
"method":"GET",
"url":"/ping"
},
"response":{
"status":200,
"jsonBody":{"ping":"pong"}
}
}
Will prime the server to return the response below:
GET /ping
Status Code: 200
Body: {
"ping":"pong"
}
- Assemble dependencies and run generated target jar
$ sbt clean assembly $ java -jar target/scala-2.11/mock-server-assembly-0.1.jar mock-server-assembly-0.1.jar
-
Package and deploy artifact
$ sbt clean awsPackage awsDeploy
-
Confirm Mock Server is up by checking App Url
- Install terraform
$ brew install [terraform](https://www.terraform.io/docs)
- Rebuild stack and deploy
$ cd terraform/mock-server # init stack
$ terraform init # init stack
$ terraform destroy # destroy stack
$ terraform plan # dryrun
$ terraform apply # build or update stack
$ cd - # return to OLD_CWD
$ sbt clean awsPackage #package
$ stack=mock-server bin/deploy #deploy mock server
- commit terraform changes i.e. terraform && terraform.tfstate