gpt4 book ai didi

amazon-web-services - 地形 | AWS ECS 服务 |每个 tf apply 所需的计数值更改

转载 作者:行者123 更新时间:2023-12-04 09:43:59 26 4
gpt4 key购买 nike

当我做 terraform apply每次所需的计数从 1 -> 2 变化时。请提出建议。
但是在 variables.tf , 我声明为 desired_count=2 .

~ resource "aws_ecs_service" "ecs_service" {
cluster = "arn:aws:ecs::cluster/"
deployment_maximum_percent = 200
deployment_minimum_healthy_percent = 100
~ desired_count = 1 -> 2
enable_ecs_managed_tags = false
force_new_deployment = true
health_check_grace_period_seconds = 0
iam_role = "aws-service-role"
id = "arn:aws:ecs:-ecs-service"
launch_type = "FARGATE"
name = "ecs-service"
platform_version = "LATEST"
propagate_tags = "NONE"
scheduling_strategy = "REPLICA"
tags = {}
task_definition = "arn:aws:ecs:"
deployment_controller {
type = "ECS"
}
load_balancer {
container_name = "abcd"
container_port = 80
target_group_arn = "arn.*"
}
network_configuration {
assign_public_ip = false
security_groups = []
subnets = []
}
}

这是main.tf:-
备注 :- 我正在使用模块来调用 main.tf。
############ ECS Service ##############
resource "aws_ecs_service" "ecs_service" {
name = "${var.name}-ecs-service"
cluster = var.cluster_id
task_definition = var.task_definition_arn
desired_count = var.desired_count
iam_role = var.ecs_iam_role
force_new_deployment = var.force_new_deployment
launch_type = "FARGATE"
deployment_controller {
type = "ECS"
}
deployment_maximum_percent = "200"
deployment_minimum_healthy_percent = "100"
load_balancer {
target_group_arn = var.lb_tg_arn
container_name = var.name
container_port = var.port
}
network_configuration {
security_groups = var.security_group_id
subnets = var.subnets
assign_public_ip = var.assign_public_ip
}
depends_on = [var.aws_alb]
}

通过设置 default=null 来根据我的项目的要求分配变量

最佳答案

不确定是什么真正导致了更改,但如果您只想静音更改,您可以忽略 terraform docs 中所述的更改。

resource "aws_ecs_service" "example" {
# ... other configurations ...

# Example: Create service with 2 instances to start
desired_count = 2

# Optional: Allow external changes without Terraform plan difference
lifecycle {
ignore_changes = [desired_count]
}
}

关于amazon-web-services - 地形 | AWS ECS 服务 |每个 tf apply 所需的计数值更改,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62203702/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com