Skip to content

Add generate_only parameter to skip terraform init/plan/apply #388

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

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Copilot
Copy link

@Copilot Copilot AI commented Jul 2, 2025

This PR adds a new generate_only parameter to the Deploy-Accelerator function that allows users to generate Terraform files without executing terraform init, plan, or apply commands. This addresses the feature request for users who want to use custom tfstate configurations or integrate with other pipelines.

Changes Made

New Parameter

  • Added -generate_only switch parameter with aliases -g and -generateOnly
  • Supports environment variable ALZ_generate_only and config file input generate_only
  • Comprehensive help text explaining the functionality

Implementation Flow

  1. Deploy-Accelerator.ps1: Added parameter definition and passed it through to New-Bootstrap
  2. New-Bootstrap.ps1: Added parameter and conditional logic for messaging and Invoke-Terraform calls
  3. Invoke-Terraform.ps1: Added early return when generateOnly is true, skipping all terraform execution

User Experience

When generate_only is used:

  • Terraform files are generated normally ✓
  • terraform init is skipped ✓
  • terraform plan is skipped ✓
  • terraform apply is skipped ✓
  • Clear messaging indicates files are ready for custom pipeline usage

Usage Examples

# Generate files only, skip terraform execution
Deploy-Accelerator -iac terraform -bootstrap github -generate_only

# Using short alias
Deploy-Accelerator -i terraform -b github -g

# Using alternative alias
Deploy-Accelerator -iac terraform -bootstrap github -generateOnly

Testing

  • ✅ All 36 existing unit tests continue to pass
  • ✅ Added new test case for generate_only functionality
  • ✅ No linting issues (PSScriptAnalyzer clean)
  • ✅ Module manifest validation passes
  • ✅ Maintains complete backward compatibility

This enables users to generate Terraform files for custom tfstate configurations, CI/CD pipeline integration, or manual terraform execution workflows.

Fixes #347.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

@Copilot Copilot AI changed the title [WIP] Feature Request: Only Generate terraform without tf init plan or apply Add generate_only parameter to skip terraform init/plan/apply Jul 2, 2025
@Copilot Copilot AI requested a review from jaredfholgate July 2, 2025 18:15
Copilot finished work on behalf of jaredfholgate July 2, 2025 18:15
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.

Feature Request: Only Generate terraform without tf init plan or apply
2 participants