Automated Flutter app deployment

March 5, 2025 Henry Jaramillo

A simplified guide for setting up automated Flutter app deployment to Raspberry Pi devices using AWS services.

Flutter Deployment Flow

Table of Contents

  1. Prerequisites
  2. Repository Setup
  3. AWS Authentication
  4. Infrastructure Setup
  5. Raspberry Pi Configuration

Prerequisites

Hardware Requirements 🔧

Component Specification
Raspberry Pi Zero or newer
Storage MicroSD card (16GB+ recommended)
Power Compatible power supply
Display Raspberry Pi compatible display
Raspberry Pi Zero


Software Requirements 💻

Software Version/Details
AWS Account Active account with admin access
GitHub Account Active account with repository access
Flutter SDK ≥3.0.3
Git Latest version
AWS CLI Installed and configured
Raspberry Pi OS Lite (64-bit recommended)
AWS


Repository Setup

  • Create Project Directory

    mkdir flutter-app

    cd flutter-app

  • Clone Infrastructure Repository

    git clone https://github.com/[original-owner]/infra.git

  • Repository Configuration

    • Create Repositories

      • Create a new empty repository for infrastructure
      • Create/use existing Flutter application repository
    • Configure Infrastructure Repository:

      cd infra

      git remote remove origin

      git remote add origin https://github.com/[your-username]/infra.git

      git push -u origin main

  • Setup CI/CD Workflow

    • Create workflows directory in Flutter app

      mkdir -p /path/to/your/flutter/app/.github/workflows

    • Copy workflow configuration

      cp infra/.github/workflows/flutter-build.yml /path/to/your/flutter/app/.github/workflows/

AWS Authentication Setup

Choose your preferred authentication method (OpenID Connect, AWS Access Keys, or AWS SSO) and configure it according to your organization’s security requirements and best practices. Make sure to:

  • Set up the chosen authentication method in AWS
  • Configure the necessary secrets in your GitHub repositories
  • Update your workflow files to use the selected authentication method

Infrastructure Configuration and Deployment

  • Configure Infrastructure

    • Navigate to infrastructure repository

    • Update config/config.toml:

      version = 0.1

      [default.deploy.parameters]

      stack_name = "your-stack-name" # Choose unique name

      region = "us-east-1" # Your AWS region

      capabilities = "CAPABILITY_IAM CAPABILITY_NAMED_IAM CAPABILITY_AUTO_EXPAND"

      resolve_s3 = true

      s3_prefix = "your-prefix" # Choose unique prefix

      disable_rollback = false

  • Deploy Infrastructure

    • Push Changes

      git add .

      git commit -m "Update infrastructure configuration"

      git push origin main

    • Monitor Deployment:

      • GitHub Actions progress
      • CloudFormation stack creation
      • CloudWatch logs

    • Verify Resources:

      • CloudFormation stack complete
      • S3 bucket created
      • IAM roles/policies configured
      • SSM documents available

Raspberry Pi Setup and AWS SSM Configuration

  • Initial Raspberry Pi Setup

    • Download Raspberry Pi Imager from official website
    • Launch Raspberry Pi Imager
    • Select your device (e.g., Raspberry Pi Zero 2 W)
    • Choose Raspberry Pi OS Lite (64-bit)
    • Select your microSD card
    • Configure OS Settings in Raspberry Pi Imager
    • Enable SSH
    • Write the OS to SD card and insert it into your Raspberry Pi
    Raspberry pi setup
  • Initial System Configuration

    • Connect to Raspberry Pi via SSH

      ssh username@hostname

      Example: ssh pi@raspberrypi

  • AWS Systems Manager Setup

    • Create Hybrid Activation:
      • Go to AWS Console → Systems Manager
      • Navigate to Node Management → Hybrid Activations
      • Click “Create activation”
      • Fill in required information
      • Save the Activation Code and Activation ID
Hybrid activation
  • Install SSM Agent on Raspberry Pi:

    Set your variables

    export REGION=us-east-1 # Replace with your AWS region

    export ACTIVATION_CODE=your_activation_code

    export ACTIVATION_ID=your_activation_id

    Create temporary directory

    mkdir /tmp/ssm

    Download SSM setup CLI

    curl https://amazon-ssm-${REGION}\ s3.${REGION}.amazonaws.com/latest/debian_arm/ssm-setup-cli\ -o /tmp/ssm/ssm-setup-cli

    Make it executable

    sudo chmod +x /tmp/ssm/ssm-setup-cli

    Register the device

    sudo /tmp/ssm/ssm-setup-cli -register \

    -activation-code $ACTIVATION_CODE \

    -activation-id $ACTIVATION_ID \

    -region $REGION

  • Verify Registration:

    • Go to AWS Systems Manager → Fleet Manager
    • Your Raspberry Pi should appear in the managed instances list
      Fleet manager



Conclusion

This simplified guide provides the essential steps to set up Flutter application deployment to Raspberry Pi devices using AWS services. The solution offers:

  • Automated device management
  • Secure infrastructure
  • Streamlined deployment process
  • Easy scalability
  • Basic monitoring capabilities
  • Automatic updates: Every push to your Flutter app repository triggers the workflow, automatically updating the application on all connected Raspberry Pi devices

For more advanced configurations or detailed information about specific components, refer to the complete documentation or AWS documentation.

Henry Jaramillo
About the Author

Subscribe to Our Newsletter

Stay updated with our latest insights on DevOps, cloud infrastructure, and software development.