Skip to content
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

feat: Add module to migrate from public dns to private setting #325

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

sanster23
Copy link

@sanster23 sanster23 commented Jan 20, 2025

Feat: Adding a new module here so that users who have setup an AWS External DNS WandB stack can migrate it to a private stack (which is only accessible inside AWS network)

Assumptions/Pre-reqs:

  • AWS external dns setup ready
  • User has a private network setup in AWS (for eg: OpenVpn)
  • User has a Private hosted zone setup in AWS

New Module added - migrate-public-to-private. This module will create following resources and will not touch any of the current external stack resources, so this will be a plug and play solution that introduces no drift in current terraform.

If users need to migrate to private they can just add this module. If they want to revert to original public setting, simply remove this module.

Below is a list of resources that will be created for private access:

  • NLB in private subnet
  • Security group for NLB
  • Target Group and Listener
    • K8s ALB will be the target
  • Route53 DNS record in private hosted zone
    • Record points towards NLB.

New flow should look like this:
image

And the new sample tfvars with variables introduced:

namespace   = "wandb"
domain_name = "mywandb.io"
subdomain   = "test"
zone_id     = "Zxxxxxxxxxxx"
wandb_license = "xxxx"

migrate_public_to_private           = true
private_hosted_zone_id              = "Zxxxx"
private_dns_network_id              = "vpc-xxx"
private_dns_network_cidr_block      = "10.x.x.x/16"
private_dns_network_private_subnets = ["subnet-xxxx", "subnet-xxxx"]

Attaching output and screenshot
wandb_private
out.log

@sanster23 sanster23 linked an issue Jan 20, 2025 that may be closed by this pull request
@sanster23 sanster23 changed the title feat: add module to migrate from public dns to private setting feat: Add module to migrate from public dns to private setting Jan 20, 2025
Copy link
Contributor

@flamarion flamarion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this first iteration, I think it's fine we make the customer input all data from their private network. We can improve it in the future and create all all of these things if the customer do not supply the network configuration.
Main changes here are:

  • Ensure to use the dynamic configuration from main module to configure the ALB. Making it tied to a string concatenation is very fragile, so we need to ensure we're pointing to something that exists in the main module without worry about names.
  • Do not use the private network from the main module in the examples. They are used by Kubernetes Cluster and we don't want to mix the subnets. Leave this decision for the customners.

@@ -0,0 +1,82 @@
# get alb arn from the output of data
data "aws_lb" "alb" {
name = "${var.namespace}-alb-k8s"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should use the output from the main module or make this an env var.
Example: If this is part of the main module, we may want to use local.lb_name_truncated

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ack, updated code

variable "private_hosted_zone_id" {
description = "Private hosted zone id if migrating from public to private"
type = string
default = ""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I leave this an empty string, what is the result?
It should be mandatory, or a new private hosted zone will be created if empty.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh yes, made this params mandatory

Comment on lines 98 to 100
vpc_id = module.wandb_infra.network_id
subnet_ids = module.wandb_infra.network_private_subnets
vpc_cidr_block = module.wandb_infra.network_cidr
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These network configurations from the main module are used to configure the Kubernetes cluster.
The example shouldn't use it, but the network configuration from where the Customer will access the service.
If the customer wants to use the same network as the Kubernetes cluster, that's okay, but I don't recommend putting the Kubernetes and the VMs that will use the service in the same subnet.
We must let the customer decide.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ack, updated code

@sanster23 sanster23 marked this pull request as ready for review January 23, 2025 07:02
Copy link
Contributor

@flamarion flamarion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add the same instructions you added to the PR to a README.md inside the module and in the example folder?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Converting W&B Endpoint from Public to Private
2 participants