-
Notifications
You must be signed in to change notification settings - Fork 28
feat: add AI configs support to terraform provider #368
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
- Upgrade from v17.1.0 to v17.2.0 - Fix Environments field access (now pointer to map) - Remove IsActive field from MetricPost (removed in v17.2.0) - Update generated integration configs and docs Co-Authored-By: traci@launchdarkly.com <traci@launchdarkly.com>
- Add resource_launchdarkly_ai_config for managing AI configs - Add data_source_launchdarkly_ai_config for querying AI configs - Register resources in provider.go - Support for name, description, tags, maintainer_id, and maintainer_team_key fields - AI Configs are currently in beta Co-Authored-By: traci@launchdarkly.com <traci@launchdarkly.com>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
The API client v17.2.0 changed the Environments field from a map to a pointer to a map. This commit fixes the test files that were directly accessing flag.Environments to properly dereference the pointer. Co-Authored-By: traci@launchdarkly.com <traci@launchdarkly.com>
Co-Authored-By: traci@launchdarkly.com <traci@launchdarkly.com>
This file needs to be populated with all integration configurations from the LaunchDarkly manifests API. Copied from main branch since local tokens don't have the necessary permissions to fetch the full manifest data. Co-Authored-By: traci@launchdarkly.com <traci@launchdarkly.com>
docs/data-sources/ai_config.md
Outdated
| Provides a LaunchDarkly AI config data source. | ||
| This data source allows you to retrieve AI config information from your LaunchDarkly project. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Provides a LaunchDarkly AI config data source. | |
| This data source allows you to retrieve AI config information from your LaunchDarkly project. | |
| Provides a LaunchDarkly AI Config data source. | |
| This data source allows you to retrieve AI Config information from your LaunchDarkly project. |
docs/data-sources/ai_config.md
Outdated
| Provides a LaunchDarkly AI config data source. | ||
|
|
||
| This data source allows you to retrieve AI config information from your LaunchDarkly project. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Provides a LaunchDarkly AI config data source. | |
| This data source allows you to retrieve AI config information from your LaunchDarkly project. | |
| Provides a LaunchDarkly AI Config data source. | |
| This data source allows you to retrieve AI Config information from your LaunchDarkly project. |
docs/data-sources/ai_config.md
Outdated
|
|
||
| ### Required | ||
|
|
||
| - `key` (String) The unique key of the AI config. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| - `key` (String) The unique key of the AI config. | |
| - `key` (String) The unique key of the AI Config. |
docs/data-sources/ai_config.md
Outdated
| - `description` (String) The description of the AI config. | ||
| - `id` (String) The ID of this resource. | ||
| - `maintainer_id` (String) The ID of the member who maintains this AI config. | ||
| - `maintainer_team_key` (String) The key of the team that maintains this AI config. | ||
| - `name` (String) The human-readable name of the AI config. | ||
| - `tags` (Set of String) Tags associated with the AI config. | ||
| - `version` (Number) The version of the AI config. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| - `description` (String) The description of the AI config. | |
| - `id` (String) The ID of this resource. | |
| - `maintainer_id` (String) The ID of the member who maintains this AI config. | |
| - `maintainer_team_key` (String) The key of the team that maintains this AI config. | |
| - `name` (String) The human-readable name of the AI config. | |
| - `tags` (Set of String) Tags associated with the AI config. | |
| - `version` (Number) The version of the AI config. | |
| - `description` (String) The description of the AI Config. | |
| - `id` (String) The ID of this resource. | |
| - `maintainer_id` (String) The ID of the member who maintains this AI Config. | |
| - `maintainer_team_key` (String) The key of the team that maintains this AI Config. | |
| - `name` (String) The human-readable name of the AI Config. | |
| - `tags` (Set of String) Tags associated with the AI Config. | |
| - `version` (Number) The version of the AI Config. |
|
|
||
| - `id` (String) The audit log subscription ID. | ||
| - `integration_key` (String) The integration key. Supported integration keys are `chronosphere`, `cloudtrail`, `datadog`, `dynatrace`, `dynatrace-v2`, `elastic`, `grafana`, `honeycomb`, `kosli`, `last9`, `logdna`, `msteams`, `new-relic-apm`, `pagerduty`, `signalfx`, `slack`, and `splunk`. | ||
| - `integration_key` (String) The integration key. Supported integration keys are `slack`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| - `integration_key` (String) The integration key. Supported integration keys are `slack`. | |
| - `integration_key` (String) The integration key. Supported integration key is `slack`. |
| MAINTAINER_ID: { | ||
| Type: schema.TypeString, | ||
| Optional: true, | ||
| Description: "The ID of the member who maintains this AI config.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Description: "The ID of the member who maintains this AI config.", | |
| Description: "The ID of the member who maintains this AI Config.", |
| MAINTAINER_TEAM_KEY: { | ||
| Type: schema.TypeString, | ||
| Optional: true, | ||
| Description: "The key of the team that maintains this AI config.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Description: "The key of the team that maintains this AI config.", | |
| Description: "The key of the team that maintains this AI Config.", |
| VERSION: { | ||
| Type: schema.TypeInt, | ||
| Computed: true, | ||
| Description: "The version of the AI config.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Description: "The version of the AI config.", | |
| Description: "The version of the AI Config.", |
| }, | ||
| }, | ||
|
|
||
| Description: `Provides a LaunchDarkly AI config resource. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Description: `Provides a LaunchDarkly AI config resource. | |
| Description: `Provides a LaunchDarkly AI Config resource. |
|
|
||
| Description: `Provides a LaunchDarkly AI config resource. | ||
| This resource allows you to create and manage AI configs within your LaunchDarkly project. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| This resource allows you to create and manage AI configs within your LaunchDarkly project. | |
| This resource allows you to create and manage AI Configs within your LaunchDarkly project. |
|
Thank you for the review! I've addressed all the AI Config capitalization changes (changing "AI config" → "AI Config" and "AI configs" → "AI Configs" throughout the codebase). Regarding the integration documentation comments (audit_log_subscription.md and flag_trigger.md): The suggested changes to simplify the integration lists appear to contradict the generated data in For audit_log_subscription:
For flag_trigger:
The documentation for these resources is auto-generated from Could you clarify:
I want to make sure I implement the correct approach before making changes that might be overwritten by the code generator. |
Address reviewer feedback by changing 'AI config' to 'AI Config' and 'AI configs' to 'AI Configs' throughout the codebase. Changes include: - Updated schema field descriptions in resource and data source - Regenerated documentation files with proper capitalization - Applied gofmts formatting Link to Devin run: https://app.devin.ai/sessions/4ce205546ce54b55a0c511fed243dc6d Requested by: traci@launchdarkly.com (@tracisiebel) Co-Authored-By: traci@launchdarkly.com <traci@launchdarkly.com>
Regenerate audit_log_subscription and flag_trigger documentation to include the full list of supported integrations from integration_configs_generated.go. This fixes the CI generate check failure. Changes: - audit_log_subscription: Update to list all supported integrations (chronosphere, cloudtrail, datadog, dynatrace, etc.) - flag_trigger: Update to list all supported integrations (generic-trigger, datadog, dynatrace, honeycomb, etc.) Link to Devin run: https://app.devin.ai/sessions/4ce205546ce54b55a0c511fed243dc6d Requested by: traci@launchdarkly.com (@tracisiebel) Co-Authored-By: traci@launchdarkly.com <traci@launchdarkly.com>
…ata source Add comprehensive acceptance tests covering: Resource tests: - Create: Test basic AI Config creation with minimal required fields - Update: Test updating name, description, and tags - WithTags: Test AI Config creation with tags - WithTeamMaintainer: Test AI Config with team maintainer - ConflictingMaintainers: Test validation error when both maintainer_id and maintainer_team_key are set - Import: Test import functionality for all scenarios Data source tests: - exists: Test data source retrieval with all fields - existsWithTeamMaintainer: Test data source with team maintainer - noMatchReturnsError: Test error handling for non-existent AI Config Also added ConflictsWith validation to maintainer_id and maintainer_team_key fields to ensure mutual exclusivity and provide clear error messages. Link to Devin run: https://app.devin.ai/sessions/4ce205546ce54b55a0c511fed243dc6d Requested by: traci@launchdarkly.com (@tracisiebel) Co-Authored-By: traci@launchdarkly.com <traci@launchdarkly.com>
Fix CI failures in AI Config acceptance tests: 1. Beta API Client: - Add ldBeta field to Client struct with LD-API-Version: beta header - Update all AI Config API calls to use client.ldBeta instead of client.ld - This fixes the 'lDAPIVersion is required and must be specified' error 2. Test Collision Fixes: - Randomize team keys in tests to prevent parallel test collisions - Convert testAccAIConfigWithTeamMaintainer to format string - Convert testAccAIConfigConflictingMaintainers to format string - Convert testAccDataSourceAIConfigWithTeam to format string - Use acctest.RandStringFromCharSet for team keys in all tests 3. Test Improvements: - Make ConflictsWith error regex case-insensitive for robustness These changes ensure AI Config tests pass reliably in CI by properly setting the beta API version header and avoiding account-scoped resource collisions in parallel tests. Link to Devin run: https://app.devin.ai/sessions/4ce205546ce54b55a0c511fed243dc6d Requested by: traci@launchdarkly.com (@tracisiebel) Co-Authored-By: traci@launchdarkly.com <traci@launchdarkly.com>
The AI Config Beta API requires the LDAPIVersion parameter to be set
on each request via the .LDAPIVersion("beta") method call. Previously
we only configured the beta header on the client, but the generated
API client requires the parameter on each request object.
This fixes the 'lDAPIVersion is required and must be specified' error
in acceptance tests.
Co-Authored-By: traci@launchdarkly.com <traci@launchdarkly.com>
The beta client was setting LD-API-Version as a default header, which
conflicted with the per-request .LDAPIVersion("beta") method calls,
resulting in duplicate headers ("Too many values for parameter
LD-API-Version, got 2").
Created newLDClientConfigNoVersion helper that builds a client config
without the default LD-API-Version header. The beta client now uses
this config, allowing the per-request .LDAPIVersion("beta") calls to
set the header without duplication.
Co-Authored-By: traci@launchdarkly.com <traci@launchdarkly.com>
Summary
This PR adds support for LaunchDarkly AI Configs to the Terraform provider, allowing users to create and manage AI Config resources via Terraform. AI Configs are currently in beta in the LaunchDarkly API.
Key Changes:
launchdarkly_ai_configresource with full CRUD operationslaunchdarkly_ai_configdata sourceBreaking Changes from API Client Upgrade
The API client upgrade to v17.2.0 introduced two breaking changes that were fixed:
Environments field: Changed from
map[string]FeatureFlagConfigto*map[string]FeatureFlagConfig(pointer)feature_flag_environment_helper.goIsActive field: Removed from
MetricPoststructIsActivefield from metric create/update operations inresource_launchdarkly_metric.goAI Config Implementation
The AI Config resource supports:
project_key,key,namedescription,tags,maintainer_id,maintainer_team_keyid,versionTesting Status
Documentation
Review Checklist
Critical Items:
API Client Upgrade:
flag.Environmentsto ensure proper pointer handlingAI Config Specific:
Session: https://app.devin.ai/sessions/4ce205546ce54b55a0c511fed243dc6d
Requested by: traci@launchdarkly.com (@tracisiebel)