-
Notifications
You must be signed in to change notification settings - Fork 103
Release Tests for AWS Redis passwordless authentication #380
Changes from 17 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
7f8376f
a55b07e
3ff3ab3
6a6b3a6
de31c27
87fd295
d937b79
1a775f5
e69b364
c87fdf6
d9a55e3
2c50863
881c641
f151253
b954e95
8366ffe
07432c6
e316724
c7c5325
62392a8
a572905
154807a
c1f8428
91c2955
e49230b
762f429
f5d9cb7
45ef6ca
357d3a2
759bef2
7c87074
6ee636a
ab99974
34f0970
aaf3610
3641c33
1fc86e8
099f9e2
5577e5f
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 | ||||
|---|---|---|---|---|---|---|
|
|
@@ -253,7 +253,7 @@ module "aurora_database" { | |||||
| # Docker Compose File Config for TFE on instance(s) using Flexible Deployment Options | ||||||
| # ------------------------------------------------------------------------------------ | ||||||
| module "runtime_container_engine_config" { | ||||||
| source = "git::https://github.com/hashicorp/terraform-random-tfe-utility//modules/runtime_container_engine_config?ref=main" | ||||||
| source = "git::https://github.com/hashicorp/terraform-random-tfe-utility//modules/runtime_container_engine_config?ref=pravi/IND-5861" | ||||||
raviharshicorp marked this conversation as resolved.
Show resolved
Hide resolved
raviharshicorp marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
| count = var.is_replicated_deployment ? 0 : 1 | ||||||
|
|
||||||
| tfe_license = var.hc_license | ||||||
|
|
@@ -312,21 +312,22 @@ module "runtime_container_engine_config" { | |||||
| s3_server_side_encryption_kms_key_id = local.kms_key_arn | ||||||
| s3_use_instance_profile = var.aws_access_key_id == null ? "1" : "0" | ||||||
|
|
||||||
| redis_host = local.redis.hostname | ||||||
| redis_user = local.redis.username | ||||||
| redis_password = local.redis.password | ||||||
| redis_use_tls = local.redis.use_tls | ||||||
| redis_use_auth = local.redis.use_password_auth | ||||||
| redis_use_sentinel = var.enable_redis_sentinel | ||||||
| redis_sentinel_hosts = local.redis.sentinel_hosts | ||||||
| redis_sentinel_leader_name = local.redis.sentinel_leader | ||||||
| redis_sentinel_user = local.redis.sentinel_username | ||||||
| redis_sentinel_password = local.redis.sentinel_password | ||||||
| redis_use_mtls = var.enable_redis_mtls | ||||||
| enable_sentinel_mtls = var.enable_sentinel_mtls | ||||||
| redis_ca_cert_path = "/etc/ssl/private/terraform-enterprise/redis/cacert.pem" | ||||||
| redis_client_cert_path = "/etc/ssl/private/terraform-enterprise/redis/cert.pem" | ||||||
| redis_client_key_path = "/etc/ssl/private/terraform-enterprise/redis/key.pem" | ||||||
| redis_host = local.redis.hostname | ||||||
| redis_user = local.redis.username | ||||||
| redis_password = local.redis.password | ||||||
| redis_use_tls = local.redis.use_tls | ||||||
| redis_use_auth = local.redis.use_password_auth | ||||||
| redis_passwordless_aws_use_iam = var.redis_passwordless_aws_use_iam | ||||||
| redis_use_sentinel = var.enable_redis_sentinel | ||||||
| redis_sentinel_hosts = local.redis.sentinel_hosts | ||||||
| redis_sentinel_leader_name = local.redis.sentinel_leader | ||||||
| redis_sentinel_user = local.redis.sentinel_username | ||||||
| redis_sentinel_password = local.redis.sentinel_password | ||||||
| redis_use_mtls = var.enable_redis_mtls | ||||||
| enable_sentinel_mtls = var.enable_sentinel_mtls | ||||||
| redis_ca_cert_path = var.enable_redis_mtls || var.enable_sentinel_mtls ? "/etc/ssl/private/terraform-enterprise/redis/cacert.pem" : null | ||||||
| redis_client_cert_path = var.enable_redis_mtls || var.enable_sentinel_mtls ? "/etc/ssl/private/terraform-enterprise/redis/cert.pem" : null | ||||||
| redis_client_key_path = var.enable_redis_mtls || var.enable_sentinel_mtls ? "/etc/ssl/private/terraform-enterprise/redis/key.pem" : null | ||||||
|
|
||||||
|
|
||||||
| trusted_proxies = local.trusted_proxies | ||||||
|
|
@@ -343,7 +344,7 @@ module "runtime_container_engine_config" { | |||||
| # AWS cloud init used to install and configure TFE on instance(s) using Flexible Deployment Options | ||||||
| # -------------------------------------------------------------------------------------------------- | ||||||
| module "tfe_init_fdo" { | ||||||
| source = "git::https://github.com/hashicorp/terraform-random-tfe-utility//modules/tfe_init?ref=main" | ||||||
| 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=pravi/IND-5861" | |
| source = "git::https://github.com/hashicorp/terraform-random-tfe-utility//modules/tfe_init?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.
Will be changed before merging
raviharshicorp marked this conversation as resolved.
Show resolved
Hide resolved
raviharshicorp marked this conversation as resolved.
Show resolved
Hide resolved
raviharshicorp marked this conversation as resolved.
Show resolved
Hide resolved
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" |
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.
will be changed before merging.
raviharshicorp marked this conversation as resolved.
Show resolved
Hide resolved
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,14 +13,27 @@ output "name" { | |
|
|
||
| output "password" { | ||
| value = aws_db_instance.postgresql.password | ||
| description = "The password of the main PostgreSQL user." | ||
| description = "The password of the PostgreSQL master user. Required for creating IAM-enabled database users." | ||
raviharshicorp marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| sensitive = true | ||
|
Collaborator
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. ⭐ Good idea. |
||
| } | ||
|
|
||
| output "username" { | ||
| value = aws_db_instance.postgresql.username | ||
| description = "The name of the main PostgreSQL user." | ||
| } | ||
|
|
||
|
|
||
|
|
||
| output "identifier" { | ||
| value = aws_db_instance.postgresql.identifier | ||
raviharshicorp marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| description = "The database identifier of the PostgreSQL RDS instance." | ||
| } | ||
|
|
||
| output "dbi_resource_id" { | ||
| value = aws_db_instance.postgresql.resource_id | ||
raviharshicorp marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| description = "The DBI resource ID of the PostgreSQL RDS instance for IAM authentication." | ||
| } | ||
|
|
||
| output "parameters" { | ||
| value = var.db_parameters | ||
| description = "PostgreSQL server parameters for the connection URI." | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,6 +3,7 @@ | |
|
|
||
| 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" { | ||
|
|
@@ -63,6 +64,47 @@ resource "aws_elasticache_subnet_group" "tfe" { | |
| 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.
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. reverted to the original code. it seems to work with existing config. |
||
| } | ||
|
|
||
| # 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" | ||
|
|
||
| # 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" | ||
| } | ||
| } | ||
|
|
||
| # ElastiCache User Group for IAM authentication | ||
| # Note: AWS ElastiCache has a built-in "default" user that must be included in user groups | ||
| 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", # Built-in AWS ElastiCache default user | ||
| 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" { | ||
| count = var.active_active ? 1 : 0 | ||
| node_type = var.cache_size | ||
|
|
@@ -83,9 +125,20 @@ resource "aws_elasticache_replication_group" "redis" { | |
|
|
||
| # 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 | ||
| transit_encryption_enabled = var.redis_encryption_in_transit | ||
| 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 || local.redis_use_iam_auth | ||
raviharshicorp marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| 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 | ||
| ] | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.