Mark externally managed terraform resources to make infrastructure terraform appliable throughout its lifetime (#442)

* Mark externally managed terraform resources to make infrastructure terraform appliable throughout its lifetime
* Use correct field for nat gateway

Signed-off-by: Paul Meyer <49727155+katexochen@users.noreply.github.com>
Co-authored-by: Paul Meyer <49727155+katexochen@users.noreply.github.com>
This commit is contained in:
Malte Poll 2022-11-07 11:04:10 +01:00 committed by GitHub
parent a70161730f
commit fa6dfdff4f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 31 additions and 7 deletions

View File

@ -39,10 +39,14 @@ resource "aws_launch_template" "launch_template" {
lifecycle { lifecycle {
create_before_destroy = true create_before_destroy = true
ignore_changes = [
default_version, # required. update procedure creates new versions of the launch template
image_id, # required. update procedure modifies the image id externally
]
} }
} }
resource "aws_autoscaling_group" "control_plane_autoscaling_group" { resource "aws_autoscaling_group" "autoscaling_group" {
name = local.name name = local.name
launch_template { launch_template {
id = aws_launch_template.launch_template.id id = aws_launch_template.launch_template.id
@ -53,10 +57,6 @@ resource "aws_autoscaling_group" "control_plane_autoscaling_group" {
vpc_zone_identifier = [var.subnetwork] vpc_zone_identifier = [var.subnetwork]
target_group_arns = var.target_group_arns target_group_arns = var.target_group_arns
lifecycle {
create_before_destroy = true
}
tag { tag {
key = "Name" key = "Name"
value = local.name value = local.name
@ -78,4 +78,14 @@ resource "aws_autoscaling_group" "control_plane_autoscaling_group" {
value = "Constellation-${var.uid}" value = "Constellation-${var.uid}"
propagate_at_launch = true propagate_at_launch = true
} }
lifecycle {
create_before_destroy = true
ignore_changes = [
launch_template.0.version, # required. update procedure creates new versions of the launch template
min_size, # required. autoscaling modifies the instance count externally
max_size, # required. autoscaling modifies the instance count externally
desired_capacity, # required. autoscaling modifies the instance count externally
]
}
} }

View File

@ -43,7 +43,7 @@ resource "aws_route_table" "private_nat" {
route { route {
cidr_block = "0.0.0.0/0" cidr_block = "0.0.0.0/0"
gateway_id = aws_nat_gateway.gw.id nat_gateway_id = aws_nat_gateway.gw.id
} }
} }

View File

@ -78,4 +78,11 @@ resource "azurerm_linux_virtual_machine_scale_set" "scale_set" {
load_balancer_backend_address_pool_ids = var.backend_address_pool_ids load_balancer_backend_address_pool_ids = var.backend_address_pool_ids
} }
} }
lifecycle {
ignore_changes = [
instances, # required. autoscaling modifies the instance count externally
source_image_id, # required. update procedure modifies the image id externally
]
}
} }

View File

@ -94,4 +94,11 @@ resource "google_compute_instance_group_manager" "instance_group_manager" {
port = named_port.value.port port = named_port.value.port
} }
} }
lifecycle {
ignore_changes = [
target_size, # required. autoscaling modifies the instance count externally
version, # required. update procedure modifies the instance template externally
]
}
} }