Cloud 5.02

Script Configurations

Understanding .magento.env.yaml variables, stages (global/build/deploy), ADMIN variables, and environment configuration.

Exam Critical: Understanding .magento.env.yaml configuration variables is ESSENTIAL! Know which variables go in which stage (global/build/deploy) and their purposes.

Cloud Script Configurations

mindmap root((Environment Variables)) ADMIN Variables Project Web Interface Pre configure admin admin user create stage global MIN_LOGGING_LEVEL X_FRAME_CONFIGURATION stage build SCD_COMPRESSION_LEVEL SCD_COMPRESSION_TIMEOUT SCD_MATRIX VERBOSE_COMMANDS stage deploy CACHE_CONFIGURATION CRON_CONSUMERS_RUNNER SKIP_SCD STATIC_CONTENT_SYMLINK UPDATE_URLS _merge Option Merge with env php Don't overwrite

Environment Variable Configuration Overview

Two Configuration Locations

Location Variable Types Access Method
Project Web Interface ADMIN_*, CRYPT_KEY, env: prefixed variables Cloud Admin UI → Settings
.magento.env.yaml stage/global, stage/build, stage/deploy, log Git repository file

Important: Auto-Redeploy

Setting a variable in the Project Web Interface automatically redeploys the environment!

ADMIN Variables

Admin User Configuration

ADMIN variables are configured in the Project Web Interface and used to configure admin users during Magento installation.

Available ADMIN Variables

  • ADMIN_FIRSTNAME
  • ADMIN_LASTNAME
  • ADMIN_EMAIL (required for automated install)
  • ADMIN_USERNAME
  • ADMIN_PASSWORD

After Installation

After Magento is installed, use this command to create/update admin users:

bin/magento admin:user:create

Note: Despite the name "create", if you specify a username of an existing Magento user, an update will happen instead.

Environment Variables and Magento Configuration

env: Prefix

Environment variables can be used to pre-set Magento configuration values.

Syntax

Variables specified in the Project Web Interface with the env: prefix automatically map to Magento configuration:

env:CONFIG__DEFAULT__SYSTEM__FULL_PAGE_CACHE__CACHING_APPLICATION = 2

This sets: system/full_page_cache/caching_application in the database.

Auto-Update Warning

.magento.env.yaml is updated every time the ece-tools Composer package is updated. Always version control your changes!

stage/global Variables

Global Configuration (All Phases)

Variables in stage/global apply to build, deploy, and post-deploy phases.

Variable Purpose Values
MIN_LOGGING_LEVEL Increases verbosity of logging for debugging debug, info, notice, warning, error, critical, alert, emergency
X_FRAME_CONFIGURATION Updates x-frame-options in app/etc/env.php DENY, SAMEORIGIN, ALLOW-FROM uri

Example Configuration

stage:
  global:
    MIN_LOGGING_LEVEL: debug
    X_FRAME_CONFIGURATION: SAMEORIGIN

stage/build Variables

Build Phase Configuration

Variable Purpose Default
SCD_COMPRESSION_LEVEL How compressed static content should be (0-9) 6
SCD_COMPRESSION_TIMEOUT Maximum time for compressing files (seconds) N/A
SCD_EXCLUDE_THEMES DEPRECATED - Use SCD_MATRIX instead N/A
SCD_MATRIX Specifies which themes and languages to build Empty
VERBOSE_COMMANDS Specifies verbosity flag for commands disabled

Example: SCD_MATRIX

stage:
  build:
    SCD_MATRIX:
      "Magento/backend":
        language:
          - en_US
      "Magento/luma":
        language:
          - en_US
          - fr_FR

stage/deploy Variables

Deploy Phase Configuration

The _merge Option

In service configuration variables (DATABASE_CONFIGURATION, QUEUE_CONFIGURATION, etc.), the _merge option set to true merges existing configuration in app/etc/env.php with the configuration specified in .magento.env.yaml instead of overwriting.

CACHE_CONFIGURATION

Purpose: Specify cache provider (if not Redis) and Redis databases

Use Case: Custom cache backend or specific Redis database configuration

Note: If using custom CACHE_CONFIGURATION, Redis slave connection is NOT available

CLEAN_STATIC_FILES

Purpose: Clears the pub/static directory during deploy

Default: Enabled

Warning: Helpful during development but can cause problems in production if not managed properly

CRON_CONSUMERS_RUNNER

Purpose: Ensures message queues are running after deploy

Use Case: Configure which consumers run automatically and their settings

CRYPT_KEY

Purpose: If NO crypt/key is set in app/etc/env.php, this allows you to specify one

Location: Project Web Interface (NOT in .magento.env.yaml)

Critical: Changing this after installation renders encrypted data useless!

ENABLE_GOOGLE_ANALYTICS

Purpose: Enables Google Analytics in integration and staging

Default: false (disabled)

Use Case: Set to true to enable GA in non-production environments

FORCE_UPDATE_URLS

Purpose: Resets Magento URLs during deployment

Default: true

Applies to:

  • Production or staging (Starter)
  • Any Pro environment

SKIP_SCD

Purpose: Prevents static content deployment during deploy phase

Benefit: Reduces downtime when deploying to production

Best Practice: Enable this and deploy SCD during build phase instead

STATIC_CONTENT_SYMLINK

Purpose: By default, static content is symlinked to init/pub/static

Default: true

Benefit: Three-server configuration on Pro plans can utilize same static content source

Disabled when: SCD_ON_DEMAND is enabled

Why? On-demand deployment writes files, and init/ directory is not writable. Files must be written directly to pub/static.

UPDATE_URLS

Purpose: Updates URLs locally and in integration on Starter plans

Use Case: Automatically update base URLs for non-production environments

VERBOSE_COMMANDS

Purpose: Sends verbose commands to the logs

Use Case: Debugging deployment issues

Complete stage/deploy Example

stage:
  deploy:
    SKIP_SCD: true
    CLEAN_STATIC_FILES: true
    ENABLE_GOOGLE_ANALYTICS: true
    FORCE_UPDATE_URLS: true
    UPDATE_URLS: true
    STATIC_CONTENT_SYMLINK: true
    VERBOSE_COMMANDS: enabled
    CACHE_CONFIGURATION:
      _merge: true
      frontend:
        default:
          backend_options:
            database: 10
    CRON_CONSUMERS_RUNNER:
      cron_run: true
      max_messages: 1000
      consumers:
        - consumer1
        - consumer2

Logging Configuration

log Section in .magento.env.yaml

Configure logging details including email and Slack alerts:

log:
  slack:
    token: YOUR_SLACK_TOKEN
    channel: '#deployment-alerts'
  email:
    to:
      - admin@example.com
      - devops@example.com
    from: noreply@magento-cloud.com

Benefits

  • Receive deployment notifications
  • Alert on errors during build/deploy
  • Track deployment progress in real-time

Variable Summary Table

Stage Variables Common Use
global MIN_LOGGING_LEVEL, X_FRAME_CONFIGURATION Debugging, security headers
build SCD_COMPRESSION_LEVEL, SCD_COMPRESSION_TIMEOUT, SCD_MATRIX, VERBOSE_COMMANDS Static content optimization
deploy SKIP_SCD, CLEAN_STATIC_FILES, CRON_CONSUMERS_RUNNER, ENABLE_GOOGLE_ANALYTICS, STATIC_CONTENT_SYMLINK, UPDATE_URLS, VERBOSE_COMMANDS Deployment optimization, environment configuration
Web Interface ADMIN_*, CRYPT_KEY, env: prefixed Admin setup, encryption, Magento config

Exam Tips

Key Points to Remember

  • ADMIN variables: Project Web Interface only
  • CRYPT_KEY: Project Web Interface, NOT .magento.env.yaml
  • env: prefix: Pre-set Magento configuration from Web Interface
  • Auto-redeploy: Setting Web Interface variables triggers deployment
  • _merge option: Merge with app/etc/env.php instead of overwriting
  • SCD_EXCLUDE_THEMES: DEPRECATED, use SCD_MATRIX
  • SKIP_SCD: Good for production (deploy SCD in build instead)
  • STATIC_CONTENT_SYMLINK: Disabled when SCD_ON_DEMAND enabled
  • CLEAN_STATIC_FILES: Default enabled, careful in production
  • MIN_LOGGING_LEVEL: Set to debug for troubleshooting
  • .magento.env.yaml updates: Happens with ece-tools Composer updates
  • Three stages: global (all phases), build, deploy
  • Logging: Can configure email and Slack alerts