# `ImagePipe.Source.S3.CredentialWarmup`
[🔗](https://github.com/hlindset/image_pipe/blob/v0.2.0/image_pipe/lib/image_pipe/source/s3/credential_warmup.ex#L1)

Fetches S3 credentials from a provider at startup, so the first request
for a bucket doesn't wait for them.

    children = [
      {ImagePipe.Source.S3.CredentialWarmup,
       provider: ImagePipe.Source.S3.InstanceRole, opts: [], scope: "my-bucket"},
      MyAppWeb.Endpoint
    ]

ImagePipe doesn't start it. Add one per bucket. The children need no
explicit ids. Each warmup starts the fetch without blocking startup, then
stops. The credentials aren't dropped before the first request for the
bucket uses them. If the fetch fails, the first request fetches the
credentials instead.

Invalid options raise `ArgumentError` from `start_link/1`. A `:provider`
without `validate_options/1` raises `UndefinedFunctionError`.

## Options

* `:provider` (`t:atom/0`) - Required. The provider module, as in the source's `:credentials`.

* `:scope` (`t:String.t/0`) - Required. The bucket whose credentials to fetch.

* `:opts` (`t:keyword/0`) - The provider's options. They must equal the options in the source's `:credentials`. Otherwise requests use a different cache entry, and the warmed credentials are refreshed in the background without ever being used. The default value is `[]`.

# `start_link`

```elixir
@spec start_link(keyword()) :: GenServer.on_start()
```

---

*Consult [api-reference.md](api-reference.md) for complete listing*
