`hashicorp/terraform-exec`에서 `ApplyConfig`를 `tf.Apply()`에 전달하는 방법은 무엇입니까?

王林
풀어 주다: 2024-02-09 10:50:29
앞으로
412명이 탐색했습니다.

如何将 `ApplyConfig` 传递给 `hashicorp / terraform-exec` 中的 `tf.Apply()`?

php 편집기 Yuzi가 `hashicorp/terraform-exec`에서 `ApplyConfig`를 `tf.Apply()`에 전달하는 방법을 설명할 것입니다. Terraform 배포에 `hashicorp/terraform-exec`를 사용하는 경우 `ApplyConfig` 객체를 생성하여 `tf.Apply()`의 동작을 구성할 수 있습니다. 그런 다음 이 객체는 적절한 배포 작업을 위해 `tf.Apply()` 메서드에 전달됩니다. 이러한 방식으로 배포 프로세스를 유연하게 제어하고 사용자 정의된 구성 요구 사항을 구현할 수 있습니다. 실제 애플리케이션에서는 특정 비즈니스 요구 사항에 따라 'ApplyConfig' 개체의 속성을 설정하여 최상의 배포 효과를 얻을 수 있습니다.

질문 내용

hashicorp/terraform-exec에서 golang SDK를 사용하여 terraform apply ​​​​commandtarget

을 추가하려고 합니다. 이상적으로 cli에 해당하는 명령은

terraform apply --auto-approve --target 'module.example'

입니다. 그런데 함수에

를 추가하면 다음과 같은 오류가 발생합니다. applyoptions{} 中的 targets 传递给 apply()

누군가 내가 여기서 뭘 하고 있는지 지적해 줄 수 있나요?

으아악

오류 표시,

invalid 复合文字类型 tfexec.applyoptioncompiler

package main

import (
    "context"

    "github.com/hashicorp/terraform-exec/tfexec"
)

func main() {
    // create a new tfexec.executor instance
    tf, err := tfexec.newterraform("/path/to/terraform/binary")
    if err != nil {
        panic(err)
    }
    err = tf.init(context.background(), tfexec.upgrade(true))
    if err != nil {
        panic(err)
    }
    // define the targets you want to apply
    targets := []string{"module.example", "module.another_example"}

    // create an applyoption with the targets
    applyoption := tfexec.applyoption{
        targets: targets,
    }

    // apply the terraform configuration with the defined targets
    err = tf.apply(context.background(), applyoption)
    if err != nil {
        panic(err)
    }
}
로그인 후 복사

Solution

다음이 효과가 있을 것 같아요:

으아악

위 내용은 `hashicorp/terraform-exec`에서 `ApplyConfig`를 `tf.Apply()`에 전달하는 방법은 무엇입니까?의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

원천:stackoverflow.com
본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
인기 튜토리얼
더>
최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿
회사 소개 부인 성명 Sitemap
PHP 중국어 웹사이트:공공복지 온라인 PHP 교육,PHP 학습자의 빠른 성장을 도와주세요!