OpenAI ChatGPT を利用したTerraform-ai
、インテリジェントで対話型のアシスタントを提供することで、Terraform HCL ファイルを適用するプロセスを簡素化します。
terraform-ai
OpenAI API キーまたは Azure OpenAI Service 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
タップに追加して次のようにインストールします。
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 です。
Terraform プロジェクト パスに設定できる--working-dir
フラグまたはWORKING_DIR
環境変数。
--exec-dir
フラグまたは Terraform 実行可能バイナリ ファイルに設定できるEXEC_DIR
環境変数。
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 に感謝の意を表したいと思います。さらに、https://github.com/simongottschlag/azure-openai-gpt-slack-bot で入手可能な Azure OpenAI フォークに関する @simongottschlag の取り組みに感謝したいと思います。このフォークは、https:// によって築かれた基盤の上に構築されています。 github.com/PullRequestInc/go-gpt3。