> For the complete documentation index, see [llms.txt](https://docs.release.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.release.com/guides-and-examples/common-setup-examples/terraform-flask-redis.md).

# Terraform and Flask

In this tutorial, we'll learn how to deploy a Python Flask application that queries a Redis database hosted by AWS ElastiCache.

Instead of manually configuring Redis on ElastiCache, we'll use Terraform with Release's infrastructure runners to provision a Redis cluster.

We'll start with the [`awesome-release/release-terraform-flask-redis`](https://github.com/awesome-release/release-terraform-flask-redis) application.

## Step 1: Fork the GitHub repo

Fork [`awesome-release/release-terraform-flask-redis`](https://github.com/awesome-release/release-terraform-flask-redis) on GitHub using the account you have authenticated with Release.

## Step 2: Create a new Release application

![Create a new Release application, step one](https://585411240-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M1neGLLQ0sDXeK6ooSo%2Fuploads%2Fgit-blob-df9e8dbc749e08e654699c42f4c383f20023589b%2Fterraform-example-create-application-one.png?alt=media\&token=892c3ffa-d0be-401b-aa67-23c001c222a2)

1. Enter a unique name for your application.
2. Select the fork you created in step 1.
3. Click **Next Step**.

![Create a new Release application, step two](https://585411240-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M1neGLLQ0sDXeK6ooSo%2Fuploads%2Fgit-blob-4b476e4d3473ed1f685a291ea61ffc2ee7e74559%2Fterraform-example-create-application-two.png?alt=media\&token=b9b3f89e-3665-4f45-881b-60f20982d07c)

1. Select the `main` branch.
2. Select `compose.yaml`.
3. Click **Start Analysis**.

![Create a new Release application, step three](https://585411240-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M1neGLLQ0sDXeK6ooSo%2Fuploads%2Fgit-blob-b3553b9d58bda85ff96f3df5226a431e9f526257%2Fterraform-example-create-application-three.png?alt=media\&token=2e5607a9-da3a-4b8a-8319-279b2b60ad24)

1. Click **Next Step**.

![Create a new Release application, step four](https://585411240-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M1neGLLQ0sDXeK6ooSo%2Fuploads%2Fgit-blob-f0fc67e825ad96652dac2823f3986a5de67c7c2b%2Fterraform-example-create-application-four.png?alt=media\&token=702cd2df-d1e5-4cf2-aafb-22ee850afcd8)

1. Select the `main` branch.
2. Select `.release/application_template.yaml`.
3. Make sure the application's context and domain are correct.
4. Click **Next Step**.

![Create a new Release application, step five](https://585411240-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M1neGLLQ0sDXeK6ooSo%2Fuploads%2Fgit-blob-e7805ec3ac84b893e00ba28b429857be5c2dda84%2Fterraform-example-create-application-five.png?alt=media\&token=39150af8-832d-41d6-980f-7104257f96a7)

1. Select `.release/environment_variables.yaml`.
2. Click **Next Step**.

![Create a new Release application, step six](https://585411240-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M1neGLLQ0sDXeK6ooSo%2Fuploads%2Fgit-blob-e2bda2f67cbf49a46e2183b9e6da48cef356e714%2Fterraform-example-create-application-six.png?alt=media\&token=3b2d0091-6da0-4adc-bc6e-7bddb6a984ad)

1. Click **Deploy your app!**

## Step 3: Follow the deployment

![Release deployment terraform](https://585411240-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M1neGLLQ0sDXeK6ooSo%2Fuploads%2Fgit-blob-de5d3de9a90e453c5abb754b699d8f75ee9ca428%2Fterraform-example-deploy.png?alt=media\&token=0f4dc262-928f-4f98-a31e-2aef684b8416)

Release will build and deploy your application. Open the infrastructure runner step to see output from Terraform.

## Step 4: View the environment

![Release environment detail page](https://585411240-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M1neGLLQ0sDXeK6ooSo%2Fuploads%2Fgit-blob-f1587c84786d89a32efa88b475b0b2c08824b02f%2Fterraform-example-environment-detail.png?alt=media\&token=b21f3a8f-b7ab-48a9-8743-b9b7909bd388)

View the environment detail page and click on the web URL.

## Result

![Release result](https://585411240-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M1neGLLQ0sDXeK6ooSo%2Fuploads%2Fgit-blob-1460aad46a69de75d137a6c912fb81d7246a0042%2Fterraform-example-result.png?alt=media\&token=957e5edc-3e71-4dc5-83b8-f3ff0043253b)

You should see HTML output showing the number of times this application has been viewed.

If the resulting view count is more than you anticipated, keep in mind that Release's health checker makes an HTTP request, which counts as a page view in our example.

## Further reading

* [Get started with Terraform](https://docs.releasehub.com/guides-and-examples/advanced-guides/infrastructure/terraform) – Release documentation about using Terraform
* [Infrastructure as code (IaC)](https://docs.releasehub.com/guides-and-examples/advanced-guides/infrastructure) – Release documentation about IaC


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.release.com/guides-and-examples/common-setup-examples/terraform-flask-redis.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
