Skip to content

Commit 687e8d6

Browse files
authored
Merge pull request #52 from zama-ai/ghislain/chore/supporte-multiple-scenarios-for-aws-private-link
chore(mpc-party): improve AWS PrivateLink integration by including AZs in consumer config
2 parents 719facd + 49f3fc6 commit 687e8d6

File tree

13 files changed

+50
-32
lines changed

13 files changed

+50
-32
lines changed

examples/mpc-party/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ module "mpc_party" {
1111
enable_region_validation = var.enable_region_validation
1212

1313
# Party configuration
14-
party_id = var.party_id
14+
party_id = var.party_id
1515
party_name = var.party_name
1616
bucket_prefix = var.bucket_prefix
1717

examples/terragrunt-infra/kms-dev-v1/mpc-party/terraform.tfvars

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ tags = {
3030
}
3131

3232
# RDS Configuration
33-
enable_rds = false
34-
rds_prefix = "zama" # Use your organization prefix here
35-
rds_db_name = "kmsconnector"
36-
rds_username = "kmsconnector"
37-
rds_enable_master_password_rotation = true # To change to 'false' on second apply only (there is a bug when initializing the value to 'false')
38-
rds_deletion_protection = false # Allow deletion of RDS instance
33+
enable_rds = false
34+
rds_prefix = "zama" # Use your organization prefix here
35+
rds_db_name = "kmsconnector"
36+
rds_username = "kmsconnector"
37+
rds_enable_master_password_rotation = true # To change to 'false' on second apply only (there is a bug when initializing the value to 'false')
38+
rds_deletion_protection = false # Allow deletion of RDS instance
3939

4040
# Node Group Configuration
4141
create_nodegroup = true

examples/terragrunt-infra/zws-dev/mpc-party/terraform.tfvars

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ tags = {
3030
}
3131

3232
# RDS Configuration
33-
enable_rds = false
34-
rds_prefix = "zama" # Use your organization prefix here
35-
rds_db_name = "kmsconnector"
36-
rds_username = "kmsconnector"
37-
rds_enable_master_password_rotation = true # To change to 'false' on second apply only (there is a bug when initializing the value to 'false')
38-
rds_deletion_protection = false # Allow deletion of RDS instance
33+
enable_rds = false
34+
rds_prefix = "zama" # Use your organization prefix here
35+
rds_db_name = "kmsconnector"
36+
rds_username = "kmsconnector"
37+
rds_enable_master_password_rotation = true # To change to 'false' on second apply only (there is a bug when initializing the value to 'false')
38+
rds_deletion_protection = false # Allow deletion of RDS instance
3939

4040
# Node Group Configuration
4141
create_nodegroup = true

modules/mpc-party/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ The module can optionally create:
426426
| <a name="input_rds_k8s_secret_namespace"></a> [rds\_k8s\_secret\_namespace](#input\_rds\_k8s\_secret\_namespace) | n/a | `string` | `"default"` | no |
427427
| <a name="input_rds_maintenance_window"></a> [rds\_maintenance\_window](#input\_rds\_maintenance\_window) | n/a | `string` | `null` | no |
428428
| <a name="input_rds_manage_master_user_password"></a> [rds\_manage\_master\_user\_password](#input\_rds\_manage\_master\_user\_password) | If true, let AWS Secrets Manager manage the master user password. If false, a random\_password will be generated and stored to K8s secrets. | `bool` | `false` | no |
429-
| <a name="input_rds_master_password_rotation_days"></a> [rds\_master\_password\_rotation\_days](#input\_rds\_master\_password\_rotation\_days) | Number of days between automatic scheduled rotations of the secret, default is set to a large number not to rotate password if rotation is not desired but not yet disabled | `number` | `1000000000` | no |
429+
| <a name="input_rds_master_password_rotation_days"></a> [rds\_master\_password\_rotation\_days](#input\_rds\_master\_password\_rotation\_days) | Number of days between automatic scheduled rotations of the secret, default is set to the maximum allowed value of 1000 days | `number` | `1000` | no |
430430
| <a name="input_rds_max_allocated_storage"></a> [rds\_max\_allocated\_storage](#input\_rds\_max\_allocated\_storage) | Max autoscaled storage in GiB. | `number` | `100` | no |
431431
| <a name="input_rds_monitoring_interval"></a> [rds\_monitoring\_interval](#input\_rds\_monitoring\_interval) | n/a | `number` | `0` | no |
432432
| <a name="input_rds_monitoring_role_arn"></a> [rds\_monitoring\_role\_arn](#input\_rds\_monitoring\_role\_arn) | n/a | `string` | `null` | no |

modules/mpc-party/main.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -770,9 +770,9 @@ module "rds_instance" {
770770
username = var.rds_username
771771
port = var.rds_port
772772

773-
password = var.rds_db_password
774-
manage_master_user_password = var.rds_db_password != null ? false : true
775-
manage_master_user_password_rotation = var.rds_enable_master_password_rotation
773+
password = var.rds_db_password
774+
manage_master_user_password = var.rds_db_password != null ? false : true
775+
manage_master_user_password_rotation = var.rds_enable_master_password_rotation
776776
master_user_password_rotation_automatically_after_days = var.rds_master_password_rotation_days
777777

778778
iam_database_authentication_enabled = false

modules/mpc-party/variables.tf

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -504,20 +504,20 @@ variable "rds_deletion_protection" {
504504

505505
variable "rds_db_password" {
506506
description = "RDS password to be set from inputs (must be longer than 8 chars), will disable RDS automatic SecretManager password"
507-
type = string
508-
default = null
507+
type = string
508+
default = null
509509
}
510510

511511
variable "rds_enable_master_password_rotation" {
512512
description = "Whether to manage the master user password rotation. By default, false on creation, rotation is managed by RDS. There is not currently no way to disable this on initial creation even when set to false. Setting this value to false after previously having been set to true will disable automatic rotation."
513-
type = bool
514-
default = true
513+
type = bool
514+
default = true
515515
}
516516

517517
variable "rds_master_password_rotation_days" {
518518
description = "Number of days between automatic scheduled rotations of the secret, default is set to the maximum allowed value of 1000 days"
519-
type = number
520-
default = 1000
519+
type = number
520+
default = 1000
521521
}
522522

523523
variable "rds_delete_automated_backups" {
@@ -582,7 +582,7 @@ variable "rds_parameters" {
582582
description = "List of DB parameter maps for the parameter group."
583583
type = list(map(string))
584584
# Required by KMS-Connector which currently lacks ssl certificates
585-
default = [{
585+
default = [{
586586
name = "rds.force_ssl"
587587
value = "0"
588588
}]

modules/vpc-endpoint-consumer/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ No modules.
5151
| <a name="input_name_prefix"></a> [name\_prefix](#input\_name\_prefix) | Prefix for naming VPC interface endpoint resources | `string` | `"mpc-partner"` | no |
5252
| <a name="input_namespace"></a> [namespace](#input\_namespace) | Kubernetes namespace where partner services will be created | `string` | `"mpc-partners"` | no |
5353
| <a name="input_network_environment"></a> [network\_environment](#input\_network\_environment) | MPC network environment that determines region constraints | `string` | `"testnet"` | no |
54-
| <a name="input_party_services"></a> [party\_services](#input\_party\_services) | List of partner MPC services to connect to via VPC interface endpoints | <pre>list(object({<br/> name = string<br/> region = string<br/> party_id = string<br/> account_id = optional(string, null)<br/> partner_name = optional(string, null)<br/> vpc_endpoint_service_name = string<br/> ports = optional(list(object({<br/> name = string<br/> port = number<br/> target_port = number<br/> protocol = string<br/> })), null)<br/> create_kube_service = optional(bool, true)<br/> kube_service_config = optional(object({<br/> additional_annotations = optional(map(string), {})<br/> labels = optional(map(string), {})<br/> session_affinity = optional(string, "None")<br/> }), {})<br/> }))</pre> | n/a | yes |
54+
| <a name="input_party_services"></a> [party\_services](#input\_party\_services) | List of partner MPC services to connect to via VPC interface endpoints | <pre>list(object({<br/> name = string<br/> region = string<br/> party_id = string<br/> account_id = optional(string, null)<br/> partner_name = optional(string, null)<br/> vpc_endpoint_service_name = string<br/> ports = optional(list(object({<br/> name = string<br/> port = number<br/> target_port = number<br/> protocol = string<br/> })), null)<br/> availability_zones = optional(list(string), null)<br/> create_kube_service = optional(bool, true)<br/> kube_service_config = optional(object({<br/> additional_annotations = optional(map(string), {})<br/> labels = optional(map(string), {})<br/> session_affinity = optional(string, "None")<br/> }), {})<br/> }))</pre> | n/a | yes |
5555
| <a name="input_private_dns_enabled"></a> [private\_dns\_enabled](#input\_private\_dns\_enabled) | Whether to enable private DNS for the VPC interface endpoints | `bool` | `false` | no |
5656
| <a name="input_private_zone_id"></a> [private\_zone\_id](#input\_private\_zone\_id) | Route53 private hosted zone ID for custom DNS records | `string` | `""` | no |
5757
| <a name="input_route_table_ids"></a> [route\_table\_ids](#input\_route\_table\_ids) | List of route table IDs to associate with the VPC interface endpoints | `list(string)` | `[]` | no |

modules/vpc-endpoint-consumer/main.tf

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ locals {
4444
for service in var.party_services : service.vpc_endpoint_service_name
4545
]
4646

47-
4847
# Create a map for easy reference with default ports fallback
4948
partner_service_map = {
5049
for i, service in var.party_services : "${service.name}-${i}" => {
@@ -70,10 +69,13 @@ locals {
7069
resource "aws_vpc_endpoint" "party_interface_endpoints" {
7170
count = length(var.party_services)
7271

73-
vpc_id = local.vpc_id
74-
service_name = local.vpc_endpoint_service_names[count.index]
75-
vpc_endpoint_type = "Interface"
76-
subnet_ids = local.subnet_ids
72+
vpc_id = local.vpc_id
73+
service_name = local.vpc_endpoint_service_names[count.index]
74+
vpc_endpoint_type = "Interface"
75+
subnet_ids = length(coalesce(var.party_services[count.index].availability_zones, [])) > 0 && var.cluster_name != null ? [
76+
for subnet_id, subnet in data.aws_subnet.cluster_subnets : subnet_id
77+
if subnet.map_public_ip_on_launch == false && contains(var.party_services[count.index].availability_zones, subnet.availability_zone)
78+
] : local.subnet_ids
7779
security_group_ids = local.security_group_ids
7880
service_region = var.party_services[count.index].region
7981

modules/vpc-endpoint-consumer/variables.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ variable "party_services" {
6868
target_port = number
6969
protocol = string
7070
})), null)
71+
availability_zones = optional(list(string), null)
7172
create_kube_service = optional(bool, true)
7273
kube_service_config = optional(object({
7374
additional_annotations = optional(map(string), {})

modules/vpc-endpoint-provider/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,15 @@
77
|------|---------|
88
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
99
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 6.0 |
10+
| <a name="requirement_kubernetes"></a> [kubernetes](#requirement\_kubernetes) | >= 2.23 |
1011

1112
## Providers
1213

1314
| Name | Version |
1415
|------|---------|
1516
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 6.0 |
1617
| <a name="provider_external"></a> [external](#provider\_external) | n/a |
17-
| <a name="provider_kubernetes"></a> [kubernetes](#provider\_kubernetes) | n/a |
18+
| <a name="provider_kubernetes"></a> [kubernetes](#provider\_kubernetes) | >= 2.23 |
1819

1920
## Modules
2021

@@ -30,6 +31,7 @@ No modules.
3031
| [aws_caller_identity.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | data source |
3132
| [aws_lb.kubernetes_nlb](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/lb) | data source |
3233
| [aws_region.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/region) | data source |
34+
| [aws_subnet.nlb_subnet](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/subnet) | data source |
3335
| [external_external.wait_nlb](https://registry.terraform.io/providers/hashicorp/external/latest/docs/data-sources/external) | data source |
3436

3537
## Inputs

0 commit comments

Comments
 (0)