Created
June 27, 2024 14:16
-
-
Save wicaksana/7c24f952f5fab0fea09456a3065a34c8 to your computer and use it in GitHub Desktop.
Terraform script for Neo4j Aura
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
terraform { | |
required_providers { | |
restapi = { | |
source = "mastercard/restapi" | |
version = "1.18.2" | |
} | |
} | |
required_version = ">= 0.12" | |
} | |
data "http" "aura_authentication" { | |
url = "https://api.neo4j.io/oauth/token" | |
method = "POST" | |
request_headers = { | |
"Authorization" = "Basic ${base64encode(join(":", [var.client_id, var.client_secret]))}" | |
"Content-Type" = "application/x-www-form-urlencoded" | |
} | |
request_body = "grant_type=client_credentials" | |
} | |
provider "restapi" { | |
alias = "aura_restapi" | |
uri = "https://api.neo4j.io/" | |
write_returns_object = true | |
debug = true | |
headers = { | |
"Authorization" = "Bearer ${jsondecode(data.http.aura_authentication.response_body).access_token}" | |
"Content-Type" = "application/json" | |
} | |
} | |
resource "restapi_object" "aura_instance" { | |
provider = restapi.aura_restapi | |
path = "/v1/instances" | |
id_attribute = "data/id" | |
create_method = "POST" | |
destroy_method = "DELETE" | |
destroy_path = "/v1/instances/{id}" | |
data = jsonencode({ | |
"version": var.aura_version, | |
"region": var.aura_region, | |
"memory": var.aura_memory, | |
"name": var.aura_name, | |
"type": var.aura_type, | |
"tenant_id": var.aura_tenant_id, | |
"cloud_provider": var.aura_cloud_provider | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment