-
Notifications
You must be signed in to change notification settings - Fork 0
Enhanced Password Validation, Import Toggle, and Output Standardization for Datastore Modules #38
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
Changes from 6 commits
8d52da2
87a2777
664bb0e
c221950
45803c2
ad1c3d4
44cba8a
459a5cc
68b50ad
45e37d3
f7d3dc5
5124df8
f32c606
980b827
8c96416
1cdb2c8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| intent: mongo | ||
| flavor: aws-documentdb | ||
| flavor: aws-documentdb-test | ||
| version: '1.0' | ||
| clouds: | ||
| - aws | ||
|
|
@@ -55,6 +55,7 @@ spec: | |
| restore_config: | ||
| type: object | ||
| title: Restore Operations | ||
| x-ui-overrides-only: true | ||
| properties: | ||
| restore_from_snapshot: | ||
| type: boolean | ||
|
|
@@ -90,6 +91,7 @@ spec: | |
| imports: | ||
| type: object | ||
| title: Import Existing Resources | ||
| x-ui-overrides-only: true | ||
| properties: | ||
| cluster_identifier: | ||
| type: string | ||
|
|
@@ -103,6 +105,11 @@ spec: | |
| type: string | ||
| title: Subnet Group Name | ||
| description: Name of existing DocumentDB subnet group to import | ||
| master_password: | ||
ishaankalra marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| type: string | ||
| title: Master Password | ||
| description: Master password for the imported cluster (8+ characters) | ||
| minLength: 8 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this should have regex as well according to cloud constraints
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done, added |
||
| required: | ||
| - version_config | ||
| - sizing | ||
|
|
@@ -121,17 +128,20 @@ inputs: | |
| description: VPC configuration for DocumentDB cluster | ||
| outputs: | ||
| default: | ||
| type: '@facets/mongo' | ||
| type: '@facets/mongo-test' | ||
ishaankalra marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| title: MongoDB DocumentDB Cluster | ||
| imports: | ||
| - name: cluster_identifier | ||
| resource_address: aws_docdb_cluster.main | ||
| required: true | ||
| - name: security_group_id | ||
| resource_address: aws_security_group.documentdb | ||
| resource_address: aws_security_group.documentdb[0] | ||
| required: true | ||
| - name: subnet_group_name | ||
| resource_address: aws_docdb_subnet_group.main | ||
| resource_address: aws_docdb_subnet_group.main[0] | ||
| required: true | ||
| - name: master_password | ||
| resource_address: random_password.master[0] | ||
| required: true | ||
| iac: | ||
| validated_files: | ||
|
|
@@ -140,7 +150,7 @@ iac: | |
| - locals.tf | ||
| sample: | ||
| kind: mongo | ||
| flavor: aws-documentdb | ||
| flavor: aws-documentdb-test | ||
ishaankalra marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| version: '1.0' | ||
| disabled: true | ||
| spec: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,17 @@ | ||
| # Generate a random password only when NOT restoring from backup AND NOT importing | ||
| # Excludes characters not allowed by Aurora MySQL: '/', '@', '"', ' ' (space) | ||
| resource "random_password" "master_password" { | ||
| count = (var.instance.spec.restore_config.restore_from_backup || try(var.instance.spec.imports.cluster_identifier, null) != null) ? 0 : 1 | ||
| count = var.instance.spec.restore_config.restore_from_backup ? 0 : 1 | ||
| length = 16 | ||
| special = true | ||
| override_special = "!#$%&*+-=?^_`{|}~" # Safe special characters for Aurora MySQL | ||
|
|
||
| lifecycle { | ||
| ignore_changes = [ | ||
| length, | ||
| override_special, | ||
| ] | ||
| } | ||
| } | ||
|
|
||
| # Generate unique cluster identifier | ||
|
|
@@ -21,8 +28,8 @@ locals { | |
| imported_writer_id = try(var.instance.spec.imports.writer_instance_identifier, null) | ||
|
|
||
| # Handle password - don't create for restore or import | ||
| master_password = local.restore_from_backup ? var.instance.spec.restore_config.master_password : (local.is_import ? null : random_password.master_password[0].result) | ||
| master_username = local.restore_from_backup ? var.instance.spec.restore_config.master_username : (local.is_import ? null : "admin") | ||
| master_password = local.restore_from_backup ? var.instance.spec.restore_config.master_password : random_password.master_password[0].result | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. dont we need to import master username as well? is custom master iusername supported?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this can be simply provided from the spec as we're not creating any add rsource for this
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we need to import |
||
| master_username = local.restore_from_backup ? var.instance.spec.restore_config.master_username : "admin" | ||
|
|
||
| # Split reader instance identifiers if provided for import | ||
| reader_instance_ids = try(var.instance.spec.imports.reader_instance_identifiers, null) != null && var.instance.spec.imports.reader_instance_identifiers != "" ? split(",", trimspace(var.instance.spec.imports.reader_instance_identifiers)) : [] | ||
|
|
@@ -83,10 +90,10 @@ resource "aws_rds_cluster" "aurora" { | |
| engine = "aurora-mysql" | ||
|
|
||
| # When restoring from snapshot or importing, these fields must be omitted or ignored | ||
| engine_version = (local.restore_from_backup || local.is_import) ? null : var.instance.spec.version_config.engine_version | ||
| database_name = (local.restore_from_backup || local.is_import) ? null : var.instance.spec.version_config.database_name | ||
| master_username = (local.restore_from_backup || local.is_import) ? null : local.master_username | ||
| master_password = (local.restore_from_backup || local.is_import) ? null : local.master_password | ||
| engine_version = var.instance.spec.version_config.engine_version | ||
| database_name = var.instance.spec.version_config.database_name | ||
| master_username = local.master_username | ||
| master_password = local.master_password | ||
|
|
||
| # Backup configuration | ||
| backup_retention_period = 7 # Hardcoded - 7 days retention | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.