Skip to content

Conversation

jimmykurian
Copy link
Contributor

@jimmykurian jimmykurian commented Oct 10, 2025

📥 Pull Request

❓ What are you trying to address

The function layer terraform configuration requires 7 manual input variables from foundry_basic deployment, making configuration verbose and error-prone. Users must manually copy resource group names, AI Foundry names, project names, and Application Insights names from foundry_basic outputs.

✨ Description of new changes

Reduced required variables from 7 to 4 by implementing automatic resource discovery:

  • Variables reduced to resource IDs only: foundry_ai_foundry_id, foundry_ai_foundry_project_id, foundry_application_insights_id, foundry_log_analytics_workspace_id
  • Added ID parsing in main.tf: Parse resource group name, AI Foundry name, project name, and Application Insights name from resource IDs
  • Added data source discovery: Retrieve AI Foundry endpoint and Application Insights connection string via data sources
  • Enhanced outputs.tf: Added 5 new outputs for local development to support best-practice configuration script
  • Updated configure-local-settings.sh: Use terraform output commands instead of state parsing with jq (72% code reduction, removed jq dependency)
  • Updated tests: All acceptance and integration tests updated and passing (5/5 each)
  • Updated README.md: Reflect simplified configuration and document resource discovery patterns

This reduces configuration complexity (43% fewer variables) while following terraform best practices.

☑️ Checklist

  • 🔍 I have performed a self-review of my own code.
  • 📝 I have commented my code, particularly in hard-to-understand areas.
  • 🧹 I have run the linter and fixed any issues (if applicable).
  • 📄 I have updated the documentation to reflect my changes (if necessary).

@jimmykurian jimmykurian self-assigned this Oct 10, 2025
@jimmykurian jimmykurian added state/skip-changelog Skip changelog entry area/iac Any changes to Infrastructure as Code area/docs Improvements or additions to documentation labels Oct 10, 2025
Copy link

github-actions bot commented Oct 10, 2025

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

Copy link

github-actions bot commented Oct 10, 2025

MegaLinter analysis: Success

Descriptor Linter Files Fixed Errors Warnings Elapsed time
✅ ACTION actionlint 15 0 0 0.39s
✅ BASH shellcheck 3 0 0 0.5s
✅ BASH shfmt 3 1 0 0 0.11s
✅ EDITORCONFIG editorconfig-checker 257 0 0 1.91s
✅ MARKDOWN markdownlint 67 0 0 0 2.92s
✅ MARKDOWN markdown-table-formatter 67 9 0 0 0.45s
✅ REPOSITORY gitleaks yes no no 1.4s
✅ REPOSITORY trivy yes no no 24.99s
✅ SPELL cspell 68 0 0 4.6s
✅ SPELL lychee 136 0 0 3.74s
✅ TERRAFORM terraform-fmt 67 0 0 0 6.85s
✅ TERRAFORM tflint yes no no 8.7s
✅ YAML yamllint 62 0 0 1.83s

See detailed reports in MegaLinter artifacts

You could have the same capabilities but better runtime performances if you use a MegaLinter flavor:

Your project could benefit from a custom flavor, which would allow you to run only the linters you need, and thus improve runtime performances. (Skip this info by defining FLAVOR_SUGGESTIONS: false)

  • Documentation: Custom Flavors
  • Command: npx [email protected] --custom-flavor-setup --custom-flavor-linters ACTION_ACTIONLINT,BASH_SHELLCHECK,BASH_SHFMT,EDITORCONFIG_EDITORCONFIG_CHECKER,MARKDOWN_MARKDOWNLINT,MARKDOWN_MARKDOWN_TABLE_FORMATTER,REPOSITORY_GITLEAKS,REPOSITORY_TRIVY,SPELL_CSPELL,SPELL_LYCHEE,TERRAFORM_TFLINT,TERRAFORM_TERRAFORM_FMT,YAML_YAMLLINT

MegaLinter is graciously provided by OX Security

@jimmykurian jimmykurian marked this pull request as ready for review October 10, 2025 21:11
@jimmykurian jimmykurian requested a review from a team as a code owner October 10, 2025 21:11
@Copilot Copilot AI review requested due to automatic review settings October 10, 2025 21:11
@jimmykurian jimmykurian enabled auto-merge (squash) October 10, 2025 21:11
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR significantly simplifies the Terraform configuration for the AI Foundry function integration by implementing automatic resource discovery. It reduces required input variables from 7 to 3 by parsing resource IDs and using data sources to discover related resources.

Key changes:

  • Reduced variables from 7 to 3 using automatic resource discovery
  • Added ID parsing logic to extract resource names from Azure resource IDs
  • Updated tests to validate parsing and discovery functionality

Reviewed Changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
guides/implement_ai_foundry_basic_with_azure_function_integration/terraform/variables.tf Reduced variables from 7 to 3 with validation
guides/implement_ai_foundry_basic_with_azure_function_integration/terraform/main.tf Added resource ID parsing and data source discovery
guides/implement_ai_foundry_basic_with_azure_function_integration/terraform/function.tf Updated to use parsed values instead of input variables
guides/implement_ai_foundry_basic_with_azure_function_integration/terraform/providers.tf Removed unused azapi provider
guides/implement_ai_foundry_basic_with_azure_function_integration/terraform/tests/*.tftest.hcl Updated tests to use new variable structure and validate parsing
guides/implement_ai_foundry_basic_with_azure_function_integration/terraform/terraform.tfvars.example Simplified example configuration
guides/implement_ai_foundry_basic_with_azure_function_integration/scripts/configure-local-settings.sh Updated to parse terraform state instead of using outputs
guides/implement_ai_foundry_basic_with_azure_function_integration/README.md Updated documentation to reflect simplified configuration
transparency-note.md Fixed spelling and markdown formatting

@jimmykurian jimmykurian changed the title refactor(guides): reduce variables from 7 to 3 using data sources refactor(guides): reduce variables from 7 to 4 using data sources Oct 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/docs Improvements or additions to documentation area/iac Any changes to Infrastructure as Code state/skip-changelog Skip changelog entry

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants