terraform에서 AWS RDS (Aurora) 설정을 변경하지 않았지만 must be replaced가되는 경우
무엇이 어려웠습니까?
왜 그렇게 곤란한가?
데이터베이스를 건너 뛰는 위험이 높습니다 (rds 용 tf 파일 만 다른 디렉토리에 배치하고 피했습니다).
그 곤란한 거야 너만이 아닌 거야?
tf 파일을 보여주세요.
rds.tfresource "aws_db_subnet_group" "sample" {
name = "sample"
subnet_ids = [aws_subnet.private_0.id, aws_subnet.private_1.id]
}
resource "aws_db_parameter_group" "sample" {
name = "sample"
family = "aurora-mysql5.7"
}
resource "aws_rds_cluster_parameter_group" "sample" {
name = "sample"
family = "aurora-mysql5.7"
description = "Cluster parameter for sample"
parameter {
name = "character_set_client"
value = "utf8mb4"
}
parameter {
name = "character_set_connection"
value = "utf8mb4"
}
parameter {
name = "character_set_database"
value = "utf8mb4"
}
parameter {
name = "character_set_filesystem"
value = "utf8mb4"
}
parameter {
name = "character_set_results"
value = "utf8mb4"
}
parameter {
name = "character_set_server"
value = "utf8mb4"
}
parameter {
name = "collation_connection"
value = "utf8mb4_general_ci"
}
parameter {
name = "collation_server"
value = "utf8mb4_general_ci"
}
parameter {
name = "time_zone"
value = "Asia/Tokyo"
}
}
resource "aws_rds_cluster" "sample-cluster" {
cluster_identifier = "sample-cluster"
engine = "aurora-mysql"
availability_zones = ["ap-northeast-1a", "ap-northeast-1c"]
database_name = "sample"
master_username = "admin"
master_password = "DeraDeraderaDeraDera"
deletion_protection = true
apply_immediately = false
backup_retention_period = 30
preferred_backup_window = "09:10-09:40" # UTC (JST-9)
preferred_maintenance_window = "wed:09:45-wed:10:45"
port = 3306
vpc_security_group_ids = [module.mysql_sg.security_group_id]
db_subnet_group_name = aws_db_subnet_group.sample.name
storage_encrypted = true
db_cluster_parameter_group_name = aws_rds_cluster_parameter_group.sample.name
skip_final_snapshot = true
lifecycle {
ignore_changes = ["master_password"]
}
}
resource "aws_rds_cluster_instance" "sample" {
count = 2
identifier = "sample-${count.index}"
engine = "aurora-mysql"
engine_version = "5.7.12"
cluster_identifier = aws_rds_cluster.sample-cluster.id
instance_class = "db.r3.xlarge"
db_subnet_group_name = aws_db_subnet_group.sample.name
db_parameter_group_name = aws_db_parameter_group.sample.name
publicly_accessible = false
}
module "mysql_sg" {
source = "./security_group"
name = "mysql-sg"
vpc_id = aws_vpc.sample.id
port = 3306
cidr_blocks = [aws_vpc.sample.cidr_block]
}
흠, 어디서 고쳤어?
resource "aws_db_subnet_group" "sample" {
name = "sample"
subnet_ids = [aws_subnet.private_0.id, aws_subnet.private_1.id]
}
resource "aws_db_parameter_group" "sample" {
name = "sample"
family = "aurora-mysql5.7"
}
resource "aws_rds_cluster_parameter_group" "sample" {
name = "sample"
family = "aurora-mysql5.7"
description = "Cluster parameter for sample"
parameter {
name = "character_set_client"
value = "utf8mb4"
}
parameter {
name = "character_set_connection"
value = "utf8mb4"
}
parameter {
name = "character_set_database"
value = "utf8mb4"
}
parameter {
name = "character_set_filesystem"
value = "utf8mb4"
}
parameter {
name = "character_set_results"
value = "utf8mb4"
}
parameter {
name = "character_set_server"
value = "utf8mb4"
}
parameter {
name = "collation_connection"
value = "utf8mb4_general_ci"
}
parameter {
name = "collation_server"
value = "utf8mb4_general_ci"
}
parameter {
name = "time_zone"
value = "Asia/Tokyo"
}
}
resource "aws_rds_cluster" "sample-cluster" {
cluster_identifier = "sample-cluster"
engine = "aurora-mysql"
availability_zones = ["ap-northeast-1a", "ap-northeast-1c"]
database_name = "sample"
master_username = "admin"
master_password = "DeraDeraderaDeraDera"
deletion_protection = true
apply_immediately = false
backup_retention_period = 30
preferred_backup_window = "09:10-09:40" # UTC (JST-9)
preferred_maintenance_window = "wed:09:45-wed:10:45"
port = 3306
vpc_security_group_ids = [module.mysql_sg.security_group_id]
db_subnet_group_name = aws_db_subnet_group.sample.name
storage_encrypted = true
db_cluster_parameter_group_name = aws_rds_cluster_parameter_group.sample.name
skip_final_snapshot = true
lifecycle {
ignore_changes = ["master_password"]
}
}
resource "aws_rds_cluster_instance" "sample" {
count = 2
identifier = "sample-${count.index}"
engine = "aurora-mysql"
engine_version = "5.7.12"
cluster_identifier = aws_rds_cluster.sample-cluster.id
instance_class = "db.r3.xlarge"
db_subnet_group_name = aws_db_subnet_group.sample.name
db_parameter_group_name = aws_db_parameter_group.sample.name
publicly_accessible = false
}
module "mysql_sg" {
source = "./security_group"
name = "mysql-sg"
vpc_id = aws_vpc.sample.id
port = 3306
cidr_blocks = [aws_vpc.sample.cidr_block]
}
코코 에 써 있는 방법으로 고치는 데 성공했어!
lifecycle의 ignore_changes에
"availability_zones"
를 추가하면 예상대로 움직입니다. 같은 문제로 곤란한 사람의 도움이 되었으면 좋겠습니다 rds.tf
resource "aws_rds_cluster" "sample-cluster" {
cluster_identifier = "sample-cluster"
engine = "aurora-mysql"
availability_zones = ["ap-northeast-1a", "ap-northeast-1c"]
database_name = "sample"
master_username = "admin"
master_password = "DeraDeraderaDeraDera"
deletion_protection = true
apply_immediately = false
backup_retention_period = 30
preferred_backup_window = "09:10-09:40" # UTC (JST-9)
preferred_maintenance_window = "wed:09:45-wed:10:45"
port = 3306
vpc_security_group_ids = [module.mysql_sg.security_group_id]
db_subnet_group_name = aws_db_subnet_group.sample.name
storage_encrypted = true
db_cluster_parameter_group_name = aws_rds_cluster_parameter_group.sample.name
skip_final_snapshot = true
lifecycle {
ignore_changes = ["master_password", "availability_zones"]
}
}
Reference
이 문제에 관하여(terraform에서 AWS RDS (Aurora) 설정을 변경하지 않았지만 must be replaced가되는 경우), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/temosy/items/92cc1271e182ceb84d00텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)