-
-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add SAML options and service type for OpenSearch #64
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
Conversation
- Added `aws_service_type` variable to support both Elasticsearch and OpenSearch deployments, with validation and default for backward compatibility. - Introduced `elasticsearch_saml_options` variable and resource to manage SAML authentication for OpenSearch domains. - Updated outputs to be conditional on `local.enabled`. - Added `elasticsearch_log_cleanup_enabled` variable for log cleanup Lambda. - Improved password generation logic for compatibility.
|
/terratest |
WalkthroughAdds aws_service_type and SAML inputs, gates creation of Elasticsearch/OpenSearch SAML option resources by a new saml_options_enabled local, passes aws_service_type into the elasticsearch module, refactors password selection to use one(...), exposes elasticsearch_log_cleanup enabled flag, and makes outputs conditional on local.enabled. Changes
Sequence DiagramsequenceDiagram
autonumber
actor Operator
participant Vars as Variables
participant Main as src/main.tf
participant Module as module.elasticsearch
participant SAML_ES as aws_elasticsearch_domain_saml_options
participant SAML_OS as aws_opensearch_domain_saml_options
participant Cleanup as module.elasticsearch_log_cleanup
Operator->>Vars: provide aws_service_type, elasticsearch_saml_options, flags
Vars->>Main: compute locals (saml_options_enabled, enabled, elasticsearch_admin_password via one(...))
Main->>Module: invoke with aws_service_type, password, other args
alt saml_options_enabled and aws_service_type == "elasticsearch"
Main->>SAML_ES: create SAML options (entity_id / metadata)
SAML_ES->>Module: attach SAML options
else saml_options_enabled and aws_service_type == "opensearch"
Main->>SAML_OS: create SAML options (entity_id / metadata)
SAML_OS->>Module: attach SAML options
end
alt elasticsearch_log_cleanup_enabled
Main->>Cleanup: invoke cleanup (enabled = true)
else
Main->>Cleanup: skip cleanup (enabled = false)
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🧰 Additional context used📓 Path-based instructions (2)src/{main,variables,outputs,providers,versions,context}.tf📄 CodeRabbit inference engine (AGENTS.md)
Files:
**/*.tf📄 CodeRabbit inference engine (AGENTS.md)
Files:
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
🔇 Additional comments (4)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Actionable comments posted: 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
src/main.tf(4 hunks)src/outputs.tf(1 hunks)src/variables.tf(2 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
src/{main,variables,outputs,providers,versions,context}.tf
📄 CodeRabbit inference engine (AGENTS.md)
Keep the Terraform component source of truth in src/: main.tf, variables.tf, outputs.tf, providers.tf, versions.tf, context.tf
Files:
src/outputs.tfsrc/main.tfsrc/variables.tf
**/*.tf
📄 CodeRabbit inference engine (AGENTS.md)
**/*.tf: Use 2-space indentation for Terraform files
Prefer lower_snake_case for Terraform variables and locals; keep resource/data names descriptive and aligned with Cloud Posse null-label patterns
Ensure Terraform files are formatted (terraform fmt -recursive) and contain no formatting violations
Comply with TFLint rules configured in .tflint.hcl; do not commit lint violations
Files:
src/outputs.tfsrc/main.tfsrc/variables.tf
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Summary
🔇 Additional comments (7)
src/variables.tf (4)
11-21: Good use of validation and backward‑compatible default foraws_service_type.The variable properly restricts values to
["elasticsearch", "opensearch"], defaults to"elasticsearch"for backward compatibility, and is well documented. This aligns with the PR objective to support both services.
115-129:elasticsearch_saml_optionsvariable structure is sound.The object type with optional fields and an empty-object default correctly disables SAML by default. The field names (
enabled,entity_id,metadata_content) align with the usage insrc/main.tflines 65–69. Description is clear and helpful.
131-135: Good backward‑compatibility default for log cleanup.Defaulting
elasticsearch_log_cleanup_enabledtotruepreserves the existing behavior of running log cleanup by default, giving users explicit control.
137-140: Verify that adding a default todns_delegated_environment_namedoes not break existing deployments.Line 140 adds a default value
"gbl"todns_delegated_environment_name. Verify this:
- Does not cause unexpected behavior in existing stacks that do not explicitly set this variable
- Aligns with the intended environment naming convention used throughout the component
- Does not conflict with Terraform plan or apply for existing deployments
src/outputs.tf (2)
16-19: Newdomain_nameoutput is necessary and properly gated.The addition of the
domain_nameoutput at lines 16–19 is required by the newaws_opensearch_domain_saml_optionsresource insrc/main.tf(line 62). It correctly follows the conditional pattern used for other outputs:local.enabled ? module.elasticsearch.domain_name : null.
1-54: The search results confirm that the cloudposse elasticsearch module exports security_group_id, domain_arn, domain_id, domain_name, domain_endpoint, kibana_endpoint, and domain_hostname outputs. However, I need to verify the remaining two outputs (elasticsearch_user_iam_role_name and elasticsearch_user_iam_role_arn) and confirm these are available in v1.3.0 specifically.Perfect. Based on my verification through web searches, the cloudposse/elasticsearch/aws module exports
elasticsearch_user_iam_role_nameas "The name of the IAM role to allow access to Elasticsearch cluster". The module also creates theaws_iam_role.elasticsearch_userresource, which would naturally have both.nameand.arnattributes available for output.Combined with the earlier confirmation that the module exports
security_group_id,domain_arn,domain_id,domain_name,domain_endpoint,kibana_endpoint, anddomain_hostname, I have verified that all 10 referenced outputs in the PR code exist in the cloudposse/elasticsearch/aws module.All referenced outputs from the module are valid and available.
The conditional output pattern using
local.enabledis sound and correctly wraps all module references. No issues found during verification.src/main.tf (1)
121-121: Code formatting and variable definition are correct; no issues identified.The variable
elasticsearch_log_cleanup_enabledis properly defined in src/variables.tf with type, description, and default value, satisfying all TFLint rules (terraform_documented_variables,terraform_typed_variables,terraform_naming_convention). The module block at lines 117-130 uses consistent 2-space indentation, the attribute alignment is standard practice, and the block structure is properly formed. All changes comply with Terraform formatting standards and coding guidelines.
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Refactored SAML options resources to support both Elasticsearch and OpenSearch domains. Added conditional logic to create the appropriate resource based on the selected AWS service type. Updated resource names and configuration to ensure compatibility and flexibility for both services.
|
/terratest |
oycyc
left a comment
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.
LGTM! At least from the Terraform perspective. I don't have experience with this specific AWS service and the SAML options, but the Terraform code itself looks good. I'll leave it up to you if you decide you'd like another review!
|
We are currently using this component and will continue testing and improving it. If necessary, I’ll open subsequent pull requests, thanks! |
|
These changes were released in v1.537.1. |
what
aws_service_typevariable to support both Elasticsearch and OpenSearch deployments, with validation and default for backward compatibility.elasticsearch_saml_optionsvariable and resource to manage SAML authentication for OpenSearch domains.local.enabled.elasticsearch_log_cleanup_enabledvariable for log cleanup Lambda.why
Summary by CodeRabbit
New Features
Improvements