Skip to content

Commit ea38c1b

Browse files
Merge pull request #8264 from r4f4/bootstrap-ssh-fix
OCPBUGS-32174: save correct bootstrap public IP
2 parents 1529d25 + 9b0c7e7 commit ea38c1b

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

data/data/aws/bootstrap/main.tf

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ resource "aws_instance" "bootstrap" {
161161
subnet_id = var.aws_publish_strategy == "External" ? var.public_subnet_ids[0] : var.private_subnet_ids[0]
162162
user_data = var.aws_bootstrap_stub_ignition
163163
vpc_security_group_ids = [var.master_sg_id, aws_security_group.bootstrap.id]
164-
associate_public_ip_address = local.public_endpoints
164+
associate_public_ip_address = local.public_endpoints && var.aws_public_ipv4_pool == ""
165165

166166
lifecycle {
167167
# Ignore changes in the AMI which force recreation of the resource. This
@@ -251,9 +251,17 @@ resource "aws_security_group_rule" "bootstrap_journald_gateway" {
251251
}
252252

253253
resource "aws_eip" "bootstrap" {
254+
count = var.aws_public_ipv4_pool == "" ? 0 : 1
254255
domain = "vpc"
255256
instance = aws_instance.bootstrap.id
256-
public_ipv4_pool = var.aws_public_ipv4_pool == "" ? null : var.aws_public_ipv4_pool
257+
public_ipv4_pool = var.aws_public_ipv4_pool
258+
259+
tags = merge(
260+
{
261+
"Name" = "${var.cluster_id}-bootstrap-eip"
262+
},
263+
local.tags,
264+
)
257265

258266
depends_on = [aws_instance.bootstrap]
259-
}
267+
}

data/data/aws/bootstrap/outputs.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
output "bootstrap_ip" {
2-
value = local.public_endpoints ? aws_instance.bootstrap.public_ip : aws_instance.bootstrap.private_ip
2+
value = var.aws_public_ipv4_pool != "" ? aws_eip.bootstrap[0].public_ip : local.public_endpoints ? aws_instance.bootstrap.public_ip : aws_instance.bootstrap.private_ip
33
}

0 commit comments

Comments
 (0)