The Declarative Shift for Mobile Releases

Shipping mobile apps, particularly those built with React Native or Expo, involves a repetitive, often undocumented, setup process. Developers typically navigate the Apple Developer portal to create bundle identifiers, configure capabilities, generate provisioning profiles, and select certificates. This is followed by a similar ritual on the Expo dashboard: creating an EAS app, wiring up credentials, and inputting environment variables. This imperative approach, driven by CLIs like fastlane and the EAS CLI, describes what to do but not necessarily what the desired state should be.

This gap becomes apparent when scaling: setting up a second app, a new environment, or onboarding a new team member. The configuration drifts, and crucial details are lost because they aren't codified. The core problem is that traditional mobile tooling is imperative, not declarative. This is where infrastructure-as-code principles, embodied by Terraform, offer a significant advantage.

Terraform's declarative nature means you define the desired end state of your infrastructure. For mobile releases, this translates to defining what your App Store Connect configuration should look like and what your Expo EAS setup should be, allowing Terraform to manage the creation and maintenance of these resources. The elevenode/appstore provider and the official expo/eas provider bridge this gap, bringing declarative configuration to the mobile release pipeline.

Terraform configuration file defining mobile release resources

Unifying App Store Connect Configuration

The elevenode/appstore Terraform provider is designed to manage resources within Apple App Store Connect. This includes the fundamental building blocks of an iOS app's presence on the store: bundle identifiers, app records, and provisioning profiles. Traditionally, these are managed through the Apple Developer website, a manual and error-prone process. With this provider, you can declare these resources in your Terraform configuration.

Consider the appstore_bundle_id resource. Instead of manually creating a bundle identifier in the Apple Developer portal, you define it in HCL (HashiCorp Configuration Language):

resource "appstore_bundle_id" "example" {
  name          = "my-app-bundle-id"
  identifier    = "com.example.myapp"
  capabilities {
    push_notifications = true
  }
}

This configuration not only defines the bundle ID but also specifies required capabilities like push notifications. Terraform ensures that this bundle ID exists and has the correct capabilities. Similarly, the appstore_app resource allows you to manage the primary app record in App Store Connect. This is crucial for associating other resources, like certificates and provisioning profiles, with your specific application.

The management of certificates and provisioning profiles is another area where Terraform shines. Instead of manually generating and uploading certificates or downloading and installing profiles, you can declaratively manage them. The provider can interact with the App Store Connect API to create, revoke, and associate these assets. This declarative approach ensures consistency across environments and simplifies the process of onboarding new developers or setting up new applications.

Leveraging Expo EAS with Terraform

Expo Application Services (EAS) simplifies the build and submission process for Expo and React Native applications. EAS Build handles the compilation of your app, and EAS Submit handles the submission to app stores. The expo/eas Terraform provider allows you to manage EAS-specific configurations declaratively.

Key EAS resources manageable via Terraform include:

  • EAS Projects: Defining your project within EAS.
  • Credentials: Managing credentials required for builds, such as Apple credentials (API keys, push notification keys) and Android keystores.
  • Build Profiles: Defining different build configurations for various environments (e.g., development, staging, production).
  • Environment Variables: Managing secrets and configuration values that your app needs during the build process.

For example, managing Apple credentials for EAS Build can be done using the eas_apple_credential resource. This allows you to create and associate API keys or push notification keys directly from your Terraform configuration, eliminating the need for manual uploads through the Expo dashboard. This is particularly useful for ensuring that build agents have the necessary credentials without exposing them through less secure means.

The eas_project resource ties everything together, representing your application within the Expo ecosystem. By defining your EAS project and its associated resources in Terraform, you create a single source of truth for your mobile app's release infrastructure.

The Power of Declarative Infrastructure-as-Code

The combination of the elevenode/appstore and expo/eas providers brings the benefits of infrastructure-as-code (IaC) to mobile app releases. This declarative approach offers several critical advantages:

  • Consistency: Ensures that your release setup is identical across all environments and for all team members. No more