liveBook · Manning

.ebextensions

As explained in Build Python Web Apps with Streamlit

.ebextensions is a directory containing Elastic Beanstalk configuration files that customize an environment before an application starts.

.ebextensions is a directory in an application’s root folder containing instructions that Elastic Beanstalk processes before the application starts. It customizes the hosting environment when local filesystem mounting is unavailable. section 12.3.5

A configuration file can prepare a deployment by:

Providing Streamlit secrets

Create .ebextensions/secrets_file.config with a files entry targeting /var/app/secrets/.streamlit/secrets.toml. Set mode to 000644, assign ownership to webapp, and place the secrets.toml contents under content. An edited docker-compose.yml can then mount /var/app/secrets/.streamlit into /app/.streamlit.

Listing 12.5 .ebextensions/secrets_file.config
files:
  "/var/app/secrets/.streamlit/secrets.toml":
    mode: "000644"
    owner: webapp
    group: webapp
    content: |
      llm_api_key = "sk-proj-..."    #1

Inspect the complete configuration example for generating a secrets.toml file during Elastic Beanstalk deployment. section 12.3.5

How Build Python Web Apps with Streamlit covers it

How deep it goes
Explains directory placement, generated files, multiline content, permissions, ownership, and Docker Compose mounting.
Examples
Uses secrets_file.config to create secrets.toml and mounts the generated directory into the application container.
What it assumes
Assumes familiarity with Docker Compose and a local .streamlit directory, while explaining why that mounting approach fails on Elastic Beanstalk.
What you can do after
Operate/configure Elastic Beanstalk deployments with generated secret files and controlled file ownership and permissions.
How it connects
Connects Elastic Beanstalk with Streamlit, Docker Compose, secrets.toml, and EC2.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Build Python Web Apps with Streamlit. The section links point to the parts of the book it draws on.