Skip to content

Commit 61d5707

Browse files
authored
Ignore changes to names for CF imported resources (#244)
When migrating from Cloudformation to Terraform there are resources that are named differently and can't be renamed. The DB for example. This change tells terraform to ignore changes to the names in the case where CF resources with different naming patterns are imported into Terraform state. This will prevent terraform from trying to recreate it.
1 parent 26f2acf commit 61d5707

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

modules/database/main.tf

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ resource "aws_db_instance" "main" {
5858
identifier,
5959
kms_key_id,
6060
storage_encrypted,
61-
db_subnet_group_name
61+
db_subnet_group_name,
62+
db_name
6263
]
6364
}
6465
}
@@ -98,6 +99,7 @@ resource "aws_db_parameter_group" "main" {
9899

99100
lifecycle {
100101
create_before_destroy = true
102+
ignore_changes = [name_prefix, description]
101103
}
102104

103105
tags = local.common_tags
@@ -111,6 +113,7 @@ resource "aws_db_subnet_group" "main" {
111113

112114
lifecycle {
113115
create_before_destroy = true
116+
ignore_changes = [name_prefix]
114117
}
115118

116119
tags = local.common_tags
@@ -134,6 +137,10 @@ resource "aws_iam_role" "db_monitoring" {
134137

135138
permissions_boundary = var.permissions_boundary_arn
136139

140+
lifecycle {
141+
ignore_changes = [name]
142+
}
143+
137144
tags = local.common_tags
138145
}
139146

@@ -165,6 +172,10 @@ resource "aws_secretsmanager_secret" "database_secret" {
165172
description = "Username/password for the main Braintrust RDS database"
166173
kms_key_id = var.kms_key_arn
167174

175+
lifecycle {
176+
ignore_changes = [name, name_prefix]
177+
}
178+
168179
tags = local.common_tags
169180
}
170181

modules/services-common/secrets.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ resource "aws_secretsmanager_secret" "function_tools_secret" {
44
description = "Function environment variables encryption key"
55
kms_key_id = var.kms_key_arn
66
tags = local.common_tags
7+
8+
lifecycle {
9+
ignore_changes = [name, name_prefix]
10+
}
711
}
812

913
data "aws_secretsmanager_random_password" "function_tools_secret" {

0 commit comments

Comments
 (0)