Skip to content

Feat/conditional resource eval #55

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

Merged
merged 5 commits into from
Mar 16, 2025

Conversation

derek10cloud
Copy link
Collaborator

@derek10cloud derek10cloud commented Mar 16, 2025

Description

This PR introduces a new if condition feature within the resources section of the stackql_manifest.yml file. This enhancement allows users to specify Python expressions that determine whether a resource should be tested, provisioned, or deprovisioned based on runtime conditions.

  • Added conditional evaluation logic in build.py and teardown.py to process the if condition before resource handling
  • Created documentation for the new feature in if.mdx

Fixes #51

Checklist

Please make sure that the following criteria are met:

  • The PR title is descriptive.
  • For example stacks, I have included a descriptive README.md in the example project directory, which describes the stack and includes instructions to deploy or test.
  • For example stacks, add your stack to the website template library at website/docs/template-library/.. which gets published to stackql-deploy.io (optional)
  • I have ⭐'ed the stackql and stackql-deploy repos.

Additional Notes

Testing Methodology

I tested the conditional resource evaluation feature using the following approach:

Test Environment Setup

  • Created a test AWS stack with two resources in test-derek-aws/stackql_manifest.yml
  • Configured different conditions for each resource:
    • example_vpc_sit with condition: '{{ stack_env }}' == 'sit'
    • example_vpc_dev with condition: '{{ stack_env }}' == 'dev'

Test Cases

  1. Environment-Specific Resource Deployment
    # Test in 'sit' environment - should only create example_vpc_sit
    stackql-deploy build test-derek-aws sit -e AWS_REGION=ap-southeast-2

스크린샷 2025-03-17 오전 2 08 51

And then, I made a second vpc

# Test in 'dev' environment - should only create example_vpc_dev
stackql-deploy build test-derek-aws dev -e AWS_REGION=ap-southeast-2

스크린샷 2025-03-17 오전 2 10 08

  1. Condition Syntax Validation

    • Tested proper template variable rendering in conditions
    • Verified error handling for invalid condition expressions
  2. Resource Skipping Behavior

    • Confirmed resources with conditions evaluating to False are properly skipped
    • Verified log messages indicating skipped resources

Results

  • Successfully deployed environment-specific resources based on conditions
  • Confirmed proper evaluation of templated variables in conditions
  • Verified resources are correctly skipped when conditions are not met

@derek10cloud derek10cloud force-pushed the feat/conditional_resource_eval branch from 2d77932 to 80c87fb Compare March 16, 2025 17:12
@jeffreyaven jeffreyaven merged commit 081d61e into stackql:main Mar 16, 2025
4 checks passed
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] Implement Conditional Resource Evaluation
2 participants