Skip to content

Conversation

@tracisiebel
Copy link

@tracisiebel tracisiebel commented Nov 14, 2025

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:

  • Added launchdarkly_ai_config resource with full CRUD operations
  • Added launchdarkly_ai_config data source
  • Upgraded API client from v17.1.0 to v17.2.0 (required for AI Configs support)
  • Fixed breaking changes from API client upgrade
  • Regenerated integration documentation with full integration lists

Breaking Changes from API Client Upgrade

The API client upgrade to v17.2.0 introduced two breaking changes that were fixed:

  1. Environments field: Changed from map[string]FeatureFlagConfig to *map[string]FeatureFlagConfig (pointer)

    • Added nil checks in feature_flag_environment_helper.go
    • Updated test files to dereference pointer before indexing
  2. IsActive field: Removed from MetricPost struct

    • Removed IsActive field from metric create/update operations in resource_launchdarkly_metric.go

AI Config Implementation

The AI Config resource supports:

  • Required fields: project_key, key, name
  • Optional fields: description, tags, maintainer_id, maintainer_team_key
  • Computed fields: id, version
  • Maintainer union type: Handles both member and team maintainers correctly

Testing Status

⚠️ IMPORTANT: This PR does not include acceptance tests for the AI Config resource and data source. Tests should be added before merging.

Documentation

  • Auto-generated documentation for AI Config resource and data source
  • Regenerated integration documentation to show full lists of supported integrations (previously showed minimal lists)

Review Checklist

Critical Items:

  • Add comprehensive acceptance tests for AI Config resource (currently missing!)
  • Verify all CRUD operations work correctly for AI Configs
  • Test maintainer field handling (both member and team maintainers)
  • Verify nil checks for Environments pointer are sufficient
  • Confirm IsActive field removal doesn't break existing metrics

API Client Upgrade:

  • Review all uses of flag.Environments to ensure proper pointer handling
  • Verify metric creation/updates work without IsActive field
  • Check for any other potential breaking changes from v17.1.0 → v17.2.0

AI Config Specific:

  • Verify import functionality works correctly
  • Test that beta API header is being sent correctly
  • Confirm error handling for non-existent projects/configs
  • Verify tags and description are optional and work as expected

Session: https://app.devin.ai/sessions/4ce205546ce54b55a0c511fed243dc6d
Requested by: traci@launchdarkly.com (@tracisiebel)

devin-ai-integration bot and others added 2 commits November 14, 2025 22:58
- 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>
@tracisiebel tracisiebel requested review from a team as code owners November 14, 2025 23:04
@devin-ai-integration
Copy link

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

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>
@devin-ai-integration devin-ai-integration bot changed the title Add AI configs support to terraform provider feat: add AI configs support to terraform provider Nov 14, 2025
devin-ai-integration bot and others added 2 commits November 14, 2025 23:15
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>
Comment on lines 6 to 7
Provides a LaunchDarkly AI config data source.
This data source allows you to retrieve AI config information from your LaunchDarkly project.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.

Comment on lines 13 to 15
Provides a LaunchDarkly AI config data source.

This data source allows you to retrieve AI config information from your LaunchDarkly project.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.


### Required

- `key` (String) The unique key of the AI config.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- `key` (String) The unique key of the AI config.
- `key` (String) The unique key of the AI Config.

Comment on lines 31 to 37
- `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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- `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`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- `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.",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Description: "The version of the AI config.",
Description: "The version of the AI Config.",

},
},

Description: `Provides a LaunchDarkly AI config resource.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.

@devin-ai-integration
Copy link

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 integration_configs_generated.go. Currently, this file contains:

For audit_log_subscription:

  • SUBSCRIPTION_CONFIGURATION_FIELDS includes: chronosphere, cloudtrail, datadog, dynatrace, dynatrace-v2, elastic, grafana, honeycomb, kosli, last9, logdna, msteams, new-relic-apm, pagerduty, signalfx, splunk

For flag_trigger:

  • VALID_TRIGGER_INTEGRATIONS includes: generic-trigger, datadog, dynatrace, dynatrace-cloud-automation, honeycomb, new-relic-apm, signalfx

The documentation for these resources is auto-generated from integration_configs_generated.go via the make generate command. If I manually change the docs to say "only slack" or "only generic-trigger" as suggested, those changes will be overwritten the next time make generate runs.

Could you clarify:

  1. Should the docs list all supported integrations from the generated data (current behavior)?
  2. Or should we simplify the wording to a generic statement (which would require changes to the generator templates in scripts/codegen/templates)?

I want to make sure I implement the correct approach before making changes that might be overwritten by the code generator.

devin-ai-integration bot and others added 2 commits November 17, 2025 18:22
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>
devin-ai-integration bot and others added 4 commits November 17, 2025 22:48
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants