相关疑难解决方法(0)

Terraform,"ignore_changes"和子块

我在terraform文件中配置了AWS CodePipeline,如下所示:

resource {
    name = "Cool Pipeline"
    ...

    stage {
        name = "Source"
        ...

        action {
            name = "Source"
            ...

            configuration {
                Owner = "Me"
                Repo = "<git-repo-uri>"
                Branch = develop
                OAuthToken = "b3287d649a28374e9283c749cc283ad74"
            }
        }
    }

    lifecycle {
        ignore_changes = "OAuthToken"
    }
}
Run Code Online (Sandbox Code Playgroud)

忽略令牌的原因是AWS API没有将该令牌显示为terraform,而是AWS API通过以下方式输出aws codepipeline get-pipeline <name>:

"pipeline": {
    "stages": {
        "name": "Source",
        "actions": {
            "configuration": {
                "OAuthToken": "****"
            }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

结果是,当我执行terraform plan它时,它显示我想要更新该令牌,如下所示:

module.modulename.aws_codepipeline.codepipeline
      stage.0.action.0.configuration.%:          "3" => "4"
      stage.0.action.0.configuration.OAuthToken: "" …
Run Code Online (Sandbox Code Playgroud)

amazon-web-services terraform aws-codepipeline

11
推荐指数
2
解决办法
5145
查看次数

即使存在ignore_changes开关,Terraform也会清除Azure应用程序配置设置

我在一个应用程序服务计划中包含三个网络应用程序。一个应用程序是前端,另一个是 API,第三个是功能应用程序。所有这些都包含在 Linux 应用服务计划中。

我在这三个应用程序中有很多应用程序配置设置。我注意到的是,如果我输入:

 lifecycle {
    ignore_changes = [
      "auth_settings",
      "app_settings"
    ]
  }
Run Code Online (Sandbox Code Playgroud)

每次应用后,terraform 都会继续从其中一个应用程序重写应用程序配置。如果我注释掉其中一个应用程序的 app_settings 以重新部署应用程序配置,则另一个应用程序将被清除。

这是 Terraform 中的错误还是其他问题?我正在使用 AzureRM 提供程序 2.0

代码如下所示:

module "name_app_service_plan" {
  version              = "~> 3.0"
  source               = "contoso.com/names/azurerm"
  providers            = { azurerm = azurerm, random = random }
  resource_environment = var.project.environment.name
  resource_location    = var.location
  resource_name        = var.project.name
}

module "name_app_service_api" {
  version              = "~> 3.0"
  source               = "contoso.com/names/azurerm"
  providers            = { azurerm = azurerm, random = random }
  resource_environment = var.project.environment.name
  resource_location    = …
Run Code Online (Sandbox Code Playgroud)

azure terraform azure-web-app-service terraform-provider-azure

5
推荐指数
1
解决办法
3306
查看次数