We know we can define a Terraform module that produces output for another module to use as input. But how can we build dynamic output from a module that creates a set resources, and format that output just right to act as input elsewhere? It’s possible with the help of Terraform for
and for_each
expressions and the zipmap
function. Keep reading to learn more!
While building out a set of Terraform modules to define some AWS resources at The Flatiron School, we ran into an interesting challenge. We needed to be able to do the following:
In a previous post, we introduced the Railway family of libraries for building messaging patterns between applications on our Learn.co ecosystem. We saw how these tools allowed us build robust async messaging systems in Elixir and Ruby with very little hand-rolled code. In this post, we'll learn how to use Railway to enact synchronous messaging patterns, also knows as 'RPC' (Remote Procedure Calls).
Before we talk about what RPC is and how Railway allows us to enact it, I want to share a scary story. If you recall from our last post, we are responsible for building out the a…
IPC, which stands for Inter-Process Communication, is something you want if you can answer “yes” to any of these questions:
Then you might benefit from a sane, extensible IPC messaging pattern within your technology architecture.
As our business grows, we need to meet the needs of more and more groups of…
Elixir has become famous as the shiny new “concurrent” programming language, with more and more former OO devotees flocking to it every day. But what actually makes Elixir concurrent? To find out, we need to understand OTP and the Erlang VM.
Coming to Elixir from a Ruby and JS background, I understood that concurrency was something I wanted in a language. However, even after a few years of programming Elixir, I didn’t really understand how it operates concurrently. …
In a recent post, we talked about the age-old question: How can you test code that relies on external services, like an API? We don’t want slow-running tests that make web requests to external services, potentially impacting things like API rate limits, production data and the overall reliability of our test suite.
This consideration often leads us to reach for a test mock. However, we want to be careful of how we think about “mocking”. When we mock certain interactions by creating unique function stubs in a given test example, we establish a dangerous pattern. We couple the run of…
What should you do when testing Elixir code that makes web requests to an external API? We don’t want to let our code make those requests during a test run — we’ll slow down our tests and potentially use up API rate limits. We could mock such requests with the help of a mocking library or use recorded requests with the help of recording library. We’ll show you why you should avoid these approaches and instead roll your own mock server for your test environment.
While there are a number of web request recording libraries in Elixir, there are *also*…
mix ecto.migrate
This post was originally published on Sophie’s blog, The Great Code Adventure.
You need to run your migrations with the production release of your Elixir app in your production environment. You can’t use mix! You can use Ecto Migrator. Read on to find out how to run your Ecto migrations in production using Distillery’s Boot Hooks.
Coming from a Rails background, I just sort of expected to be able to execute my migrations in the production environment exactly like I would in dev.
mix ecto.migrate
I was confused with my attempts to do so in production were met with:
**…
This post was originally published on on Sophie’s blog, The Great Code Adventure.
JSON Web Tokens, or JWTs, allow us to authenticate requests between the client and the server by encrypting authentication information into a compact JSON object that is digitally signed. In this post, we’ll use the Joken library to implement JWT auth in a Phoenix app. We’ll focus on JWTs that are signed using a ECDSA private/public key pair, although you can also sign JWTs using an HMAC algorithm.
First things first, we need to include the Joken package in our application’s dependencies:
Run mix deps.get
and…