Skip to main content
The Community Terraform Provider for Microsoft 365 empowers workplace teams and administrators to manage their Microsoft 365 environments using Infrastructure as Code (IaC) principles. This provider bridges the gap between Terraform’s powerful resource management capabilities and the extensive features of Microsoft 365.
This provider is currently in experimental status. It is NOT intended for production use and may contain bugs, incomplete features, or other issues. Use at your own risk, as it may undergo significant changes without notice until it reaches general availability.
This is a community-driven project and is not officially supported by Microsoft. For help, questions, or to connect with other users and contributors, join the community Discord server.

What you can manage

The provider supports management of resources across multiple Microsoft cloud services:
  • Microsoft Intune - Device and app management, compliance policies, configuration profiles
  • Microsoft Entra ID (formerly Azure AD) - Users, groups, conditional access policies, authentication methods
  • Microsoft 365 - Tenant-wide settings, app installation options, admin configurations
  • Microsoft Teams - Teams policies, calling policies, meeting configurations
  • Microsoft Defender - Security policies and configurations
  • Windows 365 - Cloud PC provisioning, user settings, device images, network connections

Key features

Wide resource coverage

Manage users, groups, devices, policies, and administrative resources across Microsoft services

Multi-cloud compatible

Works with Microsoft public cloud, US Government (GCC, GCC High, DoD), China, and other national clouds

Flexible authentication

Supports 11 authentication methods including client secret, certificate, managed identity, OIDC, and more

Microsoft Graph SDK

Built on Kiota-generated Graph SDKs for strongly-typed development and support for v1.0 and beta endpoints

Use cases

Infrastructure as code for Microsoft 365

Manage Microsoft 365 configuration (users, groups, policies, device management, and more) as code, enabling version control, peer review, and repeatable deployments—just as you would for cloud infrastructure in Azure or GCP.

Automated, auditable change management

Use Terraform’s plan and apply in GitOps workflows to preview, approve, and track changes to your Microsoft 365 environment, ensuring all modifications are intentional, reviewed, and logged.

Environment replication and drift detection

Reproduce Microsoft 365 tenant configurations across multiple environments (development, staging, production) or tenants, and detect configuration drift over time using Terraform’s state management.

Disaster recovery and rapid rebuilds

Store your Microsoft 365 configuration in code, allowing for rapid recovery or migration of tenant settings, policies, and assignments in the event of accidental changes or tenant loss.

Bulk and consistent policy enforcement

Apply security, compliance, and device management policies at scale, ensuring consistency and reducing manual configuration errors across large organizations or multiple tenants.

Self-service via Terraform modules

Build reusable Terraform modules for common Microsoft 365 workloads, enabling service-owning teams to provide self-service provisioning to other engineering teams while maintaining standards.

Integration with policy-as-code

Integrate with Open Policy Agent (OPA) or Conftest to enforce organizational standards, compliance, and guardrails on Microsoft 365 resources before deployment.

Requirements

Before you begin, ensure you have:
  • Terraform >= 1.14.x installed
  • A Microsoft 365 tenant with appropriate licenses
  • An Entra ID application registration with the necessary API permissions
  • Administrative access to configure authentication
For detailed setup instructions, see the Installation guide.

Supported cloud environments

The provider works with multiple Microsoft cloud environments:
EnvironmentCloud ValueDescription
Public CloudpublicMicrosoft Azure Public Cloud (default)
US GovernmentgccUS Government Cloud
US Government HighgcchighUS Government High Cloud
US Department of DefensedodUS DoD Cloud
China CloudchinaMicrosoft Cloud China (operated by 21Vianet)
EagleX CloudexEagleX Cloud environment
Secure CloudrxSecure Cloud (RX) environment

Example resources

Here are some of the resources you can manage with this provider:
  • microsoft365_graph_beta_users_user - Create and manage user accounts
  • microsoft365_graph_beta_groups_group - Manage security and Microsoft 365 groups
  • microsoft365_graph_beta_identity_and_access_conditional_access_policy - Configure conditional access policies
  • microsoft365_graph_beta_groups_group_member_assignment - Assign users to groups
  • microsoft365_graph_beta_device_management_windows_update_ring - Manage Windows update policies
  • microsoft365_graph_beta_windows_365_cloud_pc_provisioning_policy - Configure Cloud PC provisioning
For a complete list of resources, see the Terraform Registry documentation.

Getting help

Quick start guide

Get up and running in minutes

Discord community

Ask questions and connect with other users

GitHub issues

Report bugs and request features

Important disclaimers

While every effort is made to maintain accuracy and reliability, you should thoroughly test configurations in non-production environments before deploying to production. Always refer to official Microsoft documentation for the most up-to-date information on Microsoft 365 services and features.

Data collection and telemetry

The provider may collect information about your use of the software and send it to Microsoft. You can opt out of telemetry by setting telemetry_optout = true in your provider configuration or using the M365_TELEMETRY_OPTOUT environment variable. See Microsoft’s privacy statement for more information.

Next steps

1

Install the provider

Follow the Installation guide to add the provider to your Terraform configuration
2

Configure authentication

Set up one of the 11 supported authentication methods for your environment
3

Try the quick start

Deploy your first Microsoft 365 resources using the Quick start guide

Build docs developers (and LLMs) love