Terraform-ai
由 OpenAI ChatGPT 提供支持,透過提供智慧互動助理簡化了應用 Terraform HCL 檔案的流程。
terraform-ai
需要 OpenAI API 金鑰或 Azure OpenAI 服務 API 金鑰和終端點。
對於 OpenAI 和 Azure OpenAI,您可以使用下列環境變數:
export OPENAI_API_KEY= < your OpenAI key >
export OPENAI_DEPLOYMENT_NAME= < your OpenAI deployment/model name. defaults to " gpt-3.5-turbo " >
支援以下型號:
code-davinci-002
text-davinci-003
gpt-3.5-turbo-0301
(對於 Azure,部署必須命名為gpt-35-turbo-0301
)gpt-3.5-turbo
gpt-35-turbo-0301
gpt-4-0314
gpt-4-32k-0314
對於 Azure OpenAI 服務,您可以使用下列環境變數:
export AZURE_OPENAI_ENDPOINT= < your Azure OpenAI endpoint, like " https://my-aoi-endpoint.openai.azure.com " >
如果設定了AZURE_OPENAI_ENDPOINT
變量,則它將使用 Azure OpenAI 服務。否則,它將使用 OpenAI API。
新增到brew
tap 並安裝:
brew tap hubs-ai/terraform-ai https://github.com/hubs-ai/terraform-ai
brew install terraform-ai
可以設定--require-confirmation
標誌或REQUIRE_CONFIRMATION
環境變數以在應用清單之前提示使用者確認。預設為 true。
--temperature
標誌或TEMPERATURE
環境變數可以設定在 0 和 1 之間。較低的溫度將導致更確定的完成。預設為 0。
--working-dir
標誌或WORKING_DIR
環境變量,可為 Terraform 專案路徑設定。
--exec-dir
標誌或EXEC_DIR
環境變量,可以為 Terraform 執行二進位設定。
terraform-ai " create micro ec2 ubuntu image 20.04 with name hello-future "
? Attempting to store the following template:
resource " aws_instance " " hello_future " {
ami = " ami-0f65671a86f061fcd "
instance_type = " t2.micro "
tags = {
Name = " hello-future "
}
}
Use the arrow keys to navigate: ↓ ↑ → ←
? Would you like to apply this ? [Reprompt/Apply/Don ' t Apply]:
+ Reprompt
▸ Apply
Don ' t Apply
terraform-ai init " create aws provider in ohio "
? Attempting to apply the following template:
provider " aws " {
region = " us-east-2 "
alias = " Ohio "
}
Use the arrow keys to navigate: ↓ ↑ → ←
? Would you like to apply this ? [Reprompt/Apply/Don ' t Apply]:
+ Reprompt
▸ Apply
Don ' t Apply
--require-confirmation
標誌我從 https://github.com/sozercan/kubectl-ai 託管的儲存庫中找到了靈感,我想對 @sozercan 的寶貴創造力表示感謝。此外,我要感謝@simongottschlag 在Azure OpenAI 分支上所做的工作,可在https://github.com/simongottschlag/azure-openai-gpt-slack-bot 上找到,該分支建立在https:// 奠定的基礎上。