-
Notifications
You must be signed in to change notification settings - Fork 104
Release Tests for AWS Redis passwordless authentication #380
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
base: main
Are you sure you want to change the base?
Changes from all commits
7a7fcfe
72fd992
5c39336
13e0d4f
37867eb
45cbee2
b5b2712
7dc969f
d9bda60
3ba107d
d87c702
7760248
ca0a764
329ddef
bdf9339
ff3841b
359b88d
7fd34a7
77aeb56
c08fc28
59ae7e9
2db6119
b0c0fae
6d045b6
2ddb81d
9eab717
331897d
c4d6a21
192c04a
5f05872
ee17b75
85d8019
18efb8b
60d9716
a8a53c5
51a61ad
fa227d6
9bac62a
09778aa
c41ee19
45f3b2f
61673bd
a33c463
1a92048
4eeb04b
681b718
0d46f46
f2aecd5
7cdd3b2
9f3ce61
3d8fd7b
0d125c0
62fb075
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 | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -45,6 +45,9 @@ module "service_accounts" { | |||||||
| postgres_client_key_secret_id = var.postgres_client_key_secret_id | ||||||||
| postgres_ca_certificate_secret_id = var.postgres_ca_certificate_secret_id | ||||||||
| vm_key_secret_id = var.vm_key_secret_id | ||||||||
| redis_enable_iam_auth = var.redis_passwordless_aws_use_instance_profile | ||||||||
| redis_replication_group_id = var.redis_passwordless_aws_use_instance_profile ? local.redis.cluster_id : null | ||||||||
| redis_iam_user_name = var.redis_passwordless_aws_use_instance_profile ? local.redis.iam_user : null | ||||||||
|
Comment on lines
+48
to
+50
|
||||||||
| } | ||||||||
|
|
||||||||
| # ----------------------------------------------------------------------------- | ||||||||
|
|
@@ -79,12 +82,10 @@ module "redis" { | |||||||
| source = "./modules/redis" | ||||||||
| count = local.enable_redis_module && var.enable_redis_sentinel == false || local.enable_redis_module && local.redis_mtls_enabled == false ? 1 : 0 | ||||||||
|
|
||||||||
| active_active = var.operational_mode == "active-active" | ||||||||
| friendly_name_prefix = var.friendly_name_prefix | ||||||||
| network_id = local.network_id | ||||||||
| network_private_subnet_cidrs = var.network_private_subnet_cidrs | ||||||||
raviharshicorp marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||
| network_subnets_private = local.network_private_subnets | ||||||||
| tfe_instance_sg = module.vm.tfe_instance_sg | ||||||||
| active_active = var.operational_mode == "active-active" | ||||||||
| friendly_name_prefix = var.friendly_name_prefix | ||||||||
| network_subnets_private = local.network_private_subnets | ||||||||
| tfe_instance_sg = module.vm.tfe_instance_sg | ||||||||
|
|
||||||||
| cache_size = var.redis_cache_size | ||||||||
| engine_version = var.redis_engine_version | ||||||||
|
|
@@ -94,6 +95,7 @@ module "redis" { | |||||||
| redis_encryption_in_transit = var.redis_encryption_in_transit | ||||||||
| redis_encryption_at_rest = var.redis_encryption_at_rest | ||||||||
| redis_use_password_auth = var.redis_use_password_auth | ||||||||
| redis_enable_iam_auth = var.redis_passwordless_aws_use_instance_profile | ||||||||
| redis_port = var.redis_encryption_in_transit ? "6380" : "6379" | ||||||||
|
||||||||
| redis_port = var.redis_encryption_in_transit ? "6380" : "6379" | |
| redis_port = var.redis_encryption_in_transit ? "6380" : "6379" | |
| redis_authentication_mode = var.redis_authentication_mode |
Copilot
AI
Nov 21, 2025
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.
This module source references a feature branch (pravi/IND-5861) instead of main. According to the PR description, this should be updated to main before merging.
| source = "git::https://github.com/hashicorp/terraform-random-tfe-utility//modules/runtime_container_engine_config?ref=pravi/IND-5861" | |
| source = "git::https://github.com/hashicorp/terraform-random-tfe-utility//modules/runtime_container_engine_config?ref=main" |
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.
it seems there is another issue here, if this was the case then the existing tests would have failed and same way of configuration is also used for database, I request to pls have a look at this issue
Copilot
AI
Nov 21, 2025
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.
This module source references a feature branch (pravi/IND-5861) instead of main. According to the PR description, this should be updated to main before merging.
| source = "git::https://github.com/hashicorp/terraform-random-tfe-utility//modules/tfe_init?ref=pravi/IND-5861" | |
| source = "git::https://github.com/hashicorp/terraform-random-tfe-utility//modules/tfe_init?ref=main" |
Copilot
AI
Nov 21, 2025
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.
This module source references a feature branch (pravi/IND-5861) instead of main. According to the PR description, this should be updated to main before merging.
| source = "git::https://github.com/hashicorp/terraform-random-tfe-utility//modules/settings?ref=pravi/IND-5861" | |
| source = "git::https://github.com/hashicorp/terraform-random-tfe-utility//modules/settings?ref=main" |
Copilot
AI
Nov 21, 2025
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.
This module source references a feature branch (pravi/IND-5861) instead of main. According to the PR description, this should be updated to main before merging.
| source = "git::https://github.com/hashicorp/terraform-random-tfe-utility//modules/tfe_init_replicated?ref=pravi/IND-5861" | |
| source = "git::https://github.com/hashicorp/terraform-random-tfe-utility//modules/tfe_init_replicated?ref=main" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,66 +1,67 @@ | ||
| # Copyright (c) HashiCorp, Inc. | ||
| # SPDX-License-Identifier: MPL-2.0 | ||
|
|
||
| # Redis module - simplified to reuse TFE security group instead of creating separate ones | ||
| locals { | ||
| redis_use_password_auth = var.redis_use_password_auth || var.redis_authentication_mode == "PASSWORD" | ||
| redis_use_iam_auth = var.redis_enable_iam_auth && !var.redis_use_password_auth | ||
| } | ||
|
|
||
| resource "random_id" "redis_password" { | ||
| count = var.active_active && local.redis_use_password_auth ? 1 : 0 | ||
| byte_length = 16 | ||
| } | ||
|
|
||
| resource "aws_security_group" "redis" { | ||
| count = var.active_active ? 1 : 0 | ||
| description = "The security group of the Redis deployment for TFE." | ||
| name = "${var.friendly_name_prefix}-tfe-redis" | ||
| vpc_id = var.network_id | ||
| resource "aws_elasticache_subnet_group" "tfe" { | ||
| count = var.active_active ? 1 : 0 | ||
| name = "${var.friendly_name_prefix}-tfe-redis" | ||
| subnet_ids = var.network_subnets_private | ||
|
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. what happens here if we use existing security groups
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. This always creates a new subnet group, even when using existing security groups. This could cause conflicts or resource duplication.
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. if it works with the existing configuration we should continue to do so. wydt?
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. It didn't worked with existing configuration. When using existing security groups, EC2 instances get the existing security group. |
||
| } | ||
|
|
||
| resource "aws_security_group_rule" "redis_tfe_ingress" { | ||
| count = var.active_active ? 1 : 0 | ||
| security_group_id = aws_security_group.redis[0].id | ||
| type = "ingress" | ||
| from_port = var.redis_port | ||
| to_port = var.redis_port | ||
| protocol = "tcp" | ||
| source_security_group_id = var.tfe_instance_sg | ||
| } | ||
| # Note: For IAM authentication, we let AWS manage the built-in "default" user | ||
| # We don't explicitly manage it since it's needed for IAM authentication with username "default" | ||
|
|
||
| resource "aws_security_group_rule" "redis_tfe_egress" { | ||
| count = var.active_active ? 1 : 0 | ||
| security_group_id = aws_security_group.redis[0].id | ||
| type = "egress" | ||
| from_port = 0 | ||
| to_port = 0 | ||
| protocol = "-1" | ||
| source_security_group_id = var.tfe_instance_sg | ||
| } | ||
| # ElastiCache User for IAM authentication | ||
| resource "aws_elasticache_user" "iam_user" { | ||
| count = var.active_active && local.redis_use_iam_auth ? 1 : 0 | ||
| user_id = "${var.friendly_name_prefix}-iam-user" | ||
| user_name = "${var.friendly_name_prefix}-iam-user" | ||
|
|
||
| resource "aws_security_group_rule" "redis_ingress" { | ||
| count = var.active_active ? 1 : 0 | ||
| security_group_id = aws_security_group.redis[0].id | ||
| type = "ingress" | ||
| from_port = var.redis_port | ||
| to_port = var.redis_port | ||
| protocol = "tcp" | ||
| cidr_blocks = var.network_private_subnet_cidrs | ||
| } | ||
| # For IAM authentication, we don't set passwords but use IAM policies | ||
| authentication_mode { | ||
| type = "iam" | ||
| } | ||
|
|
||
| # Access string for Redis commands - IAM auth compatible | ||
| # Use default access string for TFE with IAM authentication | ||
| access_string = "on ~* &* +@all" | ||
| engine = "REDIS" | ||
|
|
||
| tags = { | ||
| Name = "${var.friendly_name_prefix}-redis-iam-user" | ||
| } | ||
|
|
||
| resource "aws_security_group_rule" "redis_egress" { | ||
| count = var.active_active ? 1 : 0 | ||
| security_group_id = aws_security_group.redis[0].id | ||
| type = "egress" | ||
| from_port = var.redis_port | ||
| to_port = var.redis_port | ||
| protocol = "tcp" | ||
| cidr_blocks = var.network_private_subnet_cidrs | ||
| } | ||
|
|
||
| resource "aws_elasticache_subnet_group" "tfe" { | ||
| count = var.active_active ? 1 : 0 | ||
| name = "${var.friendly_name_prefix}-tfe-redis" | ||
| subnet_ids = var.network_subnets_private | ||
| # ElastiCache User Group for IAM authentication | ||
| # AWS requires the "default" user to be included in all user groups | ||
| # We include both "default" (for IAM auth) and our custom IAM user | ||
| resource "aws_elasticache_user_group" "iam_group" { | ||
| count = var.active_active && local.redis_use_iam_auth ? 1 : 0 | ||
| engine = "REDIS" | ||
| user_group_id = "${var.friendly_name_prefix}-iam-group" | ||
| user_ids = [ | ||
| "default", # AWS-managed default user for IAM authentication | ||
| aws_elasticache_user.iam_user[0].user_id | ||
| ] | ||
|
|
||
| tags = { | ||
| Name = "${var.friendly_name_prefix}-redis-iam-group" | ||
| } | ||
|
|
||
| depends_on = [ | ||
| aws_elasticache_user.iam_user | ||
| ] | ||
| } | ||
|
|
||
| resource "aws_elasticache_replication_group" "redis" { | ||
|
|
@@ -77,15 +78,27 @@ resource "aws_elasticache_replication_group" "redis" { | |
| engine_version = var.engine_version | ||
| parameter_group_name = var.parameter_group_name | ||
| port = var.redis_port | ||
| security_group_ids = [aws_security_group.redis[0].id] | ||
| security_group_ids = [var.tfe_instance_sg] # Reuse TFE security group instead of creating separate one | ||
| snapshot_retention_limit = 0 | ||
| subnet_group_name = aws_elasticache_subnet_group.tfe[0].name | ||
|
|
||
| # Password used to access a password protected server. | ||
| # Can be specified only if transit_encryption_enabled = true. | ||
| auth_token = var.redis_encryption_in_transit && local.redis_use_password_auth ? random_id.redis_password[0].hex : null | ||
| # For IAM authentication, auth_token must be null to force IAM-only authentication | ||
| auth_token = var.redis_encryption_in_transit && local.redis_use_password_auth ? random_id.redis_password[0].hex : null | ||
|
|
||
| # Transit encryption is required when using user groups (IAM authentication) | ||
| transit_encryption_enabled = var.redis_encryption_in_transit | ||
|
|
||
| at_rest_encryption_enabled = var.redis_encryption_at_rest | ||
| kms_key_id = var.redis_encryption_at_rest ? var.kms_key_arn : null | ||
|
|
||
| # IAM authentication configuration | ||
| user_group_ids = local.redis_use_iam_auth ? [aws_elasticache_user_group.iam_group[0].user_group_id] : null | ||
|
|
||
| # Ensure proper dependency ordering for IAM authentication | ||
| depends_on = [ | ||
| aws_elasticache_user_group.iam_group, | ||
| aws_elasticache_user.iam_user | ||
| ] | ||
| } | ||
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.
This module source references a feature branch (
pravi/IND-5861) instead ofmain. According to the PR description, this should be updated tomainbefore merging.