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(rancher): AWS - Switch Rancher Server public ip to EIP #243

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions rancher/aws/infra.tf
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,13 @@ resource "aws_security_group" "rancher_sg_allowall" {
}
}

# EIP resource for Rancher Server
resource "aws_eip" "rancher_server" {
domain = "vpc"

depends_on = [aws_internet_gateway.rancher_gateway]
}

# AWS EC2 instance for creating a single node RKE cluster and installing the Rancher server
resource "aws_instance" "rancher_server" {
depends_on = [
Expand Down Expand Up @@ -130,11 +137,17 @@ resource "aws_instance" "rancher_server" {
}
}

# EIP explicit allocation for Rancher Server
resource "aws_eip_association" "rancher_server" {
instance_id = aws_instance.rancher_server.id
allocation_id = aws_eip.rancher_server.id
}

# Rancher resources
module "rancher_common" {
source = "../rancher-common"

node_public_ip = aws_instance.rancher_server.public_ip
node_public_ip = aws_eip_association.rancher_server.public_ip
node_internal_ip = aws_instance.rancher_server.private_ip
node_username = local.node_username
ssh_private_key_pem = tls_private_key.global_key.private_key_pem
Expand All @@ -144,7 +157,7 @@ module "rancher_common" {
rancher_version = var.rancher_version
rancher_helm_repository = var.rancher_helm_repository

rancher_server_dns = join(".", ["rancher", aws_instance.rancher_server.public_ip, "sslip.io"])
rancher_server_dns = join(".", ["rancher", aws_eip_association.rancher_server.public_ip, "sslip.io"])

admin_password = var.rancher_server_admin_password

Expand Down
2 changes: 1 addition & 1 deletion rancher/aws/output.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ output "rancher_server_url" {
}

output "rancher_node_ip" {
value = aws_instance.rancher_server.public_ip
value = aws_eip.rancher_server.public_ip
}

output "workload_node_ip" {
Expand Down