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:// 奠定的基础上。 github.com/PullRequestInc/go-gpt3。