メインコンテンツまでスキップ

Manage Momento Caches with Terraform

Terraformは、インフラを安全かつ効率的に構築、変更、バージョン管理するためのInfrastructure-as-Codeツールです。

Momento Terraform Providerを使うと、TerraformプロジェクトでMomentoキャッシュを作成・削除することができます。

このチュートリアルでは、"example "というキャッシュを作成・削除する基本的なTerraformプロジェクトを説明します。

前提条件​

  • Terraformがインストールされている
  • Momento Consoleで作成できるMomento APIキー
  • You'll also need a Momento serverless endpoint, which you can choose from our list.

Example Terraform Project​

以下の内容でmain.tfファイルを作成します:

terraform {
required_providers {
momento = {
source = "momentohq/momento"
}
}
}

provider "momento" {}

resource "momento_cache" "example" {
name = "example"
}

MomentoのAPIキーを提供するには、providerブロックに次のように記述します:

provider "momento" {
v2_api_key = "your-api-key"
v2_api_endpoint = "your-api-endpoint"
}

あるいは、環境変数を設定することもできます:

export MOMENTO_API_KEY="your-api-key"
export MOMENTO_ENDPOINT="your-api-endpoint"

以下のコマンドを実行して、"example "という名前のMomento Cacheを作成し、削除します:

# TerraformレジストリからMomentoプロバイダをインストール

terraform init

# キャッシュの作成
terraform apply

# キャッシュの削除
terraform destroy