client_options block configures the behavior of the Microsoft Graph HTTP client used by the provider.
Basic Configuration
Configuration Parameters
Retry Configuration
Enable automatic retries for failed requests.When enabled, the provider will automatically retry requests that fail due to transient errors such as network timeouts or rate limiting.Can be set using the
M365_ENABLE_RETRY environment variable.Maximum number of retries for failed requests.The provider will retry failed requests up to this many times before giving up. Retries use exponential backoff with jitter to avoid overwhelming the API.Can be set using the
M365_MAX_RETRIES environment variable.Base delay between retry attempts in seconds.The actual delay uses exponential backoff based on this value. For example, with a base delay of 5 seconds:
- 1st retry: ~5 seconds + jitter
- 2nd retry: ~10 seconds + jitter
- 3rd retry: ~20 seconds + jitter
M365_RETRY_DELAY_SECONDS environment variable.- Automatic retries are triggered for the following HTTP status codes:
408- Request Timeout429- Too Many Requests (Rate Limiting)500- Internal Server Error502- Bad Gateway503- Service Unavailable504- Gateway Timeout
- Uses exponential backoff with jitter to prevent thundering herd problems
- Maximum retry delay is 10x the base retry delay
Redirect Configuration
Enable automatic following of HTTP redirects.When enabled, the provider will automatically follow HTTP 3xx redirect responses.
Maximum number of redirects to follow.Prevents infinite redirect loops by limiting the number of consecutive redirects that will be followed.
Compression
Enable compression for HTTP requests and responses.When enabled, the provider will use gzip compression for request and response bodies, reducing bandwidth usage and improving performance.Can be set using the
M365_ENABLE_COMPRESSION environment variable.Timeout
Timeout for HTTP requests in seconds.The maximum time to wait for a request to complete. Requests that exceed this timeout will be cancelled.Can be set using the
M365_TIMEOUT_SECONDS environment variable.Headers and Telemetry
Enable inspection of HTTP headers.When enabled, the provider will log HTTP request and response headers for debugging purposes.Can be set using the
M365_ENABLE_HEADERS_INSPECTION environment variable.Custom User-Agent string to be sent with requests.If not specified, the provider uses a default User-Agent that includes the provider version and Terraform version.Can be set using the
M365_CUSTOM_USER_AGENT environment variable.Complete Example
Using Environment Variables
Chaos Testing (Development Only)
The provider includes chaos testing capabilities to simulate API failures and test error handling:Enable the chaos handler for testing purposes.When enabled, the chaos handler simulates failure scenarios and random errors in API responses to test the robustness and resilience of your Terraform configurations.Can be set using the
M365_ENABLE_CHAOS environment variable.Percentage of requests to apply chaos testing to (0-100).Determines the probability of injecting chaos into each request. Higher values increase the frequency of simulated errors.Can be set using the
M365_CHAOS_PERCENTAGE environment variable.HTTP status code to return for chaos-affected requests.If not set, a random error status code will be used. Common error codes include:
429- Too Many Requests500- Internal Server Error503- Service Unavailable
M365_CHAOS_STATUS_CODE environment variable.Custom status message to return for chaos-affected requests.If not set, a default message will be used.Can be set using the
M365_CHAOS_STATUS_MESSAGE environment variable.Recommended Configurations
Production Environment
Development Environment
High-Volume Operations
For environments with many resources or frequent API calls:Best Practices
Enable Compression
Always enable compression in production to reduce bandwidth usage and improve performance.
Configure Retries
Enable retries with appropriate max_retries and retry_delay_seconds values to handle transient failures and rate limiting.
Set Reasonable Timeouts
Configure timeout_seconds based on your workload. Large operations may require longer timeouts.
Use Environment Variables
Store client options as environment variables for easier management across environments.
