├── CHANGELOG.md ├── CODEOWNERS ├── Dockerfile ├── terraform-registry-manifest.json ├── .gitignore ├── examples ├── provider │ └── provider.tf ├── resources │ ├── oasis_organization │ │ ├── resource.tf │ │ └── README.md │ ├── oasis_auditlog │ │ ├── resource.tf │ │ └── README.md │ ├── oasis_backup │ │ ├── README.md │ │ └── resource.tf │ ├── oasis_project │ │ ├── resource.tf │ │ └── README.md │ ├── oasis_notebook │ │ ├── README.md │ │ └── resource.tf │ ├── oasis_organization_invite │ │ ├── README.md │ │ └── resource.tf │ ├── oasis_iam_group │ │ ├── README.md │ │ └── resource.tf │ ├── oasis_iam_policy │ │ ├── README.md │ │ └── resource.tf │ ├── oasis_multi_region_backup │ │ ├── README.md │ │ └── resource.tf │ ├── oasis_private_endpoint │ │ ├── README.md │ │ └── resource.tf │ ├── oasis_certificate │ │ ├── resource.tf │ │ └── README.md │ ├── oasis_iam_role │ │ ├── resource.tf │ │ └── README.md │ ├── oasis_ipallowlist │ │ ├── resource.tf │ │ └── README.md │ ├── oasis_backup_policy │ │ ├── resource.tf │ │ └── README.md │ └── oasis_deployment │ │ ├── resource.tf │ │ └── README.md ├── data-sources │ ├── oasis_current_user │ │ ├── data-source.tf │ │ └── README.md │ ├── oasis_notebook_model │ │ ├── data-source.tf │ │ └── README.md │ ├── oasis_terms_and_conditions │ │ └── data-source.tf │ ├── oasis_project │ │ ├── data-source.tf │ │ └── README.md │ ├── oasis_organization │ │ ├── data-source.tf │ │ └── README.md │ ├── oasis_cloud_provider │ │ ├── data-source.tf │ │ └── README.md │ ├── oasis_backup │ │ ├── data-source.tf │ │ └── README.md │ ├── oasis_example_datasets │ │ ├── README.md │ │ └── data-source.tf │ └── oasis_region │ │ ├── data-source.tf │ │ └── README.md └── README.md ├── sign.sh ├── docs ├── guides │ ├── schema.md │ ├── setup.md │ └── getting-started.md ├── resources │ ├── example_dataset_installation.md │ ├── organization.md │ ├── auditlog.md │ ├── organization_invite.md │ ├── project.md │ ├── iam_group.md │ ├── iam_role.md │ ├── certificate.md │ ├── ipallowlist.md │ ├── iam_policy.md │ ├── backup.md │ ├── multi_region_backup.md │ └── notebook.md ├── data-sources │ ├── example_dataset_installations.md │ ├── current_user.md │ ├── terms_and_conditions.md │ ├── project.md │ ├── cloud_provider.md │ ├── notebook_model.md │ ├── backup.md │ ├── region.md │ ├── example_datasets.md │ └── organization.md └── index.md ├── templates ├── guides │ ├── schema.md.tmpl │ ├── setup.md.tmpl │ └── getting-started.md.tmpl └── index.md.tmpl ├── tools └── tools.go ├── internal ├── resource_unique_id_generator.go ├── data_source_current_user_test.go ├── provider_test.go ├── data_source_cloud_providers_test.go ├── data_source_oasis_example_dataset_test.go ├── data_source_backup_test.go ├── data_source_regions_test.go ├── resource_auditlog_test.go ├── data_source_oasis_example_dataset_installation_test.go ├── operational_test_resources.go ├── data_source_notebook_model_test.go ├── resource_iam_policy_test.go ├── resource_example_dataset_installation_test.go ├── data_source_oasis_terms_and_conditions_test.go ├── data_source_current_user.go ├── client.go ├── data_source_oasis_project_test.go ├── data_source_oasis_project.go ├── data_source_oasis_organization_test.go ├── data_source_oasis_terms_and_conditions.go ├── data_source_cloud_providers.go ├── resource_multi_region_backup_test.go ├── data_source_backup.go ├── resource_iam_group_test.go ├── resource_organization_invite_test.go └── data_source_regions.go ├── README.md ├── main.go ├── .vscode └── settings.json ├── Makefile └── .circleci └── config.yml /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | 2 | ## 0.1.0 Unreleased 3 | 4 | NOTES: 5 | 6 | -------------------------------------------------------------------------------- /CODEOWNERS: -------------------------------------------------------------------------------- 1 | # This team will own the entire repository 2 | * @arangodb-managed/developers 3 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine 2 | 3 | # Install required build packages 4 | RUN apk add -U sed 5 | -------------------------------------------------------------------------------- /terraform-registry-manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 1, 3 | "metadata": { 4 | "protocol_versions": ["5.0"] 5 | } 6 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | bin/ 3 | .*.swp 4 | .idea 5 | assets 6 | terraform.tfstate 7 | .terraform.lock.hcl 8 | *.backup 9 | ./*.tfstate 10 | .terraform/ 11 | terraform.tfplan 12 | *~ 13 | *.log -------------------------------------------------------------------------------- /examples/provider/provider.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 0.13.0" 3 | required_providers { 4 | oasis = { 5 | source = "arangodb-managed/oasis" 6 | version = ">=2.1.0" 7 | } 8 | } 9 | } 10 | 11 | provider "oasis" { 12 | api_key_id = "" // API Key ID generated in Oasis platform 13 | api_key_secret = "" // API Key Secret generated in Oasis platform 14 | } -------------------------------------------------------------------------------- /sign.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | gpg-agent --daemon --default-cache-ttl 7200 5 | # Multiline key in an envvar gets mangled. 6 | echo "$GPG_PRIVATE_KEY_BASE64" | base64 -d | gpg --import --batch --no-tty 7 | echo "hello world" > temp.txt 8 | gpg --detach-sig --yes -v --output=/dev/null --pinentry-mode loopback --passphrase "${PASSPHRASE}" temp.txt 9 | cd assets ; gpg --detach-sign ${PROJECT}_${VERSION}_SHA256SUMS 10 | rm ../temp.txt 11 | -------------------------------------------------------------------------------- /docs/guides/schema.md: -------------------------------------------------------------------------------- 1 | --- 2 | page_title: "Schema" 3 | description: |- 4 | Guide to generating the schema for the Terraform Provider 5 | --- 6 | 7 | # Schema 8 | 9 | In order to see every configuration option for this plugin, either browse the code for the data source 10 | you are interested in, or, once an Oasis Terraform configuration file is provided, take a look at the schema 11 | with the following command: 12 | 13 | ```bash 14 | terraform providers schema -json ./my_oasis_deployment | jq 15 | ``` 16 | 17 | Where `./my_oasis_deployment` is a folder which contains terraform configuration files. -------------------------------------------------------------------------------- /templates/guides/schema.md.tmpl: -------------------------------------------------------------------------------- 1 | --- 2 | page_title: "Schema" 3 | description: |- 4 | Guide to generating the schema for the Terraform Provider 5 | --- 6 | 7 | # Schema 8 | 9 | In order to see every configuration option for this plugin, either browse the code for the data source 10 | you are interested in, or, once an Oasis Terraform configuration file is provided, take a look at the schema 11 | with the following command: 12 | 13 | ```bash 14 | terraform providers schema -json ./my_oasis_deployment | jq 15 | ``` 16 | 17 | Where `./my_oasis_deployment` is a folder which contains terraform configuration files. -------------------------------------------------------------------------------- /examples/resources/oasis_organization/resource.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 0.13.0" 3 | required_providers { 4 | oasis = { 5 | source = "arangodb-managed/oasis" 6 | version = ">=2.1.0" 7 | } 8 | } 9 | } 10 | 11 | provider "oasis" { 12 | api_key_id = "" // API Key ID generated in Oasis platform 13 | api_key_secret = "" // API Key Secret generated in Oasis platform 14 | } 15 | 16 | // Terraform created organization 17 | resource "oasis_organization" "oasis_test_organization" { 18 | name = "Terraform Oasis Organization" 19 | description = "A test Oasis organization from Terraform Provider" 20 | } -------------------------------------------------------------------------------- /examples/resources/oasis_auditlog/resource.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 0.13.0" 3 | required_providers { 4 | oasis = { 5 | source = "arangodb-managed/oasis" 6 | version = ">=2.1.0" 7 | } 8 | } 9 | } 10 | 11 | provider "oasis" { 12 | api_key_id = "" // API Key ID generated in Oasis platform 13 | api_key_secret = "" // API Key Secret generated in Oasis platform 14 | } 15 | 16 | // Terraform created auditlog 17 | resource "oasis_auditlog" "oasis_test_auditlog" { 18 | name = "Terraform Oasis AuditLog" 19 | description = "A test Oasis auditlog from Terraform Provider" 20 | organization = "" // organization id 21 | } -------------------------------------------------------------------------------- /examples/data-sources/oasis_current_user/data-source.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 0.13.0" 3 | required_providers { 4 | oasis = { 5 | source = "arangodb-managed/oasis" 6 | version = ">=2.1.2" 7 | } 8 | } 9 | } 10 | 11 | provider "oasis" { 12 | api_key_id = "" // API Key ID generated in Oasis platform 13 | api_key_secret = "" // API Key Secret generated in Oasis platform 14 | } 15 | 16 | // Load in an Oasis Current User within an organization 17 | data "oasis_current_user" "oasis_test_current_user" {} 18 | 19 | // Output the data after it has been synced. 20 | output "datasets" { 21 | value = data.oasis_current_user.oasis_test_current_user 22 | } -------------------------------------------------------------------------------- /examples/data-sources/oasis_notebook_model/data-source.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 0.13.0" 3 | required_providers { 4 | oasis = { 5 | source = "arangodb-managed/oasis" 6 | version = ">=2.1.7" 7 | } 8 | } 9 | } 10 | 11 | provider "oasis" { 12 | api_key_id = "" // API Key ID generated in Oasis platform 13 | api_key_secret = "" // API Key Secret generated in Oasis platform 14 | } 15 | 16 | // Load in all the available datasets 17 | data "oasis_notebook_model" "models" { 18 | deployment_id = "" // deployment id (required) 19 | } 20 | 21 | // Output the data after it has been synced. 22 | output "datasets" { 23 | value = data.oasis_notebook_model.models 24 | } -------------------------------------------------------------------------------- /examples/data-sources/oasis_terms_and_conditions/data-source.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 0.13.0" 3 | required_providers { 4 | oasis = { 5 | source = "arangodb-managed/oasis" 6 | version = ">=2.1.0" 7 | } 8 | } 9 | } 10 | 11 | provider "oasis" { 12 | api_key_id = "" // API Key ID generated in Oasis platform 13 | api_key_secret = "" // API Key Secret generated in Oasis platform 14 | } 15 | 16 | // Load in Oasis terms and conditions 17 | data "oasis_terms_and_conditions" "test_terms_and_conditions" { 18 | } 19 | 20 | // Output the data after it has been synced. 21 | output "datasets" { 22 | value = data.oasis_terms_and_conditions.test_terms_and_conditions 23 | } -------------------------------------------------------------------------------- /examples/data-sources/oasis_project/data-source.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 0.13.0" 3 | required_providers { 4 | oasis = { 5 | source = "arangodb-managed/oasis" 6 | version = ">=2.1.0" 7 | } 8 | } 9 | } 10 | 11 | provider "oasis" { 12 | api_key_id = "" // API Key ID generated in Oasis platform 13 | api_key_secret = "" // API Key Secret generated in Oasis platform 14 | } 15 | 16 | // Load in an Oasis project within an organization 17 | data "oasis_project" "oasis_test_project" { 18 | id = "" // Provide your project ID here 19 | } 20 | 21 | // Output the data after it has been synced. 22 | output "datasets" { 23 | value = data.oasis_project.oasis_test_project 24 | } -------------------------------------------------------------------------------- /examples/data-sources/oasis_organization/data-source.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 0.13.0" 3 | required_providers { 4 | oasis = { 5 | source = "arangodb-managed/oasis" 6 | version = ">=2.1.0" 7 | } 8 | } 9 | } 10 | 11 | provider "oasis" { 12 | api_key_id = "" // API Key ID generated in Oasis platform 13 | api_key_secret = "" // API Key Secret generated in Oasis platform 14 | } 15 | 16 | // Load in an Oasis organization 17 | data "oasis_organization" "oasis_test_organization" { 18 | id = "" // Provide your Organization ID here 19 | } 20 | 21 | // Output the data after it has been synced. 22 | output "datasets" { 23 | value = data.oasis_organization.oasis_test_organization 24 | } -------------------------------------------------------------------------------- /examples/resources/oasis_backup/README.md: -------------------------------------------------------------------------------- 1 | # Example: Backup 2 | 3 | This example shows how to use the Terraform Oasis provider to create an Oasis backup inside a Deployment. 4 | 5 | ## Prerequisites 6 | 7 | *This example uses syntax elements specific to Terraform version 0.13+ (tested on Terraform version 1.1.4). 8 | It will not work out-of-the-box with Terraform 0.12.x and lower.* 9 | 10 | ## Environment variables 11 | Please refer to [Main README](../../README.md) file for all the environment variables you might need. 12 | 13 | ## Instructions on how to run: 14 | ``` 15 | terraform init 16 | terraform plan 17 | terraform apply 18 | ``` 19 | 20 | To remove the resources created run: 21 | ``` 22 | terraform destroy 23 | ``` -------------------------------------------------------------------------------- /examples/resources/oasis_project/resource.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 0.13.0" 3 | required_providers { 4 | oasis = { 5 | source = "arangodb-managed/oasis" 6 | version = ">=2.1.0" 7 | } 8 | } 9 | } 10 | 11 | provider "oasis" { 12 | api_key_id = "" // API Key ID generated in Oasis platform 13 | api_key_secret = "" // API Key Secret generated in Oasis platform 14 | organization = "" // Your Oasis organization where you want to create the resources 15 | } 16 | 17 | // Terraform created project 18 | resource "oasis_project" "oasis_test_project" { 19 | name = "Terraform Oasis Project" 20 | description = "A test Oasis project within an organization from the Terraform Provider" 21 | } -------------------------------------------------------------------------------- /examples/data-sources/oasis_cloud_provider/data-source.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 0.13.0" 3 | required_providers { 4 | oasis = { 5 | source = "arangodb-managed/oasis" 6 | version = ">=2.1.0" 7 | } 8 | } 9 | } 10 | 11 | provider "oasis" { 12 | api_key_id = "" // API Key ID generated in Oasis platform 13 | api_key_secret = "" // API Key Secret generated in Oasis platform 14 | } 15 | 16 | // Load in Oasis Cloud Providers 17 | data "oasis_cloud_provider" "test_oasis_cloud_providers" { 18 | organization = "" // Provide your Organization ID here 19 | } 20 | 21 | // Output the data after it has been synced. 22 | output "datasets" { 23 | value = data.oasis_cloud_provider.test_oasis_cloud_providers 24 | } -------------------------------------------------------------------------------- /examples/resources/oasis_auditlog/README.md: -------------------------------------------------------------------------------- 1 | # Example: Audit Log 2 | 3 | This example shows how to use the Terraform Oasis provider to manage Audit Log resources in Oasis. 4 | 5 | ## Prerequisites 6 | 7 | *This example uses syntax elements specific to Terraform version 0.13+ (tested on Terraform version 1.1.4). 8 | It will not work out-of-the-box with Terraform 0.12.x and lower (deprecated by Terraform).* 9 | 10 | ## Environment variables 11 | Please refer to [Main README](../../README.md) file for all the environment variables you might need. 12 | 13 | ## Instructions on how to run: 14 | ``` 15 | terraform init 16 | terraform plan 17 | terraform apply 18 | ``` 19 | 20 | To remove the resources created run: 21 | ``` 22 | terraform destroy 23 | ``` -------------------------------------------------------------------------------- /examples/resources/oasis_notebook/README.md: -------------------------------------------------------------------------------- 1 | # Example: Oasis Notebook 2 | 3 | This example shows how to use the Terraform Oasis provider to create an Oasis Jupyter Notebook inside a Deployment. 4 | 5 | ## Prerequisites 6 | 7 | _This example uses syntax elements specific to Terraform version 0.13+ (tested on Terraform version 1.1.4). 8 | It will not work out-of-the-box with Terraform 0.12.x and lower._ 9 | 10 | ## Environment variables 11 | 12 | Please refer to [Main README](../../README.md) file for all the environment variables you might need. 13 | 14 | ## Instructions on how to run: 15 | 16 | ``` 17 | terraform init 18 | terraform plan 19 | terraform apply 20 | ``` 21 | 22 | To remove the resources created run: 23 | 24 | ``` 25 | terraform destroy 26 | ``` 27 | -------------------------------------------------------------------------------- /examples/resources/oasis_organization_invite/README.md: -------------------------------------------------------------------------------- 1 | # Example: Organization Invite 2 | 3 | This example shows how to use the Terraform Oasis provider to create an Oasis Organization Invite. 4 | 5 | ## Prerequisites 6 | 7 | *This example uses syntax elements specific to Terraform version 0.13+ (tested on Terraform version 1.1.4). 8 | It will not work out-of-the-box with Terraform 0.12.x and lower (deprecated by Terraform).* 9 | 10 | ## Environment variables 11 | Please refer to [Main README](../../README.md) file for all the environment variables you might need. 12 | 13 | ## Instructions on how to run: 14 | ``` 15 | terraform init 16 | terraform plan 17 | terraform apply 18 | ``` 19 | 20 | To remove the resources created run: 21 | ``` 22 | terraform destroy 23 | ``` -------------------------------------------------------------------------------- /examples/resources/oasis_iam_group/README.md: -------------------------------------------------------------------------------- 1 | # Example: IAM Group 2 | 3 | This example shows how to use the Terraform Oasis provider to create an IAM Group for a specific organization within Oasis. 4 | 5 | ## Prerequisites 6 | 7 | *This example uses syntax elements specific to Terraform version 0.13+ (tested on Terraform version 1.1.4). 8 | It will not work out-of-the-box with Terraform 0.12.x and lower (deprecated by Terraform).* 9 | 10 | ## Environment variables 11 | Please refer to [Main README](../../README.md) file for all the environment variables you might need. 12 | 13 | ## Instructions on how to run: 14 | ``` 15 | terraform init 16 | terraform plan 17 | terraform apply 18 | ``` 19 | 20 | To remove the resources created run: 21 | ``` 22 | terraform destroy 23 | ``` -------------------------------------------------------------------------------- /examples/resources/oasis_iam_policy/README.md: -------------------------------------------------------------------------------- 1 | # Example: IAM Policy 2 | 3 | This example shows how to use the Terraform Oasis provider to create an IAM Policy for a specific resource within Oasis. 4 | 5 | ## Prerequisites 6 | 7 | *This example uses syntax elements specific to Terraform version 0.13+ (tested on Terraform version 1.1.4). 8 | It will not work out-of-the-box with Terraform 0.12.x and lower (deprecated by Terraform).* 9 | 10 | ## Environment variables 11 | Please refer to [Main README](../../README.md) file for all the environment variables you might need. 12 | 13 | ## Instructions on how to run: 14 | ``` 15 | terraform init 16 | terraform plan 17 | terraform apply 18 | ``` 19 | 20 | To remove the resources created run: 21 | ``` 22 | terraform destroy 23 | ``` -------------------------------------------------------------------------------- /examples/data-sources/oasis_backup/data-source.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 0.13.0" 3 | required_providers { 4 | oasis = { 5 | source = "arangodb-managed/oasis" 6 | version = ">=2.1.0" 7 | } 8 | } 9 | } 10 | 11 | provider "oasis" { 12 | api_key_id = "" // API Key ID generated in Oasis platform 13 | api_key_secret = "" // API Key Secret generated in Oasis platform 14 | organization = "" // Your Oasis organization where you want to create the resources 15 | } 16 | 17 | // Load in an Oasis backup of a deployment 18 | data "oasis_backup" "oasis_test_backup" { 19 | id = "" // Provide your Backup ID here 20 | } 21 | 22 | // Output the data after it has been synced. 23 | output "backup" { 24 | value = data.oasis_backup.oasis_test_backup 25 | } -------------------------------------------------------------------------------- /examples/data-sources/oasis_notebook_model/README.md: -------------------------------------------------------------------------------- 1 | # Example: Notebook Model Data Source 2 | 3 | This example shows how to use the Terraform Oasis provider to manage Notebook Model Data Source in Oasis. 4 | 5 | ## Prerequisites 6 | 7 | *This example uses syntax elements specific to Terraform version 0.13+ (tested on Terraform version 1.1.4). 8 | It will not work out-of-the-box with Terraform 0.12.x and lower (deprecated by Terraform).* 9 | 10 | ## Environment variables 11 | Please refer to [Main README](../../README.md) file for all the environment variables you might need. 12 | 13 | 14 | ## Instructions on how to run: 15 | ``` 16 | terraform init 17 | terraform plan 18 | terraform apply 19 | ``` 20 | 21 | To remove the resources created run: 22 | ``` 23 | terraform destroy 24 | ``` -------------------------------------------------------------------------------- /examples/resources/oasis_multi_region_backup/README.md: -------------------------------------------------------------------------------- 1 | # Example: Multi Region Backup 2 | 3 | This example shows how to use the Terraform Oasis provider to create an Oasis Multi Region backup inside a Deployment. 4 | 5 | ## Prerequisites 6 | 7 | _This example uses syntax elements specific to Terraform version 0.13+ (tested on Terraform version 1.1.4). 8 | It will not work out-of-the-box with Terraform 0.12.x and lower._ 9 | 10 | ## Environment variables 11 | 12 | Please refer to [Main README](../../README.md) file for all the environment variables you might need. 13 | 14 | ## Instructions on how to run: 15 | 16 | ``` 17 | terraform init 18 | terraform plan 19 | terraform apply 20 | ``` 21 | 22 | To remove the resources created run: 23 | 24 | ``` 25 | terraform destroy 26 | ``` 27 | -------------------------------------------------------------------------------- /examples/resources/oasis_private_endpoint/README.md: -------------------------------------------------------------------------------- 1 | # Example: Private Endpoint 2 | 3 | This example shows how to use the Terraform Oasis provider to create an Oasis Private Endpoint Service for a Deployment. 4 | 5 | ## Prerequisites 6 | 7 | *This example uses syntax elements specific to Terraform version 0.13+ (tested on Terraform version 1.1.4). 8 | It will not work out-of-the-box with Terraform 0.12.x and lower (deprecated by Terraform).* 9 | 10 | ## Environment variables 11 | Please refer to [Main README](../../README.md) file for all the environment variables you might need. 12 | 13 | ## Instructions on how to run: 14 | ``` 15 | terraform init 16 | terraform plan 17 | terraform apply 18 | ``` 19 | 20 | To remove the resources created run: 21 | ``` 22 | terraform destroy 23 | ``` -------------------------------------------------------------------------------- /examples/data-sources/oasis_example_datasets/README.md: -------------------------------------------------------------------------------- 1 | # Example: Example Datasets Data Source 2 | 3 | This example shows how to use the Terraform Oasis provider to manage Example Dataset Data Source in Oasis. 4 | 5 | ## Prerequisites 6 | 7 | *This example uses syntax elements specific to Terraform version 0.13+ (tested on Terraform version 1.1.4). 8 | It will not work out-of-the-box with Terraform 0.12.x and lower (deprecated by Terraform).* 9 | 10 | ## Environment variables 11 | Please refer to [Main README](../../README.md) file for all the environment variables you might need. 12 | 13 | 14 | ## Instructions on how to run: 15 | ``` 16 | terraform init 17 | terraform plan 18 | terraform apply 19 | ``` 20 | 21 | To remove the resources created run: 22 | ``` 23 | terraform destroy 24 | ``` -------------------------------------------------------------------------------- /examples/README.md: -------------------------------------------------------------------------------- 1 | # Examples 2 | 3 | This directory contains examples that are mostly used for documentation, but can also be run/tested manually via the Terraform CLI (see information in respective README files for each folder). 4 | 5 | The document generation tool looks for files in the following locations by default. All other *.tf files besides the ones mentioned below are ignored by the documentation tool. This is useful for creating examples that can run and/or ar testable even if some parts are not relevant for the documentation. 6 | 7 | * **provider/provider.tf** example file for the provider index page 8 | * **data-sources/<_full data source name_>/data-source.tf** example file for the named data source page 9 | * **resources/<_full resource name_>/resource.tf** example file for the named data source page 10 | -------------------------------------------------------------------------------- /examples/data-sources/oasis_region/data-source.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 0.13.0" 3 | required_providers { 4 | oasis = { 5 | source = "arangodb-managed/oasis" 6 | version = ">=2.1.0" 7 | } 8 | } 9 | } 10 | 11 | provider "oasis" { 12 | api_key_id = "" // API Key ID generated in Oasis platform 13 | api_key_secret = "" // API Key Secret generated in Oasis platform 14 | } 15 | 16 | // Load in Oasis Cloud Providers 17 | data "oasis_region" "test_oasis_region" { 18 | organization = "" // put your organization id here 19 | provider_id = "" // put one of the cloud provider ids here (can be fetched from cloud_provider data source) 20 | } 21 | 22 | // Output the data after it has been synced. 23 | output "datasets" { 24 | value = data.oasis_region.test_oasis_region 25 | } -------------------------------------------------------------------------------- /templates/index.md.tmpl: -------------------------------------------------------------------------------- 1 | --- 2 | layout: "" 3 | page_title: "Provider: Oasis" 4 | description: |- 5 | The Oasis Terraform provider allows full lifecycle management of ArangoGraph Insights Platform (formerly called Oasis) resources. 6 | --- 7 | 8 | # Oasis Provider 9 | 10 | The Terraform Oasis provider is a plugin for Terraform that allows for the full lifecycle management of ArangoGraph Insights Platform resources. 11 | 12 | Api keys can be generated and viewed under the user's dashboard view on the API Keys tab. 13 | On a logged in view, navigate to [API Keys](https://cloud.arangodb.com/dashboard/user/api-keys) and hit the button 14 | labeled `New API key`. This will generate a set of keys which can be used with ArangoDB's public API. 15 | 16 | ## Example Usage 17 | 18 | {{tffile "examples/provider/provider.tf"}} 19 | 20 | {{ .SchemaMarkdown | trimspace }} -------------------------------------------------------------------------------- /examples/resources/oasis_organization_invite/resource.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 0.13.0" 3 | required_providers { 4 | oasis = { 5 | source = "arangodb-managed/oasis" 6 | version = ">=2.1.0" 7 | } 8 | } 9 | } 10 | 11 | provider "oasis" { 12 | api_key_id = "" // API Key ID generated in Oasis platform 13 | api_key_secret = "" // API Key Secret generated in Oasis platform 14 | } 15 | 16 | // Terraform created organization 17 | resource "oasis_organization" "oasis_test_organization" { 18 | name = "Terraform Oasis Organization" 19 | description = "A test Oasis organization from Terraform Provider" 20 | } 21 | 22 | // Terraform created organization invite 23 | resource "oasis_organization_invite" "oasis_test_organization_invite" { 24 | organization = oasis_organization.oasis_test_organization.id 25 | email = "test.managedservice@arangodb.com" 26 | } -------------------------------------------------------------------------------- /examples/data-sources/oasis_example_datasets/data-source.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 0.13.0" 3 | required_providers { 4 | oasis = { 5 | source = "arangodb-managed/oasis" 6 | version = ">=2.1.0" 7 | } 8 | } 9 | } 10 | 11 | provider "oasis" { 12 | api_key_id = "" // API Key ID generated in Oasis platform 13 | api_key_secret = "" // API Key Secret generated in Oasis platform 14 | } 15 | 16 | // Load in all the available datasets 17 | data "oasis_example_datasets" "datasets" { 18 | // optionally define an organization id to list example datasets for which are 19 | // only available to that organization. If you do not have access to said organization 20 | // this will just be ignored. 21 | organization = "" // organization id 22 | } 23 | 24 | // Output the data after it has been synced. 25 | output "datasets" { 26 | value = data.oasis_example_datasets.datasets 27 | } -------------------------------------------------------------------------------- /examples/data-sources/oasis_current_user/README.md: -------------------------------------------------------------------------------- 1 | # Example: Current User Data Source 2 | 3 | This example shows how to use the Terraform Oasis provider to manage Current User Data Source in Oasis. 4 | 5 | ## Prerequisites 6 | 7 | *This example uses syntax elements specific to Terraform version 0.13+ (tested on Terraform version 1.1.4). 8 | It will not work out-of-the-box with Terraform 0.12.x and lower (deprecated by Terraform).* 9 | 10 | ## Environment variables 11 | Please refer to [Main README](../../README.md) file for all the environment variables you might need. 12 | 13 | ## Example output 14 | ``` 15 | datasets = { 16 | "email" = "test@arangodb.com" 17 | "id" = "google-oauth2|781471512049238536110" 18 | "name" = "Test Arango" 19 | } 20 | ``` 21 | 22 | ## Instructions on how to run: 23 | ``` 24 | terraform init 25 | terraform plan 26 | terraform apply 27 | ``` 28 | 29 | To remove the resources created run: 30 | ``` 31 | terraform destroy 32 | ``` -------------------------------------------------------------------------------- /tools/tools.go: -------------------------------------------------------------------------------- 1 | // 2 | // DISCLAIMER 3 | // 4 | // Copyright 2022 ArangoDB GmbH, Cologne, Germany 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | // Copyright holder is ArangoDB GmbH, Cologne, Germany 19 | // 20 | 21 | //go:build tools 22 | // +build tools 23 | 24 | package tools 25 | 26 | import ( 27 | // document generation 28 | _ "github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs" 29 | ) 30 | -------------------------------------------------------------------------------- /examples/resources/oasis_iam_group/resource.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 0.13.0" 3 | required_providers { 4 | oasis = { 5 | source = "arangodb-managed/oasis" 6 | version = ">=2.1.0" 7 | } 8 | } 9 | } 10 | 11 | provider "oasis" { 12 | api_key_id = "" // API Key ID generated in Oasis platform 13 | api_key_secret = "" // API Key Secret generated in Oasis platform 14 | } 15 | 16 | // Terraform created organization 17 | resource "oasis_organization" "oasis_test_organization" { 18 | name = "Terraform Oasis Organization" 19 | description = "A test Oasis organization from Terraform Provider" 20 | } 21 | 22 | // Terraform created IAM Group. This resource uses the computed ID value of the 23 | // previously defined organization resource. 24 | resource "oasis_iam_group" "my_iam_group" { 25 | name = "Terraform IAM Group" 26 | description = "IAM Group created by Terraform" 27 | organization = oasis_organization.oasis_test_organization.id 28 | } -------------------------------------------------------------------------------- /examples/data-sources/oasis_project/README.md: -------------------------------------------------------------------------------- 1 | # Example: Project Data Source 2 | 3 | This example shows how to use the Terraform Oasis provider to manage Project Data Source in Oasis. 4 | 5 | ## Prerequisites 6 | 7 | *This example uses syntax elements specific to Terraform version 0.13+ (tested on Terraform version 1.1.4). 8 | It will not work out-of-the-box with Terraform 0.12.x and lower (deprecated by Terraform).* 9 | 10 | ## Environment variables 11 | Please refer to [Main README](../../README.md) file for all the environment variables you might need. 12 | 13 | ## Example output 14 | ``` 15 | datasets = { 16 | "created_at" = "2022-05-26T09:29:32.357Z" 17 | "description" = "" 18 | "id" = "144514639" 19 | "name" = "testProj" 20 | "url" = "/Organization/144496467/Project/144514639" 21 | } 22 | ``` 23 | 24 | ## Instructions on how to run: 25 | ``` 26 | terraform init 27 | terraform plan 28 | terraform apply 29 | ``` 30 | 31 | To remove the resources created run: 32 | ``` 33 | terraform destroy 34 | ``` -------------------------------------------------------------------------------- /examples/resources/oasis_certificate/resource.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 0.13.0" 3 | required_providers { 4 | oasis = { 5 | source = "arangodb-managed/oasis" 6 | version = ">=2.1.0" 7 | } 8 | } 9 | } 10 | 11 | provider "oasis" { 12 | api_key_id = "" // API Key ID generated in Oasis platform 13 | api_key_secret = "" // API Key Secret generated in Oasis platform 14 | organization = "" // Your Oasis organization where you want to create the resources 15 | } 16 | 17 | // Terraform created project. 18 | resource "oasis_project" "oasis_test_project" { 19 | name = "Terraform Oasis Project" 20 | description = "A test Oasis project within an organization from the Terraform Provider" 21 | } 22 | 23 | // Oasis certificate. This certificate's computed ID will be used in the project above. 24 | resource "oasis_certificate" "my_oasis_cert" { 25 | name = "Terraform certificate" 26 | description = "Certificate description." 27 | project = oasis_project.oasis_test_project.id 28 | } 29 | -------------------------------------------------------------------------------- /examples/resources/oasis_iam_role/resource.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 0.13.0" 3 | required_providers { 4 | oasis = { 5 | source = "arangodb-managed/oasis" 6 | version = ">=2.1.0" 7 | } 8 | } 9 | } 10 | 11 | provider "oasis" { 12 | api_key_id = "" // API Key ID generated in Oasis platform 13 | api_key_secret = "" // API Key Secret generated in Oasis platform 14 | } 15 | 16 | // Terraform created organization 17 | resource "oasis_organization" "oasis_test_organization" { 18 | name = "Terraform Oasis Organization" 19 | description = "A test Oasis organization from Terraform Provider" 20 | } 21 | 22 | // Terraform created IAM Role. This resource uses the computed ID value of the 23 | // previously defined organization resource. 24 | resource "oasis_iam_role" "my_iam_role" { 25 | name = "Terraform IAM Role" 26 | description = "IAM Role created by Terraform" 27 | organization = oasis_organization.oasis_test_organization.id 28 | permissions = ["audit.auditlog.list"] // optional 29 | } -------------------------------------------------------------------------------- /examples/resources/oasis_ipallowlist/resource.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 0.13.0" 3 | required_providers { 4 | oasis = { 5 | source = "arangodb-managed/oasis" 6 | version = ">=2.1.0" 7 | } 8 | } 9 | } 10 | 11 | provider "oasis" { 12 | api_key_id = "" // API Key ID generated in Oasis platform 13 | api_key_secret = "" // API Key Secret generated in Oasis platform 14 | organization = "" // Your Oasis organization where you want to create the resources 15 | } 16 | 17 | // Terraform created project. 18 | resource "oasis_project" "my_project" { 19 | name = "Terraform Oasis Project" 20 | description = "A test Oasis project within an organization from the Terraform Provider" 21 | } 22 | 23 | // Terraform created ip allowlist. This resource uses the computed ID value of the 24 | // previously defined project resource. 25 | resource "oasis_ipallowlist" "my_iplist" { 26 | name = "Terraform IP Allowlist" 27 | description = "IP Allowlist description" 28 | cidr_ranges = ["1.2.3.4/32", "111.11.0.0/16"] 29 | project = oasis_project.my_project.id 30 | } -------------------------------------------------------------------------------- /docs/resources/example_dataset_installation.md: -------------------------------------------------------------------------------- 1 | --- 2 | # generated by https://github.com/hashicorp/terraform-plugin-docs 3 | page_title: "oasis_example_dataset_installation Resource - terraform-provider-oasis" 4 | subcategory: "" 5 | description: |- 6 | Oasis Example Dataset Installation Resource 7 | --- 8 | 9 | # oasis_example_dataset_installation (Resource) 10 | 11 | Oasis Example Dataset Installation Resource 12 | 13 | 14 | 15 | 16 | ## Schema 17 | 18 | ### Required 19 | 20 | - `deployment_id` (String) Oasis Example Dataset Resource Deployment ID field 21 | - `example_dataset_id` (String) Oasis Example Dataset Resource Example Dataset ID field 22 | 23 | ### Read-Only 24 | 25 | - `created_at` (String) Oasis Example Dataset Resource Example Dataset Created At field 26 | - `id` (String) The ID of this resource. 27 | - `status` (List of Object) Oasis Example Dataset Resource Example Dataset Status field (see [below for nested schema](#nestedatt--status)) 28 | 29 | 30 | ### Nested Schema for `status` 31 | 32 | Read-Only: 33 | 34 | - `database_name` (String) 35 | - `is_available` (Boolean) 36 | - `is_failed` (Boolean) 37 | - `state` (String) 38 | 39 | 40 | -------------------------------------------------------------------------------- /examples/data-sources/oasis_cloud_provider/README.md: -------------------------------------------------------------------------------- 1 | # Example: Cloud Providers Data Source 2 | 3 | This example shows how to use the Terraform Oasis provider to manage Cloud Provider Data Source in Oasis. The data source will give a list of Cloud Providers supported by Oasis. 4 | 5 | ## Prerequisites 6 | 7 | *This example uses syntax elements specific to Terraform version 0.13+ (tested on Terraform version 1.1.4). 8 | It will not work out-of-the-box with Terraform 0.12.x and lower (deprecated by Terraform).* 9 | 10 | ## Environment variables 11 | Please refer to [Main README](../../README.md) file for all the environment variables you might need. 12 | 13 | ## Example output: 14 | ``` 15 | datasets = { 16 | "organization" = "_support" 17 | "providers" = tolist([ 18 | { 19 | "id" = "aks" 20 | "name" = "Microsoft Azure" 21 | }, 22 | { 23 | "id" = "aws" 24 | "name" = "Amazon Web Services" 25 | }, 26 | { 27 | "id" = "gcp" 28 | "name" = "Google Cloud Platform" 29 | }, 30 | ]) 31 | } 32 | ``` 33 | 34 | ## Instructions on how to run: 35 | ``` 36 | terraform init 37 | terraform plan 38 | terraform apply 39 | ``` 40 | 41 | To remove the resources created run: 42 | ``` 43 | terraform destroy 44 | ``` -------------------------------------------------------------------------------- /docs/data-sources/example_dataset_installations.md: -------------------------------------------------------------------------------- 1 | --- 2 | # generated by https://github.com/hashicorp/terraform-plugin-docs 3 | page_title: "oasis_example_dataset_installations Data Source - terraform-provider-oasis" 4 | subcategory: "" 5 | description: |- 6 | Example DataSet Installation Data Source 7 | --- 8 | 9 | # oasis_example_dataset_installations (Data Source) 10 | 11 | Example DataSet Installation Data Source 12 | 13 | 14 | 15 | 16 | ## Schema 17 | 18 | ### Required 19 | 20 | - `deployment_id` (String) Example Dataset Data Source Deployment ID field 21 | 22 | ### Read-Only 23 | 24 | - `id` (String) The ID of this resource. 25 | - `items` (List of Object) (see [below for nested schema](#nestedatt--items)) 26 | 27 | 28 | ### Nested Schema for `items` 29 | 30 | Read-Only: 31 | 32 | - `created_at` (String) 33 | - `example_dataset_id` (String) 34 | - `status` (List of Object) (see [below for nested schema](#nestedobjatt--items--status)) 35 | 36 | 37 | ### Nested Schema for `items.status` 38 | 39 | Read-Only: 40 | 41 | - `database_name` (String) 42 | - `is_available` (Boolean) 43 | - `is_failed` (Boolean) 44 | - `state` (String) 45 | 46 | 47 | -------------------------------------------------------------------------------- /examples/data-sources/oasis_backup/README.md: -------------------------------------------------------------------------------- 1 | # Example: Backup Data Source 2 | 3 | This example shows how to use the Terraform Oasis provider to manage Backup Data Source in Oasis. 4 | 5 | ## Prerequisites 6 | 7 | *This example uses syntax elements specific to Terraform version 0.13+ (tested on Terraform version 1.1.4). 8 | It will not work out-of-the-box with Terraform 0.12.x and lower (deprecated by Terraform).* 9 | 10 | ## Environment variables 11 | Please refer to [Main README](../../README.md) file for all the environment variables you might need. 12 | 13 | ## Example output: 14 | ``` 15 | backup = { 16 | "backup_policy_id" = "0syap73n4gqpbikn6oo5" 17 | "created_at" = "2022-05-26T08:00:10.835Z" 18 | "deployment_id" = "bszpx3zjnquchcwvil22" 19 | "description" = "This backup has been created by backup policy (scheduled backup): Default backup policy" 20 | "id" = "y2pcdn45pvrm8gld8zmv" 21 | "name" = "Created 2022-05-26T08:00:07Z" 22 | "url" = "/Organization/_support/Project/76253721/Deployment/bszpx3zjnquchcwvil22/Backup/y2pcdn45pvrm8gld8zmv" 23 | } 24 | ``` 25 | 26 | ## Instructions on how to run: 27 | ``` 28 | terraform init 29 | terraform plan 30 | terraform apply 31 | ``` 32 | 33 | To remove the resources created run: 34 | ``` 35 | terraform destroy 36 | ``` -------------------------------------------------------------------------------- /examples/data-sources/oasis_organization/README.md: -------------------------------------------------------------------------------- 1 | # Example: Organization Data Source 2 | 3 | This example shows how to use the Terraform Oasis provider to manage Organization Data Source in Oasis. 4 | 5 | ## Prerequisites 6 | 7 | *This example uses syntax elements specific to Terraform version 0.13+ (tested on Terraform version 1.1.4). 8 | It will not work out-of-the-box with Terraform 0.12.x and lower (deprecated by Terraform).* 9 | 10 | ## Environment variables 11 | Please refer to [Main README](../../README.md) file for all the environment variables you might need. 12 | 13 | ## Example output 14 | ``` 15 | datasets = { 16 | "created_at" = "2022-05-26T09:17:51.608Z" 17 | "description" = "" 18 | "id" = "144496467" 19 | "is_deleted" = tobool(null) 20 | "name" = "test" 21 | "tier" = toset([ 22 | { 23 | "has_backup_uploads" = false 24 | "has_support_plans" = true 25 | "id" = "free" 26 | "name" = "Free to try" 27 | "requires_terms_and_conditions" = true 28 | }, 29 | ]) 30 | "url" = "/Organization/144496467" 31 | } 32 | ``` 33 | 34 | ## Instructions on how to run: 35 | ``` 36 | terraform init 37 | terraform plan 38 | terraform apply 39 | ``` 40 | 41 | To remove the resources created run: 42 | ``` 43 | terraform destroy 44 | ``` -------------------------------------------------------------------------------- /internal/resource_unique_id_generator.go: -------------------------------------------------------------------------------- 1 | // 2 | // DISCLAIMER 3 | // 4 | // Copyright 2020-2022 ArangoDB GmbH, Cologne, Germany 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | // Copyright holder is ArangoDB GmbH, Cologne, Germany 19 | // 20 | 21 | package provider 22 | 23 | import ( 24 | "fmt" 25 | "strings" 26 | "sync/atomic" 27 | "time" 28 | ) 29 | 30 | // counter is keeping track of the generated resources in an atomic way. 31 | // This will result in unique ids even with multiple terraform calls. 32 | var counter uint64 33 | 34 | func uniqueResourceID(prefix string) string { 35 | ts := strings.ReplaceAll(time.Now().Format("200601020405.000000"), ".", "") 36 | atomic.AddUint64(&counter, 1) 37 | return fmt.Sprintf("%s%s%05d", prefix, ts, counter) 38 | } 39 | -------------------------------------------------------------------------------- /docs/data-sources/current_user.md: -------------------------------------------------------------------------------- 1 | --- 2 | # generated by https://github.com/hashicorp/terraform-plugin-docs 3 | page_title: "oasis_current_user Data Source - terraform-provider-oasis" 4 | subcategory: "" 5 | description: |- 6 | Oasis Current User Data Source 7 | --- 8 | 9 | # oasis_current_user (Data Source) 10 | 11 | Oasis Current User Data Source 12 | 13 | ## Example Usage 14 | 15 | ```terraform 16 | terraform { 17 | required_version = ">= 0.13.0" 18 | required_providers { 19 | oasis = { 20 | source = "arangodb-managed/oasis" 21 | version = ">=2.1.2" 22 | } 23 | } 24 | } 25 | 26 | provider "oasis" { 27 | api_key_id = "" // API Key ID generated in Oasis platform 28 | api_key_secret = "" // API Key Secret generated in Oasis platform 29 | } 30 | 31 | // Load in an Oasis Current User within an organization 32 | data "oasis_current_user" "oasis_test_current_user" {} 33 | 34 | // Output the data after it has been synced. 35 | output "datasets" { 36 | value = data.oasis_current_user.oasis_test_current_user 37 | } 38 | ``` 39 | 40 | 41 | ## Schema 42 | 43 | ### Optional 44 | 45 | - `email` (String) Current User Data Source Email field 46 | - `id` (String) Current User Data Source User ID field 47 | - `name` (String) Current User Data Source Name field 48 | 49 | 50 | -------------------------------------------------------------------------------- /examples/resources/oasis_iam_role/README.md: -------------------------------------------------------------------------------- 1 | # Example: IAM Role 2 | 3 | This example shows how to use the Terraform Oasis provider to create an IAM Role for a specific organization within Oasis. 4 | 5 | ## Prerequisites 6 | 7 | *This example uses syntax elements specific to Terraform version 0.13+ (tested on Terraform version 1.1.4). 8 | It will not work out-of-the-box with Terraform 0.12.x and lower (deprecated by Terraform).* 9 | 10 | ## Environment variables 11 | Please refer to [Main README](../../README.md) file for all the environment variables you might need. 12 | 13 | ## Instructions on how to run: 14 | ``` 15 | terraform init 16 | terraform plan 17 | terraform apply 18 | ``` 19 | 20 | __Note__: When creating a role please make sure to look in Oasis dashboard or use [oasisctl](https://github.com/arangodb-managed/oasisctl) to get the list of allowed permissions, if you specify a permission that is not allowed, you will not be able to create the role. Note that permissions is an optional field, it can be updated later. 21 | 22 | To use `oasisctl` to get the list of permissions you can run: 23 | ``` 24 | oasisctl list permissions 25 | ``` 26 | This will output a list of permissions you can use for the `permissions` field when creating an `oasis_iam_role` resource. 27 | 28 | To remove the resources created run: 29 | ``` 30 | terraform destroy 31 | ``` -------------------------------------------------------------------------------- /docs/resources/organization.md: -------------------------------------------------------------------------------- 1 | --- 2 | # generated by https://github.com/hashicorp/terraform-plugin-docs 3 | page_title: "oasis_organization Resource - terraform-provider-oasis" 4 | subcategory: "" 5 | description: |- 6 | Oasis Organization Resource 7 | --- 8 | 9 | # oasis_organization (Resource) 10 | 11 | Oasis Organization Resource 12 | 13 | ## Example Usage 14 | 15 | ```terraform 16 | terraform { 17 | required_version = ">= 0.13.0" 18 | required_providers { 19 | oasis = { 20 | source = "arangodb-managed/oasis" 21 | version = ">=2.1.0" 22 | } 23 | } 24 | } 25 | 26 | provider "oasis" { 27 | api_key_id = "" // API Key ID generated in Oasis platform 28 | api_key_secret = "" // API Key Secret generated in Oasis platform 29 | } 30 | 31 | // Terraform created organization 32 | resource "oasis_organization" "oasis_test_organization" { 33 | name = "Terraform Oasis Organization" 34 | description = "A test Oasis organization from Terraform Provider" 35 | } 36 | ``` 37 | 38 | 39 | ## Schema 40 | 41 | ### Required 42 | 43 | - `name` (String) Organization Resource Organization Name field 44 | 45 | ### Optional 46 | 47 | - `description` (String) Organization Resource Organization Description field 48 | - `locked` (Boolean) Organization Resource Organization Lock field 49 | 50 | ### Read-Only 51 | 52 | - `id` (String) The ID of this resource. 53 | 54 | 55 | -------------------------------------------------------------------------------- /docs/resources/auditlog.md: -------------------------------------------------------------------------------- 1 | --- 2 | # generated by https://github.com/hashicorp/terraform-plugin-docs 3 | page_title: "oasis_auditlog Resource - terraform-provider-oasis" 4 | subcategory: "" 5 | description: |- 6 | Oasis Audit Log Resource 7 | --- 8 | 9 | # oasis_auditlog (Resource) 10 | 11 | Oasis Audit Log Resource 12 | 13 | ## Example Usage 14 | 15 | ```terraform 16 | terraform { 17 | required_version = ">= 0.13.0" 18 | required_providers { 19 | oasis = { 20 | source = "arangodb-managed/oasis" 21 | version = ">=2.1.0" 22 | } 23 | } 24 | } 25 | 26 | provider "oasis" { 27 | api_key_id = "" // API Key ID generated in Oasis platform 28 | api_key_secret = "" // API Key Secret generated in Oasis platform 29 | } 30 | 31 | // Terraform created auditlog 32 | resource "oasis_auditlog" "oasis_test_auditlog" { 33 | name = "Terraform Oasis AuditLog" 34 | description = "A test Oasis auditlog from Terraform Provider" 35 | organization = "" // organization id 36 | } 37 | ``` 38 | 39 | 40 | ## Schema 41 | 42 | ### Required 43 | 44 | - `name` (String) Audit Log Resource Audit Log Name field 45 | 46 | ### Optional 47 | 48 | - `description` (String) Audit Log Resource Audit Log Description field 49 | - `is_default` (Boolean) Audit Log Resource Audit Log Is Default field 50 | - `organization` (String) Audit Log Resource Organization ID field 51 | 52 | ### Read-Only 53 | 54 | - `id` (String) The ID of this resource. 55 | 56 | 57 | -------------------------------------------------------------------------------- /docs/data-sources/terms_and_conditions.md: -------------------------------------------------------------------------------- 1 | --- 2 | # generated by https://github.com/hashicorp/terraform-plugin-docs 3 | page_title: "oasis_terms_and_conditions Data Source - terraform-provider-oasis" 4 | subcategory: "" 5 | description: |- 6 | Terms and Conditions Data Source 7 | --- 8 | 9 | # oasis_terms_and_conditions (Data Source) 10 | 11 | Terms and Conditions Data Source 12 | 13 | ## Example Usage 14 | 15 | ```terraform 16 | terraform { 17 | required_version = ">= 0.13.0" 18 | required_providers { 19 | oasis = { 20 | source = "arangodb-managed/oasis" 21 | version = ">=2.1.0" 22 | } 23 | } 24 | } 25 | 26 | provider "oasis" { 27 | api_key_id = "" // API Key ID generated in Oasis platform 28 | api_key_secret = "" // API Key Secret generated in Oasis platform 29 | } 30 | 31 | // Load in Oasis terms and conditions 32 | data "oasis_terms_and_conditions" "test_terms_and_conditions" { 33 | } 34 | 35 | // Output the data after it has been synced. 36 | output "datasets" { 37 | value = data.oasis_terms_and_conditions.test_terms_and_conditions 38 | } 39 | ``` 40 | 41 | 42 | ## Schema 43 | 44 | ### Optional 45 | 46 | - `id` (String) Terms and Conditions Data Source ID field 47 | - `organization` (String) Terms and Conditions Data Source Organization field 48 | 49 | ### Read-Only 50 | 51 | - `content` (String) Terms and Conditions Data Source Content field 52 | - `created_at` (String) Terms and Conditions Data Source Created At field 53 | 54 | 55 | -------------------------------------------------------------------------------- /internal/data_source_current_user_test.go: -------------------------------------------------------------------------------- 1 | // 2 | // DISCLAIMER 3 | // 4 | // Copyright 2022 ArangoDB GmbH, Cologne, Germany 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | // Copyright holder is ArangoDB GmbH, Cologne, Germany 19 | // 20 | 21 | package provider 22 | 23 | import ( 24 | "fmt" 25 | "testing" 26 | 27 | "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" 28 | "github.com/stretchr/testify/assert" 29 | 30 | iam "github.com/arangodb-managed/apis/iam/v1" 31 | ) 32 | 33 | func TestFlattenCurrentUserDataSource(t *testing.T) { 34 | testUserId := fmt.Sprintf("-oauth2|%s", acctest.RandString(21)) 35 | user := iam.User{ 36 | Id: testUserId, 37 | Name: "Test", 38 | Email: "test@arangodb.com", 39 | } 40 | expected := map[string]interface{}{ 41 | userIdFieldName: testUserId, 42 | userNameFieldName: "Test", 43 | userEmailFieldName: "test@arangodb.com", 44 | } 45 | got := flattenCurrentUserObject(&user) 46 | assert.Equal(t, expected, got) 47 | } 48 | -------------------------------------------------------------------------------- /docs/data-sources/project.md: -------------------------------------------------------------------------------- 1 | --- 2 | # generated by https://github.com/hashicorp/terraform-plugin-docs 3 | page_title: "oasis_project Data Source - terraform-provider-oasis" 4 | subcategory: "" 5 | description: |- 6 | Oasis Project Data Source 7 | --- 8 | 9 | # oasis_project (Data Source) 10 | 11 | Oasis Project Data Source 12 | 13 | ## Example Usage 14 | 15 | ```terraform 16 | terraform { 17 | required_version = ">= 0.13.0" 18 | required_providers { 19 | oasis = { 20 | source = "arangodb-managed/oasis" 21 | version = ">=2.1.0" 22 | } 23 | } 24 | } 25 | 26 | provider "oasis" { 27 | api_key_id = "" // API Key ID generated in Oasis platform 28 | api_key_secret = "" // API Key Secret generated in Oasis platform 29 | } 30 | 31 | // Load in an Oasis project within an organization 32 | data "oasis_project" "oasis_test_project" { 33 | id = "" // Provide your project ID here 34 | } 35 | 36 | // Output the data after it has been synced. 37 | output "datasets" { 38 | value = data.oasis_project.oasis_test_project 39 | } 40 | ``` 41 | 42 | 43 | ## Schema 44 | 45 | ### Required 46 | 47 | - `id` (String) Project Data Source Project ID field 48 | 49 | ### Optional 50 | 51 | - `description` (String) Project Data Source Project Description field 52 | - `name` (String) Project Data Source Project Name field 53 | 54 | ### Read-Only 55 | 56 | - `created_at` (String) Project Data Source Project Created At field 57 | - `url` (String) Project Data Source Project URL field 58 | 59 | 60 | -------------------------------------------------------------------------------- /docs/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: "" 3 | page_title: "Provider: Oasis" 4 | description: |- 5 | The Oasis Terraform provider allows full lifecycle management of ArangoGraph Insights Platform (formerly called Oasis) resources. 6 | --- 7 | 8 | # Oasis Provider 9 | 10 | The Terraform Oasis provider is a plugin for Terraform that allows for the full lifecycle management of ArangoGraph Insights Platform resources. 11 | 12 | Api keys can be generated and viewed under the user's dashboard view on the API Keys tab. 13 | On a logged in view, navigate to [API Keys](https://cloud.arangodb.com/dashboard/user/api-keys) and hit the button 14 | labeled `New API key`. This will generate a set of keys which can be used with ArangoDB's public API. 15 | 16 | ## Example Usage 17 | 18 | ```terraform 19 | terraform { 20 | required_version = ">= 0.13.0" 21 | required_providers { 22 | oasis = { 23 | source = "arangodb-managed/oasis" 24 | version = ">=2.1.0" 25 | } 26 | } 27 | } 28 | 29 | provider "oasis" { 30 | api_key_id = "" // API Key ID generated in Oasis platform 31 | api_key_secret = "" // API Key Secret generated in Oasis platform 32 | } 33 | ``` 34 | 35 | 36 | ## Schema 37 | 38 | ### Optional 39 | 40 | - `api_key_id` (String) OASIS API KEY ID 41 | - `api_key_secret` (String) OASIS API KEY SECRET 42 | - `api_port_suffix` (String) OASIS API PORT SUFFIX 43 | - `oasis_endpoint` (String) OASIS API ENDPOINT 44 | - `organization` (String) Default Oasis Organization 45 | - `project` (String) Default Oasis Project -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ArangoDB Oasis Terraform Provider [![GitHub tag (latest SemVer)](https://img.shields.io/github/v/tag/arangodb-managed/terraform-provider-oasis?label=release)](https://github.com/arangodb-managed/terraform-provider-oasis/releases) [![CircleCI](https://dl.circleci.com/status-badge/img/gh/arangodb-managed/terraform-provider-oasis/tree/master.svg?style=shield)](https://dl.circleci.com/status-badge/redirect/gh/arangodb-managed/terraform-provider-oasis/tree/master) 2 | 3 | 4 | ArangoGraph Insights Platform 5 | 6 | The Terraform Oasis provider is a plugin for Terraform that allows for the full lifecycle management of ArangoGraph Insights Platform's (formerly called Oasis) resources. 7 | 8 | ## Project status: GA 9 | 10 | ## Maintainers 11 | 12 | This provider plugin is maintained by the team at [ArangoDB](https://www.arangodb.com/). 13 | 14 | ## Installation 15 | 16 | Please follow the [Getting Started](https://registry.terraform.io/providers/arangodb-managed/oasis/latest/docs/guides/getting-started) guide in the official documentation page. 17 | 18 | ## Requirements 19 | 20 | - [Terraform](https://www.terraform.io/downloads.html) 0.13+ (recommend 1.1.4+) 21 | - [Go](https://golang.org/doc/install) 1.17 (to build the provider plugin) 22 | 23 | ## Examples 24 | 25 | For further examples, please take a look under [Examples](./examples) folder. 26 | 27 | ## Links 28 | 29 | - Website: https://cloud.arangodb.com/ 30 | - Slack: https://slack.arangodb.com/ 31 | 32 | -------------------------------------------------------------------------------- /examples/resources/oasis_certificate/README.md: -------------------------------------------------------------------------------- 1 | # Example: Certificate 2 | 3 | This example shows how to use the Terraform Oasis provider to create a Certificate for a specific project within Oasis. 4 | 5 | ## Prerequisites 6 | 7 | *This example uses syntax elements specific to Terraform version 0.13+ (tested on Terraform version 1.1.4). 8 | It will not work out-of-the-box with Terraform 0.12.x and lower.* 9 | 10 | ## Environment variables 11 | Please refer to [Main README](../../README.md) file for all the environment variables you might need. 12 | 13 | ## Instructions on how to run: 14 | ``` 15 | terraform init 16 | terraform plan 17 | terraform apply 18 | ``` 19 | 20 | You can lock a Certificate by specifying the lock as an option in the schema: 21 | ```terraform 22 | resource "oasis_certificate" "my_oasis_cert" { 23 | name = "Terraform certificate" 24 | description = "Certificate description." 25 | project = oasis_project.oasis_test_project.id 26 | locked = true 27 | } 28 | ``` 29 | Note: if you run `terraform destroy` while the Certificate is locked, an error is shown, that's because you can't delete a locked CA Certificate. 30 | To delete it you have to either remove the property or set `locked=false`: 31 | ```terraform 32 | resource "oasis_certificate" "my_oasis_cert" { 33 | name = "Terraform certificate" 34 | description = "Certificate description." 35 | project = oasis_project.oasis_test_project.id 36 | locked = false 37 | } 38 | ``` 39 | 40 | To remove the resources created run: 41 | ``` 42 | terraform destroy 43 | ``` -------------------------------------------------------------------------------- /main.go: -------------------------------------------------------------------------------- 1 | // 2 | // DISCLAIMER 3 | // 4 | // Copyright 2020-2023 ArangoDB GmbH, Cologne, Germany 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | // Copyright holder is ArangoDB GmbH, Cologne, Germany 19 | // 20 | // 21 | 22 | package main 23 | 24 | import ( 25 | "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" 26 | "github.com/hashicorp/terraform-plugin-sdk/v2/plugin" 27 | 28 | provider "github.com/arangodb-managed/terraform-provider-oasis/internal" 29 | ) 30 | 31 | var ( 32 | projectVersion = "dev" 33 | projectBuild = "dev" 34 | ) 35 | 36 | // Examples folder formatting 37 | //go:generate terraform fmt -recursive ./examples/ 38 | 39 | // Terraform plugin tool for documentation generation 40 | //go:generate go run github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs 41 | 42 | func main() { 43 | provider.SetVersionAndBuild(projectVersion, projectBuild) 44 | plugin.Serve(&plugin.ServeOpts{ 45 | ProviderFunc: func() *schema.Provider { 46 | return provider.Provider() 47 | }, 48 | }) 49 | } 50 | -------------------------------------------------------------------------------- /internal/provider_test.go: -------------------------------------------------------------------------------- 1 | // 2 | // DISCLAIMER 3 | // 4 | // Copyright 2020-2022 ArangoDB GmbH, Cologne, Germany 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | // Copyright holder is ArangoDB GmbH, Cologne, Germany 19 | // 20 | 21 | package provider 22 | 23 | import ( 24 | "testing" 25 | 26 | "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" 27 | ) 28 | 29 | var ( 30 | testAccProviders map[string]*schema.Provider 31 | testAccProvider *schema.Provider 32 | testProviderFactories map[string]func() (*schema.Provider, error) 33 | ) 34 | 35 | func init() { 36 | testAccProvider = Provider() 37 | testAccProviders = map[string]*schema.Provider{ 38 | "oasis": testAccProvider, 39 | } 40 | testProviderFactories = map[string]func() (*schema.Provider, error){ 41 | "oasis": func() (*schema.Provider, error) { 42 | return testAccProvider, nil 43 | }, 44 | } 45 | } 46 | 47 | func TestProvider(t *testing.T) { 48 | if err := Provider().InternalValidate(); err != nil { 49 | t.Fatalf("err: %s", err) 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /docs/resources/organization_invite.md: -------------------------------------------------------------------------------- 1 | --- 2 | # generated by https://github.com/hashicorp/terraform-plugin-docs 3 | page_title: "oasis_organization_invite Resource - terraform-provider-oasis" 4 | subcategory: "" 5 | description: |- 6 | Oasis Organization Invite Resource 7 | --- 8 | 9 | # oasis_organization_invite (Resource) 10 | 11 | Oasis Organization Invite Resource 12 | 13 | ## Example Usage 14 | 15 | ```terraform 16 | terraform { 17 | required_version = ">= 0.13.0" 18 | required_providers { 19 | oasis = { 20 | source = "arangodb-managed/oasis" 21 | version = ">=2.1.0" 22 | } 23 | } 24 | } 25 | 26 | provider "oasis" { 27 | api_key_id = "" // API Key ID generated in Oasis platform 28 | api_key_secret = "" // API Key Secret generated in Oasis platform 29 | } 30 | 31 | // Terraform created organization 32 | resource "oasis_organization" "oasis_test_organization" { 33 | name = "Terraform Oasis Organization" 34 | description = "A test Oasis organization from Terraform Provider" 35 | } 36 | 37 | // Terraform created organization invite 38 | resource "oasis_organization_invite" "oasis_test_organization_invite" { 39 | organization = oasis_organization.oasis_test_organization.id 40 | email = "test.managedservice@arangodb.com" 41 | } 42 | ``` 43 | 44 | 45 | ## Schema 46 | 47 | ### Required 48 | 49 | - `email` (String) Organization Invite Resource Email field 50 | - `organization` (String) Organization Invite Resource Organization ID field 51 | 52 | ### Read-Only 53 | 54 | - `id` (String) The ID of this resource. 55 | 56 | 57 | -------------------------------------------------------------------------------- /docs/data-sources/cloud_provider.md: -------------------------------------------------------------------------------- 1 | --- 2 | # generated by https://github.com/hashicorp/terraform-plugin-docs 3 | page_title: "oasis_cloud_provider Data Source - terraform-provider-oasis" 4 | subcategory: "" 5 | description: |- 6 | Oasis Cloud Providers Data Source 7 | --- 8 | 9 | # oasis_cloud_provider (Data Source) 10 | 11 | Oasis Cloud Providers Data Source 12 | 13 | ## Example Usage 14 | 15 | ```terraform 16 | terraform { 17 | required_version = ">= 0.13.0" 18 | required_providers { 19 | oasis = { 20 | source = "arangodb-managed/oasis" 21 | version = ">=2.1.0" 22 | } 23 | } 24 | } 25 | 26 | provider "oasis" { 27 | api_key_id = "" // API Key ID generated in Oasis platform 28 | api_key_secret = "" // API Key Secret generated in Oasis platform 29 | } 30 | 31 | // Load in Oasis Cloud Providers 32 | data "oasis_cloud_provider" "test_oasis_cloud_providers" { 33 | organization = "" // Provide your Organization ID here 34 | } 35 | 36 | // Output the data after it has been synced. 37 | output "datasets" { 38 | value = data.oasis_cloud_provider.test_oasis_cloud_providers 39 | } 40 | ``` 41 | 42 | 43 | ## Schema 44 | 45 | ### Required 46 | 47 | - `organization` (String) Cloud Provider Data Source Organization ID field 48 | 49 | ### Read-Only 50 | 51 | - `id` (String) The ID of this resource. 52 | - `providers` (List of Object) List of all supported cloud providers in Oasis. (see [below for nested schema](#nestedatt--providers)) 53 | 54 | 55 | ### Nested Schema for `providers` 56 | 57 | Read-Only: 58 | 59 | - `id` (String) 60 | - `name` (String) 61 | 62 | 63 | -------------------------------------------------------------------------------- /docs/data-sources/notebook_model.md: -------------------------------------------------------------------------------- 1 | --- 2 | # generated by https://github.com/hashicorp/terraform-plugin-docs 3 | page_title: "oasis_notebook_model Data Source - terraform-provider-oasis" 4 | subcategory: "" 5 | description: |- 6 | Oasis Notebook Model Data Source 7 | --- 8 | 9 | # oasis_notebook_model (Data Source) 10 | 11 | Oasis Notebook Model Data Source 12 | 13 | ## Example Usage 14 | 15 | ```terraform 16 | terraform { 17 | required_version = ">= 0.13.0" 18 | required_providers { 19 | oasis = { 20 | source = "arangodb-managed/oasis" 21 | version = ">=2.1.7" 22 | } 23 | } 24 | } 25 | 26 | provider "oasis" { 27 | api_key_id = "" // API Key ID generated in Oasis platform 28 | api_key_secret = "" // API Key Secret generated in Oasis platform 29 | } 30 | 31 | // Load in all the available datasets 32 | data "oasis_notebook_model" "models" { 33 | deployment_id = "" // deployment id (required) 34 | } 35 | 36 | // Output the data after it has been synced. 37 | output "datasets" { 38 | value = data.oasis_notebook_model.models 39 | } 40 | ``` 41 | 42 | 43 | ## Schema 44 | 45 | ### Optional 46 | 47 | - `deployment_id` (String) Notebook Model Data Source Notebook Model Deployment ID field 48 | 49 | ### Read-Only 50 | 51 | - `id` (String) The ID of this resource. 52 | - `items` (List of Object) (see [below for nested schema](#nestedatt--items)) 53 | 54 | 55 | ### Nested Schema for `items` 56 | 57 | Read-Only: 58 | 59 | - `cpu` (Number) 60 | - `id` (String) 61 | - `max_disk_size` (Number) 62 | - `memory` (Number) 63 | - `min_disk_size` (Number) 64 | - `name` (String) 65 | 66 | 67 | -------------------------------------------------------------------------------- /docs/resources/project.md: -------------------------------------------------------------------------------- 1 | --- 2 | # generated by https://github.com/hashicorp/terraform-plugin-docs 3 | page_title: "oasis_project Resource - terraform-provider-oasis" 4 | subcategory: "" 5 | description: |- 6 | Oasis Project Resource 7 | --- 8 | 9 | # oasis_project (Resource) 10 | 11 | Oasis Project Resource 12 | 13 | ## Example Usage 14 | 15 | ```terraform 16 | terraform { 17 | required_version = ">= 0.13.0" 18 | required_providers { 19 | oasis = { 20 | source = "arangodb-managed/oasis" 21 | version = ">=2.1.0" 22 | } 23 | } 24 | } 25 | 26 | provider "oasis" { 27 | api_key_id = "" // API Key ID generated in Oasis platform 28 | api_key_secret = "" // API Key Secret generated in Oasis platform 29 | organization = "" // Your Oasis organization where you want to create the resources 30 | } 31 | 32 | // Terraform created project 33 | resource "oasis_project" "oasis_test_project" { 34 | name = "Terraform Oasis Project" 35 | description = "A test Oasis project within an organization from the Terraform Provider" 36 | } 37 | ``` 38 | 39 | 40 | ## Schema 41 | 42 | ### Required 43 | 44 | - `name` (String) Project Resource Project Name field 45 | 46 | ### Optional 47 | 48 | - `description` (String) Project Resource Project Description field 49 | - `locked` (Boolean) Project Resource Project Locked field 50 | - `organization` (String) Project Resource Organization ID field 51 | 52 | ### Read-Only 53 | 54 | - `created_at` (String) Project Resource Project Created At field 55 | - `id` (String) The ID of this resource. 56 | - `is_deleted` (Boolean) Project Resource Project IsDeleted field 57 | 58 | 59 | -------------------------------------------------------------------------------- /docs/guides/setup.md: -------------------------------------------------------------------------------- 1 | --- 2 | page_title: "Setup" 3 | description: |- 4 | Guide to setup the Oasis Provider with the required Keys 5 | --- 6 | 7 | # Setup 8 | 9 | When using the provider, you need to set up api_key_id and api_key_secret. Both parameters can be generated in the ArangoGraph Insights Platform (formerly called Oasis) Dashboard. Once you are logged in, navigate to the [**API Keys**](https://cloud.arangodb.com/dashboard/user/api-keys) tab of your user account and click the **New API** key button. 10 | 11 | ```hcl 12 | terraform { 13 | required_version = ">= 0.13.0" 14 | required_providers { 15 | oasis = { 16 | source = "arangodb-managed/oasis" 17 | version = ">=2.1.0" 18 | } 19 | } 20 | } 21 | 22 | provider "oasis" { 23 | api_key_id = "" // API Key ID generated in ArangoGraph Insights Platform platform 24 | api_key_secret = "" // API Key Secret generated in ArangoGraph Insights Platform platform 25 | } 26 | ``` 27 | 28 | The provider can also be setup with a default organization and project to manage resources in: 29 | 30 | ```hcl 31 | provider "oasis" { 32 | api_key_id = "" // API Key ID generated in ArangoGraph Insights Platform 33 | api_key_secret = "" // API Key Secret generated in ArangoGraph Insights Platform 34 | organization = "" // Organization ID within ArangoGraph Insights Platform 35 | project = "" // Project ID within the specified organization 36 | } 37 | ``` 38 | 39 | The other options you can provide are: 40 | - `oasis_endpoint` for the endpoint you want to manage the resources in (by default set to: `api.cloud.arangodb.com`). 41 | - `api_port_suffix` for the ArangoGraph Insights Platform API Port Suffix (by default set to `:443`). -------------------------------------------------------------------------------- /docs/data-sources/backup.md: -------------------------------------------------------------------------------- 1 | --- 2 | # generated by https://github.com/hashicorp/terraform-plugin-docs 3 | page_title: "oasis_backup Data Source - terraform-provider-oasis" 4 | subcategory: "" 5 | description: |- 6 | Oasis Backup Data Source 7 | --- 8 | 9 | # oasis_backup (Data Source) 10 | 11 | Oasis Backup Data Source 12 | 13 | ## Example Usage 14 | 15 | ```terraform 16 | terraform { 17 | required_version = ">= 0.13.0" 18 | required_providers { 19 | oasis = { 20 | source = "arangodb-managed/oasis" 21 | version = ">=2.1.0" 22 | } 23 | } 24 | } 25 | 26 | provider "oasis" { 27 | api_key_id = "" // API Key ID generated in Oasis platform 28 | api_key_secret = "" // API Key Secret generated in Oasis platform 29 | organization = "" // Your Oasis organization where you want to create the resources 30 | } 31 | 32 | // Load in an Oasis backup of a deployment 33 | data "oasis_backup" "oasis_test_backup" { 34 | id = "" // Provide your Backup ID here 35 | } 36 | 37 | // Output the data after it has been synced. 38 | output "backup" { 39 | value = data.oasis_backup.oasis_test_backup 40 | } 41 | ``` 42 | 43 | 44 | ## Schema 45 | 46 | ### Required 47 | 48 | - `id` (String) Backup Data Source ID field 49 | 50 | ### Optional 51 | 52 | - `backup_policy_id` (String) Backup Data Source Policy ID field 53 | - `deployment_id` (String) Backup Sata Source Deployment ID field 54 | - `description` (String) Backup Data Source Description field 55 | - `name` (String) Backup Data Source Name field 56 | - `url` (String) Backup Data Source URL field 57 | 58 | ### Read-Only 59 | 60 | - `created_at` (String) Backup Sata Source Created At field 61 | 62 | 63 | -------------------------------------------------------------------------------- /templates/guides/setup.md.tmpl: -------------------------------------------------------------------------------- 1 | --- 2 | page_title: "Setup" 3 | description: |- 4 | Guide to setup the Oasis Provider with the required Keys 5 | --- 6 | 7 | # Setup 8 | 9 | When using the provider, you need to set up api_key_id and api_key_secret. Both parameters can be generated in the ArangoGraph Insights Platform (formerly called Oasis) Dashboard. Once you are logged in, navigate to the [**API Keys**](https://cloud.arangodb.com/dashboard/user/api-keys) tab of your user account and click the **New API** key button. 10 | 11 | ```hcl 12 | terraform { 13 | required_version = ">= 0.13.0" 14 | required_providers { 15 | oasis = { 16 | source = "arangodb-managed/oasis" 17 | version = ">=2.1.0" 18 | } 19 | } 20 | } 21 | 22 | provider "oasis" { 23 | api_key_id = "" // API Key ID generated in ArangoGraph Insights Platform platform 24 | api_key_secret = "" // API Key Secret generated in ArangoGraph Insights Platform platform 25 | } 26 | ``` 27 | 28 | The provider can also be setup with a default organization and project to manage resources in: 29 | 30 | ```hcl 31 | provider "oasis" { 32 | api_key_id = "" // API Key ID generated in ArangoGraph Insights Platform 33 | api_key_secret = "" // API Key Secret generated in ArangoGraph Insights Platform 34 | organization = "" // Organization ID within ArangoGraph Insights Platform 35 | project = "" // Project ID within the specified organization 36 | } 37 | ``` 38 | 39 | The other options you can provide are: 40 | - `oasis_endpoint` for the endpoint you want to manage the resources in (by default set to: `api.cloud.arangodb.com`). 41 | - `api_port_suffix` for the ArangoGraph Insights Platform API Port Suffix (by default set to `:443`). -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "git.ignoreLimitWarning": true, 3 | "fileHeaderComment.parameter":{ 4 | "*":{ 5 | "commentprefix": "//", 6 | "company": "ArangoDB GmbH, Cologne, Germany", 7 | } 8 | }, 9 | "fileHeaderComment.template":{ 10 | "*":[ 11 | "${commentprefix} ", 12 | "${commentprefix} DISCLAIMER", 13 | "${commentprefix} ", 14 | "${commentprefix} Copyright ${year} ArangoDB GmbH, Cologne, Germany", 15 | "${commentprefix} ", 16 | "${commentprefix} Licensed under the Apache License, Version 2.0 (the \"License\");", 17 | "${commentprefix} you may not use this file except in compliance with the License.", 18 | "${commentprefix} You may obtain a copy of the License at", 19 | "${commentprefix} ", 20 | "${commentprefix} http://www.apache.org/licenses/LICENSE-2.0", 21 | "${commentprefix} ", 22 | "${commentprefix} Unless required by applicable law or agreed to in writing, software", 23 | "${commentprefix} distributed under the License is distributed on an \"AS IS\" BASIS,", 24 | "${commentprefix} WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", 25 | "${commentprefix} See the License for the specific language governing permissions and", 26 | "${commentprefix} limitations under the License.", 27 | "${commentprefix} ", 28 | "${commentprefix} Copyright holder is ArangoDB GmbH, Cologne, Germany", 29 | "${commentprefix} ", 30 | "${commentprefix} Author ${author}", 31 | "${commentprefix} ", 32 | "" 33 | ] 34 | }, 35 | } 36 | -------------------------------------------------------------------------------- /docs/resources/iam_group.md: -------------------------------------------------------------------------------- 1 | --- 2 | # generated by https://github.com/hashicorp/terraform-plugin-docs 3 | page_title: "oasis_iam_group Resource - terraform-provider-oasis" 4 | subcategory: "" 5 | description: |- 6 | Oasis IAM Group Resource 7 | --- 8 | 9 | # oasis_iam_group (Resource) 10 | 11 | Oasis IAM Group Resource 12 | 13 | ## Example Usage 14 | 15 | ```terraform 16 | terraform { 17 | required_version = ">= 0.13.0" 18 | required_providers { 19 | oasis = { 20 | source = "arangodb-managed/oasis" 21 | version = ">=2.1.0" 22 | } 23 | } 24 | } 25 | 26 | provider "oasis" { 27 | api_key_id = "" // API Key ID generated in Oasis platform 28 | api_key_secret = "" // API Key Secret generated in Oasis platform 29 | } 30 | 31 | // Terraform created organization 32 | resource "oasis_organization" "oasis_test_organization" { 33 | name = "Terraform Oasis Organization" 34 | description = "A test Oasis organization from Terraform Provider" 35 | } 36 | 37 | // Terraform created IAM Group. This resource uses the computed ID value of the 38 | // previously defined organization resource. 39 | resource "oasis_iam_group" "my_iam_group" { 40 | name = "Terraform IAM Group" 41 | description = "IAM Group created by Terraform" 42 | organization = oasis_organization.oasis_test_organization.id 43 | } 44 | ``` 45 | 46 | 47 | ## Schema 48 | 49 | ### Required 50 | 51 | - `name` (String) IAM Group Resource IAM Group Name 52 | - `organization` (String) IAM Group Resource IAM Group Organization ID 53 | 54 | ### Optional 55 | 56 | - `description` (String) IAM Group Resource IAM Group Description 57 | 58 | ### Read-Only 59 | 60 | - `id` (String) The ID of this resource. 61 | 62 | 63 | -------------------------------------------------------------------------------- /examples/resources/oasis_project/README.md: -------------------------------------------------------------------------------- 1 | # Example: Project 2 | 3 | This example shows how to use the Terraform Oasis provider to create an Oasis Project within an organization. 4 | 5 | ## Prerequisites 6 | 7 | *This example uses syntax elements specific to Terraform version 0.13+ (tested on Terraform version 1.1.4). 8 | It will not work out-of-the-box with Terraform 0.12.x and lower (deprecated by Terraform).* 9 | 10 | ## Environment variables 11 | Please refer to [Main README](../../README.md) file for all the environment variables you might need. 12 | 13 | ## Instructions on how to run: 14 | ``` 15 | terraform init 16 | terraform plan 17 | terraform apply 18 | ``` 19 | 20 | You can lock a project by specifying the lock as an option in the schema: 21 | ```terraform 22 | resource "oasis_project" "oasis_test_project" { 23 | name = "Terraform Oasis Project" 24 | description = "A test Oasis project within an organization from the Terraform Provider" 25 | locked = true 26 | } 27 | ``` 28 | Note: if you run `terraform destroy` while the project is locked, an error is shown, that's because you can't delete a locked project. 29 | To delete it you have to either remove the property or set `lock=false`: 30 | ```terraform 31 | resource "oasis_project" "oasis_test_project" { 32 | name = "Terraform Oasis Project" 33 | description = "A test Oasis project within an organization from the Terraform Provider" 34 | locked = false 35 | } 36 | ``` 37 | After running `terraform plan` and then `terraform apply --auto-approve` you update the project to not be locked anymore. This way you can run `terraform destroy` without errors, this way deleting the project. 38 | 39 | To remove the resources created run: 40 | ``` 41 | terraform destroy 42 | ``` -------------------------------------------------------------------------------- /examples/resources/oasis_notebook/resource.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 0.13.0" 3 | required_providers { 4 | oasis = { 5 | source = "arangodb-managed/oasis" 6 | version = ">=2.1.7" 7 | } 8 | } 9 | } 10 | 11 | provider "oasis" { 12 | api_key_id = "" // API Key ID generated in Oasis platform 13 | api_key_secret = "" // API Key Secret generated in Oasis platform 14 | } 15 | 16 | // Create Project 17 | resource "oasis_project" "oasis_test_project" { 18 | name = "Terraform Oasis Project" 19 | description = "A test Oasis project within an organization from the Terraform Provider" 20 | } 21 | 22 | // Create Deployment 23 | resource "oasis_deployment" "my_oneshard_deployment" { 24 | terms_and_conditions_accepted = "true" 25 | project = oasis_project.oasis_test_project.id // Project id where deployment will be created 26 | name = "oasis_jupyter_notebook_deployment" 27 | location { 28 | region = "gcp-europe-west4" 29 | } 30 | security { 31 | disable_foxx_authentication = false 32 | } 33 | disk_performance = "dp30" 34 | configuration { 35 | model = "oneshard" 36 | node_size_id = "c4-a8" 37 | node_disk_size = 20 38 | maximum_node_disk_size = 40 39 | } 40 | notification_settings { 41 | email_addresses = [ 42 | "test@arangodb.com" 43 | ] 44 | } 45 | } 46 | 47 | // Create Notebook 48 | resource "oasis_notebook" "oasis_test_notebook" { 49 | deployment_id = oasis_deployment.my_oneshard_deployment.id 50 | name = "Test Oasis Jupyter Notebook" 51 | description = "Test Description" 52 | model { 53 | notebook_model_id = "basic" 54 | disk_size = "10" 55 | } 56 | } -------------------------------------------------------------------------------- /examples/resources/oasis_backup/resource.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 0.13.0" 3 | required_providers { 4 | oasis = { 5 | source = "arangodb-managed/oasis" 6 | version = ">=2.1.0" 7 | } 8 | } 9 | } 10 | 11 | provider "oasis" { 12 | api_key_id = "" // API Key ID generated in Oasis platform 13 | api_key_secret = "" // API Key Secret generated in Oasis platform 14 | organization = "" // Your Oasis organization where you want to create the resources 15 | } 16 | 17 | // Terraform created project. 18 | resource "oasis_project" "oasis_test_project" { 19 | name = "Terraform Oasis Project" 20 | description = "A test Oasis project within an organization from the Terraform Provider" 21 | } 22 | 23 | // Example of a oneshard deployment 24 | resource "oasis_deployment" "my_oneshard_deployment" { 25 | terms_and_conditions_accepted = "true" 26 | project = oasis_project.oasis_test_project.id // Project id where deployment will be created 27 | name = "oasis_test_dep_tf" 28 | location { 29 | region = "gcp-europe-west4" 30 | } 31 | 32 | configuration { 33 | model = "oneshard" 34 | node_size_id = "c4-a8" 35 | node_disk_size = 20 36 | } 37 | notification_settings { 38 | email_addresses = [ 39 | "test@arangodb.com" 40 | ] 41 | } 42 | } 43 | 44 | // Oasis backup 45 | // This resources uses the computed ID of the deployment created above. 46 | resource "oasis_backup" "my_backup" { 47 | name = "test tf backup" 48 | description = "test backup description from terraform" 49 | deployment_id = oasis_deployment.my_oneshard_deployment.id 50 | upload = true 51 | auto_deleted_at = 3 // auto delete after 3 days 52 | } -------------------------------------------------------------------------------- /examples/resources/oasis_iam_policy/resource.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 0.13.0" 3 | required_providers { 4 | oasis = { 5 | source = "arangodb-managed/oasis" 6 | version = ">=2.1.2" 7 | } 8 | } 9 | } 10 | 11 | provider "oasis" { 12 | api_key_id = "" // API Key ID generated in Oasis platform 13 | api_key_secret = "" // API Key Secret generated in Oasis platform 14 | } 15 | 16 | // Terraform created organization 17 | resource "oasis_organization" "oasis_test_organization" { 18 | name = "Terraform Oasis Organization" 19 | description = "A test Oasis organization from Terraform Provider" 20 | } 21 | 22 | // Terraform created IAM Group. This resource uses the computed ID value of the 23 | // previously defined organization resource. 24 | resource "oasis_iam_group" "my_iam_group" { 25 | name = "Terraform IAM Group" 26 | description = "IAM Group created by Terraform" 27 | organization = oasis_organization.oasis_test_organization.id 28 | } 29 | 30 | // Load in an Oasis Current User within an organization 31 | data "oasis_current_user" "oasis_test_current_user" {} 32 | 33 | // Terraform created IAM Policy. This resource uses the computed ID value of the 34 | // previously defined organization resource and IAM group resource. 35 | resource "oasis_iam_policy" "my_iam_policy_group" { 36 | url = "/Organization/${oasis_organization.oasis_test_organization.id}" 37 | 38 | binding { 39 | role = "auditlog-admin" 40 | group = oasis_iam_group.my_iam_group.id 41 | } 42 | 43 | binding { 44 | role = "auditlog-archive-viewer" 45 | group = oasis_iam_group.my_iam_group.id 46 | } 47 | 48 | binding { 49 | role = "auditlog-archive-viewer" 50 | user = data.oasis_current_user.oasis_test_current_user.id 51 | } 52 | } -------------------------------------------------------------------------------- /examples/resources/oasis_organization/README.md: -------------------------------------------------------------------------------- 1 | # Example: Organization 2 | 3 | This example shows how to use the Terraform Oasis provider to get data about an Oasis Organization. An organization typically represents a (commercial) entity such as a company, a company division, an institution or a non-profit organization. 4 | 5 | ## Prerequisites 6 | 7 | *This example uses syntax elements specific to Terraform version 0.13+ (tested on Terraform version 1.1.4). 8 | It will not work out-of-the-box with Terraform 0.12.x and lower (deprecated by Terraform).* 9 | 10 | ## Environment variables 11 | Please refer to [Main README](../../README.md) file for all the environment variables you might need. 12 | 13 | ## Instructions on how to run: 14 | ``` 15 | terraform init 16 | terraform plan 17 | terraform apply 18 | ``` 19 | 20 | You can lock an organization by specifying it as an option in the schema: 21 | ```terraform 22 | resource "oasis_organization" "oasis_test_organization" { 23 | name = "Terraform Oasis Organization" 24 | description = "A test Oasis organization from Terraform Provider" 25 | lock = true 26 | } 27 | ``` 28 | Note: if you run `terraform destroy` while the organization is locked an error is shown, that's because you can't delete a locked organization. 29 | To delete it you have to either remove the property or set `lock=false`: 30 | ```terraform 31 | resource "oasis_organization" "oasis_test_organization" { 32 | name = "Terraform Oasis Organization" 33 | description = "A test Oasis organization from Terraform Provider" 34 | lock = false 35 | } 36 | ``` 37 | After running `terraform plan` and then `terraform apply --auto-approve` you update the organization to not be locked anymore. This way you can run `terraform destroy` without errors. 38 | 39 | To remove the resources created run: 40 | ``` 41 | terraform destroy 42 | ``` -------------------------------------------------------------------------------- /docs/data-sources/region.md: -------------------------------------------------------------------------------- 1 | --- 2 | # generated by https://github.com/hashicorp/terraform-plugin-docs 3 | page_title: "oasis_region Data Source - terraform-provider-oasis" 4 | subcategory: "" 5 | description: |- 6 | Oasis Cloud Provider Regions Data Source 7 | --- 8 | 9 | # oasis_region (Data Source) 10 | 11 | Oasis Cloud Provider Regions Data Source 12 | 13 | ## Example Usage 14 | 15 | ```terraform 16 | terraform { 17 | required_version = ">= 0.13.0" 18 | required_providers { 19 | oasis = { 20 | source = "arangodb-managed/oasis" 21 | version = ">=2.1.0" 22 | } 23 | } 24 | } 25 | 26 | provider "oasis" { 27 | api_key_id = "" // API Key ID generated in Oasis platform 28 | api_key_secret = "" // API Key Secret generated in Oasis platform 29 | } 30 | 31 | // Load in Oasis Cloud Providers 32 | data "oasis_region" "test_oasis_region" { 33 | organization = "" // put your organization id here 34 | provider_id = "" // put one of the cloud provider ids here (can be fetched from cloud_provider data source) 35 | } 36 | 37 | // Output the data after it has been synced. 38 | output "datasets" { 39 | value = data.oasis_region.test_oasis_region 40 | } 41 | ``` 42 | 43 | 44 | ## Schema 45 | 46 | ### Required 47 | 48 | - `organization` (String) Regions Data Source Organization ID field 49 | - `provider_id` (String) Regions Data Source Provider ID field 50 | 51 | ### Read-Only 52 | 53 | - `id` (String) The ID of this resource. 54 | - `regions` (List of Object) List of all supported regions for a Cloud Provider in Oasis. (see [below for nested schema](#nestedatt--regions)) 55 | 56 | 57 | ### Nested Schema for `regions` 58 | 59 | Read-Only: 60 | 61 | - `available` (Boolean) 62 | - `id` (String) 63 | - `location` (String) 64 | - `provider_id` (String) 65 | 66 | 67 | -------------------------------------------------------------------------------- /docs/data-sources/example_datasets.md: -------------------------------------------------------------------------------- 1 | --- 2 | # generated by https://github.com/hashicorp/terraform-plugin-docs 3 | page_title: "oasis_example_datasets Data Source - terraform-provider-oasis" 4 | subcategory: "" 5 | description: |- 6 | Oasis Example Datasets Data Source 7 | --- 8 | 9 | # oasis_example_datasets (Data Source) 10 | 11 | Oasis Example Datasets Data Source 12 | 13 | ## Example Usage 14 | 15 | ```terraform 16 | terraform { 17 | required_version = ">= 0.13.0" 18 | required_providers { 19 | oasis = { 20 | source = "arangodb-managed/oasis" 21 | version = ">=2.1.0" 22 | } 23 | } 24 | } 25 | 26 | provider "oasis" { 27 | api_key_id = "" // API Key ID generated in Oasis platform 28 | api_key_secret = "" // API Key Secret generated in Oasis platform 29 | } 30 | 31 | // Load in all the available datasets 32 | data "oasis_example_datasets" "datasets" { 33 | // optionally define an organization id to list example datasets for which are 34 | // only available to that organization. If you do not have access to said organization 35 | // this will just be ignored. 36 | organization = "" // organization id 37 | } 38 | 39 | // Output the data after it has been synced. 40 | output "datasets" { 41 | value = data.oasis_example_datasets.datasets 42 | } 43 | ``` 44 | 45 | 46 | ## Schema 47 | 48 | ### Optional 49 | 50 | - `organization` (String) Example Data Set Data Source Organization ID field 51 | 52 | ### Read-Only 53 | 54 | - `id` (String) The ID of this resource. 55 | - `items` (List of Object) (see [below for nested schema](#nestedatt--items)) 56 | 57 | 58 | ### Nested Schema for `items` 59 | 60 | Read-Only: 61 | 62 | - `created_at` (String) 63 | - `description` (String) 64 | - `guide` (String) 65 | - `id` (String) 66 | - `name` (String) 67 | 68 | 69 | -------------------------------------------------------------------------------- /examples/resources/oasis_ipallowlist/README.md: -------------------------------------------------------------------------------- 1 | # Example: IPAllowlist 2 | 3 | This example shows how to use the Terraform Oasis provider to create an IPAllowlist for a specific project within Oasis. 4 | 5 | ## Prerequisites 6 | 7 | *This example uses syntax elements specific to Terraform version 0.13+ (tested on Terraform version 1.1.4). 8 | It will not work out-of-the-box with Terraform 0.12.x and lower (deprecated by Terraform).* 9 | 10 | ## Environment variables 11 | Please refer to [Main README](../../README.md) file for all the environment variables you might need. 12 | 13 | ## Instructions on how to run: 14 | ``` 15 | terraform init 16 | terraform plan 17 | terraform apply 18 | ``` 19 | 20 | You can lock an IP Allow List by specifying the lock as an option in the schema: 21 | ```terraform 22 | resource "oasis_ipallowlist" "my_iplist" { 23 | name = "Terraform IP Allowlist" 24 | description = "IP Allowlist description" 25 | cidr_ranges = ["1.2.3.4/32", "111.11.0.0/16"] 26 | project = oasis_project.my_project.id 27 | locked = true 28 | } 29 | ``` 30 | Note: if you run `terraform destroy` while the IP Allow List is locked, an error is shown, that's because you can't delete a locked IP Allow List. 31 | To delete it you have to either remove the property or set `lock=false`: 32 | ```terraform 33 | resource "oasis_ipallowlist" "my_iplist" { 34 | name = "Terraform IP Allowlist" 35 | description = "IP Allowlist description" 36 | cidr_ranges = ["1.2.3.4/32", "111.11.0.0/16"] 37 | project = oasis_project.my_project.id 38 | locked = false 39 | } 40 | ``` 41 | After running `terraform plan` and then `terraform apply --auto-approve` you update the IP Allow List to not be locked anymore. This way you can run `terraform destroy` without errors, deleting the IP Allow List. 42 | 43 | To remove the resources created run: 44 | ``` 45 | terraform destroy 46 | ``` -------------------------------------------------------------------------------- /docs/resources/iam_role.md: -------------------------------------------------------------------------------- 1 | --- 2 | # generated by https://github.com/hashicorp/terraform-plugin-docs 3 | page_title: "oasis_iam_role Resource - terraform-provider-oasis" 4 | subcategory: "" 5 | description: |- 6 | Oasis IAM Role Resource 7 | --- 8 | 9 | # oasis_iam_role (Resource) 10 | 11 | Oasis IAM Role Resource 12 | 13 | ## Example Usage 14 | 15 | ```terraform 16 | terraform { 17 | required_version = ">= 0.13.0" 18 | required_providers { 19 | oasis = { 20 | source = "arangodb-managed/oasis" 21 | version = ">=2.1.0" 22 | } 23 | } 24 | } 25 | 26 | provider "oasis" { 27 | api_key_id = "" // API Key ID generated in Oasis platform 28 | api_key_secret = "" // API Key Secret generated in Oasis platform 29 | } 30 | 31 | // Terraform created organization 32 | resource "oasis_organization" "oasis_test_organization" { 33 | name = "Terraform Oasis Organization" 34 | description = "A test Oasis organization from Terraform Provider" 35 | } 36 | 37 | // Terraform created IAM Role. This resource uses the computed ID value of the 38 | // previously defined organization resource. 39 | resource "oasis_iam_role" "my_iam_role" { 40 | name = "Terraform IAM Role" 41 | description = "IAM Role created by Terraform" 42 | organization = oasis_organization.oasis_test_organization.id 43 | permissions = ["audit.auditlog.list"] // optional 44 | } 45 | ``` 46 | 47 | 48 | ## Schema 49 | 50 | ### Required 51 | 52 | - `name` (String) IAM Role Resource IAM Role Name field 53 | - `organization` (String) IAM Role Resource IAM Role Organization ID field 54 | 55 | ### Optional 56 | 57 | - `description` (String) IAM Role Resource IAM Role Description field 58 | - `permissions` (List of String) IAM Role Resource IAM Role Permissions field (list of permissions) 59 | 60 | ### Read-Only 61 | 62 | - `id` (String) The ID of this resource. 63 | 64 | 65 | -------------------------------------------------------------------------------- /internal/data_source_cloud_providers_test.go: -------------------------------------------------------------------------------- 1 | // 2 | // DISCLAIMER 3 | // 4 | // Copyright 2022 ArangoDB GmbH, Cologne, Germany 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | // Copyright holder is ArangoDB GmbH, Cologne, Germany 19 | // 20 | 21 | package provider 22 | 23 | import ( 24 | "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" 25 | "regexp" 26 | "testing" 27 | ) 28 | 29 | func TestAccOasisCloudProviderBasic(t *testing.T) { 30 | rxPosNum := regexp.MustCompile("^[1-9][0-9]*$") 31 | 32 | resource.Test(t, resource.TestCase{ 33 | PreCheck: func() { testAccPreCheck(t) }, 34 | ProviderFactories: testProviderFactories, 35 | Steps: []resource.TestStep{ 36 | { 37 | Config: testAccOasisCloudProviderConfigBasic(), 38 | Check: resource.ComposeAggregateTestCheckFunc( 39 | resource.TestMatchResourceAttr("data.oasis_cloud_provider.test_oasis_cloud_providers", "providers.#", rxPosNum), 40 | resource.TestCheckResourceAttrSet("data.oasis_cloud_provider.test_oasis_cloud_providers", "providers.0.id"), 41 | ), 42 | }, 43 | }, 44 | }) 45 | } 46 | 47 | func testAccOasisCloudProviderConfigBasic() string { 48 | return ` 49 | resource "oasis_organization" "test_organization" { 50 | name = "test" 51 | description = "A test Oasis organization from Terraform Provider" 52 | } 53 | 54 | data "oasis_cloud_provider" "test_oasis_cloud_providers" { 55 | organization = oasis_organization.test_organization.id 56 | } 57 | ` 58 | } 59 | -------------------------------------------------------------------------------- /docs/data-sources/organization.md: -------------------------------------------------------------------------------- 1 | --- 2 | # generated by https://github.com/hashicorp/terraform-plugin-docs 3 | page_title: "oasis_organization Data Source - terraform-provider-oasis" 4 | subcategory: "" 5 | description: |- 6 | Oasis Organization Data Source 7 | --- 8 | 9 | # oasis_organization (Data Source) 10 | 11 | Oasis Organization Data Source 12 | 13 | ## Example Usage 14 | 15 | ```terraform 16 | terraform { 17 | required_version = ">= 0.13.0" 18 | required_providers { 19 | oasis = { 20 | source = "arangodb-managed/oasis" 21 | version = ">=2.1.0" 22 | } 23 | } 24 | } 25 | 26 | provider "oasis" { 27 | api_key_id = "" // API Key ID generated in Oasis platform 28 | api_key_secret = "" // API Key Secret generated in Oasis platform 29 | } 30 | 31 | // Load in an Oasis organization 32 | data "oasis_organization" "oasis_test_organization" { 33 | id = "" // Provide your Organization ID here 34 | } 35 | 36 | // Output the data after it has been synced. 37 | output "datasets" { 38 | value = data.oasis_organization.oasis_test_organization 39 | } 40 | ``` 41 | 42 | 43 | ## Schema 44 | 45 | ### Required 46 | 47 | - `id` (String) Organization Data Source Organization ID field 48 | 49 | ### Optional 50 | 51 | - `description` (String) Organization Data Source Organization Description field 52 | - `name` (String) Organization Data Source Organization Name field 53 | 54 | ### Read-Only 55 | 56 | - `created_at` (String) Organization Data Source Organization Created At field 57 | - `is_deleted` (Boolean) Organization Data Source Organization is deleted field 58 | - `tier` (Set of Object) Organization Data Source Organization Tier field (see [below for nested schema](#nestedatt--tier)) 59 | - `url` (String) Organization Data Source Organization URL field 60 | 61 | 62 | ### Nested Schema for `tier` 63 | 64 | Read-Only: 65 | 66 | - `has_backup_uploads` (Boolean) 67 | - `has_support_plans` (Boolean) 68 | - `id` (String) 69 | - `name` (String) 70 | - `requires_terms_and_conditions` (Boolean) 71 | 72 | 73 | -------------------------------------------------------------------------------- /examples/resources/oasis_multi_region_backup/resource.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 0.13.0" 3 | required_providers { 4 | oasis = { 5 | source = "arangodb-managed/oasis" 6 | version = ">=2.1.6" 7 | } 8 | } 9 | } 10 | 11 | provider "oasis" { 12 | api_key_id = "" // API Key ID generated in Oasis platform 13 | api_key_secret = "" // API Key Secret generated in Oasis platform 14 | organization = "" // Your Oasis organization where you want to create the resources 15 | } 16 | 17 | // Create Project 18 | resource "oasis_project" "oasis_test_project" { 19 | name = "Terraform Oasis Project" 20 | description = "A test Oasis project within an organization from the Terraform Provider" 21 | } 22 | 23 | // Create Deployment 24 | resource "oasis_deployment" "my_oneshard_deployment" { 25 | terms_and_conditions_accepted = "true" 26 | project = oasis_project.oasis_test_project.id // Project id where deployment will be created 27 | name = "oasis_multi_region_deployment" 28 | location { 29 | region = "gcp-europe-west4" 30 | } 31 | security { 32 | disable_foxx_authentication = false 33 | } 34 | disk_performance = "dp30" 35 | configuration { 36 | model = "oneshard" 37 | node_size_id = "c4-a8" 38 | node_disk_size = 20 39 | maximum_node_disk_size = 40 40 | } 41 | notification_settings { 42 | email_addresses = [ 43 | "test@arangodb.com" 44 | ] 45 | } 46 | } 47 | 48 | // Create Backup 49 | resource "oasis_backup" "backup" { 50 | name = "oasis_backup" 51 | description = "test backup description update from terraform" 52 | deployment_id = oasis_deployment.my_oneshard_deployment.id 53 | upload = true 54 | auto_deleted_at = 3 // auto delete after 3 days 55 | } 56 | 57 | // Create Multi Region Backup 58 | resource "oasis_multi_region_backup" "backup" { 59 | source_backup_id = oasis_backup.backup.id // Existing backup ID 60 | region_id = "gcp-us-central1" // Oasis region identifier, which is other than the deployment region 61 | } -------------------------------------------------------------------------------- /examples/data-sources/oasis_region/README.md: -------------------------------------------------------------------------------- 1 | # Example: Cloud Provider Region Data Source 2 | 3 | This example shows how to use the Terraform Oasis provider to manage Region Data Source in Oasis. 4 | 5 | ## Prerequisites 6 | 7 | *This example uses syntax elements specific to Terraform version 0.13+ (tested on Terraform version 1.1.4). 8 | It will not work out-of-the-box with Terraform 0.12.x and lower (deprecated by Terraform).* 9 | 10 | ## Environment variables 11 | Please refer to [Main README](../../README.md) file for all the environment variables you might need. 12 | 13 | ## Example output 14 | ``` 15 | datasets = { 16 | "id" = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" 17 | "organization" = "_support" 18 | "provider_id" = "aks" 19 | "regions" = tolist([ 20 | { 21 | "available" = true 22 | "id" = "aks-canadacentral" 23 | "location" = "Central Canada, Toronto" 24 | "provider_id" = "aks" 25 | }, 26 | { 27 | "available" = true 28 | "id" = "aks-eastus2" 29 | "location" = "East US, Virginia" 30 | "provider_id" = "aks" 31 | }, 32 | { 33 | "available" = true 34 | "id" = "aks-japaneast" 35 | "location" = "Japan East" 36 | "provider_id" = "aks" 37 | }, 38 | { 39 | "available" = true 40 | "id" = "aks-southeastasia" 41 | "location" = "Southeast Asia, Singapore" 42 | "provider_id" = "aks" 43 | }, 44 | { 45 | "available" = true 46 | "id" = "aks-uksouth" 47 | "location" = "UK, London" 48 | "provider_id" = "aks" 49 | }, 50 | { 51 | "available" = true 52 | "id" = "aks-westeurope" 53 | "location" = "West Europe, Netherlands" 54 | "provider_id" = "aks" 55 | }, 56 | { 57 | "available" = true 58 | "id" = "aks-westus2" 59 | "location" = "West US, Washington" 60 | "provider_id" = "aks" 61 | }, 62 | ]) 63 | } 64 | ``` 65 | 66 | ## Instructions on how to run: 67 | ``` 68 | terraform init 69 | terraform plan 70 | terraform apply 71 | ``` 72 | 73 | To remove the resources created run: 74 | ``` 75 | terraform destroy 76 | ``` -------------------------------------------------------------------------------- /internal/data_source_oasis_example_dataset_test.go: -------------------------------------------------------------------------------- 1 | // 2 | // DISCLAIMER 3 | // 4 | // Copyright 2020-2024 ArangoDB GmbH, Cologne, Germany 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | // Copyright holder is ArangoDB GmbH, Cologne, Germany 19 | // 20 | 21 | package provider 22 | 23 | import ( 24 | "testing" 25 | "time" 26 | 27 | "github.com/stretchr/testify/assert" 28 | "google.golang.org/protobuf/types/known/timestamppb" 29 | 30 | example "github.com/arangodb-managed/apis/example/v1" 31 | ) 32 | 33 | func TestFlattenExampleDataset(t *testing.T) { 34 | created := timestamppb.New(time.Date(1980, 03, 03, 1, 1, 1, 0, time.UTC)) 35 | items := &example.ExampleDatasetList{ 36 | Items: []*example.ExampleDataset{ 37 | { 38 | Id: "test-id", 39 | Url: "test-url", 40 | CreatedAt: created, 41 | Guide: "test-guide", 42 | Name: "test-name", 43 | Description: "test-description", 44 | }, 45 | }, 46 | } 47 | expected := map[string]interface{}{ 48 | exampleOrganizationIDFieldName: "", 49 | exampleExampleDatasetsFieldName: []interface{}{ 50 | map[string]interface{}{ 51 | exampleExampleDatasetsIDFieldName: "test-id", 52 | exampleExampleDatasetsNameFieldName: "test-name", 53 | exampleExampleDatasetsDescriptionFieldName: "test-description", 54 | exampleExampleDatasetsGuideFieldName: "test-guide", 55 | exampleExampleDatasetsCreatedAtFieldName: "1980-03-03T01:01:01Z", 56 | }, 57 | }, 58 | } 59 | flattened := flattenExampleDatasets("", items.Items) 60 | assert.Equal(t, expected, flattened) 61 | } 62 | -------------------------------------------------------------------------------- /internal/data_source_backup_test.go: -------------------------------------------------------------------------------- 1 | // 2 | // DISCLAIMER 3 | // 4 | // Copyright 2022-2024 ArangoDB GmbH, Cologne, Germany 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | // Copyright holder is ArangoDB GmbH, Cologne, Germany 19 | // 20 | 21 | package provider 22 | 23 | import ( 24 | "testing" 25 | "time" 26 | 27 | "github.com/stretchr/testify/assert" 28 | "google.golang.org/protobuf/types/known/timestamppb" 29 | 30 | backup "github.com/arangodb-managed/apis/backup/v1" 31 | ) 32 | 33 | // TestFlattenBackupObject tests the Oasis Backup flattening for Terraform schema compatibility. 34 | func TestFlattenBackupObject(t *testing.T) { 35 | createdAtTimeStamp := timestamppb.New(time.Date(2022, 1, 1, 1, 1, 1, 0, time.UTC)) 36 | backup := backup.Backup{ 37 | Id: "test-id", 38 | Url: "https://test.url", 39 | Name: "test-name", 40 | Description: "test-description", 41 | CreatedAt: createdAtTimeStamp, 42 | BackupPolicyId: "test-policy-id", 43 | DeploymentId: "test-dep-id", 44 | RegionId: "gcp-europe-west4", 45 | } 46 | 47 | expected := map[string]interface{}{ 48 | backupDataSourceIdFieldName: "test-id", 49 | backupDataSourceNameFieldName: "test-name", 50 | backupDataSourceDescriptionFieldName: "test-description", 51 | backupDataSourceURLFieldName: "https://test.url", 52 | backupDataSourceCreatedAtFieldName: "2022-01-01T01:01:01Z", 53 | backupDataSourceDeploymentIDFieldName: "test-dep-id", 54 | backupDataSourcePolicyIDFieldName: "test-policy-id", 55 | backupRegionIDFieldName: "gcp-europe-west4", 56 | } 57 | 58 | got := flattenBackupObject(&backup) 59 | assert.Equal(t, expected, got) 60 | } 61 | -------------------------------------------------------------------------------- /examples/resources/oasis_backup_policy/resource.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 0.13.0" 3 | required_providers { 4 | oasis = { 5 | source = "arangodb-managed/oasis" 6 | version = ">=2.1.0" 7 | } 8 | } 9 | } 10 | 11 | provider "oasis" { 12 | api_key_id = "" // API Key ID generated in Oasis platform 13 | api_key_secret = "" // API Key Secret generated in Oasis platform 14 | organization = "" // Your Oasis organization where you want to create the resources 15 | } 16 | 17 | // Terraform created project. 18 | resource "oasis_project" "oasis_test_project" { 19 | name = "Terraform Oasis Project" 20 | description = "A test Oasis project within an organization from the Terraform Provider" 21 | } 22 | 23 | // Example of a oneshard deployment 24 | resource "oasis_deployment" "my_oneshard_deployment" { 25 | terms_and_conditions_accepted = "true" 26 | project = oasis_project.oasis_test_project.id // If set here, overrides project in provider 27 | name = "oasis_test_dep_tf" 28 | location { 29 | region = "gcp-europe-west4" 30 | } 31 | version { 32 | db_version = "3.9.1" 33 | } 34 | security { 35 | disable_foxx_authentication = false 36 | } 37 | configuration { 38 | model = "oneshard" 39 | node_size_id = "c4-a4" 40 | node_disk_size = 20 41 | } 42 | notification_settings { 43 | email_addresses = [ 44 | "test@arangodb.com" 45 | ] 46 | } 47 | } 48 | 49 | // Oasis backup policy. This can have a lot of values and configuration options. 50 | // For details, please consult `terraform providers schema` or the code. 51 | // This resources uses the computed ID of the deployment created above. 52 | resource "oasis_backup_policy" "my_backup_policy" { 53 | name = "Test Policy" 54 | description = "Test Description" 55 | email_notification = "FailureOnly" 56 | deployment_id = oasis_deployment.my_oneshard_deployment.id 57 | retention_period_hour = 120 58 | upload = true 59 | schedule { 60 | type = "Monthly" 61 | monthly { 62 | day_of_month = 12 63 | schedule_at { 64 | hours = 15 65 | minutes = 10 66 | timezone = "UTC" 67 | } 68 | } 69 | } 70 | } -------------------------------------------------------------------------------- /docs/resources/certificate.md: -------------------------------------------------------------------------------- 1 | --- 2 | # generated by https://github.com/hashicorp/terraform-plugin-docs 3 | page_title: "oasis_certificate Resource - terraform-provider-oasis" 4 | subcategory: "" 5 | description: |- 6 | Oasis CA Certificate Resource 7 | --- 8 | 9 | # oasis_certificate (Resource) 10 | 11 | Oasis CA Certificate Resource 12 | 13 | ## Example Usage 14 | 15 | ```terraform 16 | terraform { 17 | required_version = ">= 0.13.0" 18 | required_providers { 19 | oasis = { 20 | source = "arangodb-managed/oasis" 21 | version = ">=2.1.0" 22 | } 23 | } 24 | } 25 | 26 | provider "oasis" { 27 | api_key_id = "" // API Key ID generated in Oasis platform 28 | api_key_secret = "" // API Key Secret generated in Oasis platform 29 | organization = "" // Your Oasis organization where you want to create the resources 30 | } 31 | 32 | // Terraform created project. 33 | resource "oasis_project" "oasis_test_project" { 34 | name = "Terraform Oasis Project" 35 | description = "A test Oasis project within an organization from the Terraform Provider" 36 | } 37 | 38 | // Oasis certificate. This certificate's computed ID will be used in the project above. 39 | resource "oasis_certificate" "my_oasis_cert" { 40 | name = "Terraform certificate" 41 | description = "Certificate description." 42 | project = oasis_project.oasis_test_project.id 43 | } 44 | ``` 45 | 46 | 47 | ## Schema 48 | 49 | ### Required 50 | 51 | - `name` (String) CA Certificate Resource Certificate Name field 52 | 53 | ### Optional 54 | 55 | - `description` (String) CA Certificate Resource Certificate Description field 56 | - `lifetime` (Number) CA Certificate Resource Certificate Lifetime field 57 | - `locked` (Boolean) Ca Certificate Resource Locked Certificate field 58 | - `project` (String) CA Certificate Resource Project Name field 59 | - `use_well_known_certificate` (Boolean) CA Certificate Resource Use Well Known Certificate field 60 | 61 | ### Read-Only 62 | 63 | - `created_at` (String) Ca Certificate Resource Certificate Created At field 64 | - `expires_at` (String) Ca Certificate Resource Certificate Expires At field 65 | - `id` (String) The ID of this resource. 66 | - `is_default` (Boolean) Ca Certificate Resource Is Default Certificate field 67 | 68 | 69 | -------------------------------------------------------------------------------- /docs/resources/ipallowlist.md: -------------------------------------------------------------------------------- 1 | --- 2 | # generated by https://github.com/hashicorp/terraform-plugin-docs 3 | page_title: "oasis_ipallowlist Resource - terraform-provider-oasis" 4 | subcategory: "" 5 | description: |- 6 | Oasis IP Allowlist Resource 7 | --- 8 | 9 | # oasis_ipallowlist (Resource) 10 | 11 | Oasis IP Allowlist Resource 12 | 13 | ## Example Usage 14 | 15 | ```terraform 16 | terraform { 17 | required_version = ">= 0.13.0" 18 | required_providers { 19 | oasis = { 20 | source = "arangodb-managed/oasis" 21 | version = ">=2.1.0" 22 | } 23 | } 24 | } 25 | 26 | provider "oasis" { 27 | api_key_id = "" // API Key ID generated in Oasis platform 28 | api_key_secret = "" // API Key Secret generated in Oasis platform 29 | organization = "" // Your Oasis organization where you want to create the resources 30 | } 31 | 32 | // Terraform created project. 33 | resource "oasis_project" "my_project" { 34 | name = "Terraform Oasis Project" 35 | description = "A test Oasis project within an organization from the Terraform Provider" 36 | } 37 | 38 | // Terraform created ip allowlist. This resource uses the computed ID value of the 39 | // previously defined project resource. 40 | resource "oasis_ipallowlist" "my_iplist" { 41 | name = "Terraform IP Allowlist" 42 | description = "IP Allowlist description" 43 | cidr_ranges = ["1.2.3.4/32", "111.11.0.0/16"] 44 | project = oasis_project.my_project.id 45 | } 46 | ``` 47 | 48 | 49 | ## Schema 50 | 51 | ### Required 52 | 53 | - `cidr_ranges` (List of String) IP Allowlist Resource IP Allowlist IP CIDR Range field 54 | - `name` (String) IP Allowlist Resource IP Allowlist Name field 55 | 56 | ### Optional 57 | 58 | - `description` (String) IP Allowlist Resource IP Allowlist Description field 59 | - `locked` (Boolean) IP Allowlist Resource IP Allowlist Locked field 60 | - `project` (String) IP Allowlist Resource IP Allowlist Project field 61 | - `remote_inspection_allowed` (Boolean) IP Allowlist Resource IP Allowlist Inspection Allowed field 62 | 63 | ### Read-Only 64 | 65 | - `created_at` (String) IP Allowlist Resource IP Allowlist Created At field 66 | - `id` (String) The ID of this resource. 67 | - `is_deleted` (Boolean) IP Allowlist Resource IP Allowlist Is Deleted field 68 | 69 | 70 | -------------------------------------------------------------------------------- /internal/data_source_regions_test.go: -------------------------------------------------------------------------------- 1 | // 2 | // DISCLAIMER 3 | // 4 | // Copyright 2022 ArangoDB GmbH, Cologne, Germany 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | // Copyright holder is ArangoDB GmbH, Cologne, Germany 19 | // 20 | 21 | package provider 22 | 23 | import ( 24 | "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" 25 | "regexp" 26 | "testing" 27 | ) 28 | 29 | func TestAccOasisRegionDataSourceBasic(t *testing.T) { 30 | rxPosNum := regexp.MustCompile("^[1-9][0-9]*$") 31 | 32 | resource.Test(t, resource.TestCase{ 33 | PreCheck: func() { testAccPreCheck(t) }, 34 | ProviderFactories: testProviderFactories, 35 | Steps: []resource.TestStep{ 36 | { 37 | Config: testAccOasisRegionDataSourceConfigBasic(), 38 | Check: resource.ComposeAggregateTestCheckFunc( 39 | resource.TestMatchResourceAttr("data.oasis_region.test_oasis_regions", "regions.#", rxPosNum), 40 | resource.TestCheckResourceAttrSet("data.oasis_region.test_oasis_regions", "regions.0.id"), 41 | resource.TestCheckResourceAttrSet("data.oasis_region.test_oasis_regions", "regions.0.available"), 42 | resource.TestCheckResourceAttrSet("data.oasis_region.test_oasis_regions", "regions.0.location"), 43 | resource.TestCheckResourceAttrSet("data.oasis_region.test_oasis_regions", "regions.0.provider_id"), 44 | ), 45 | }, 46 | }, 47 | }) 48 | } 49 | 50 | func testAccOasisRegionDataSourceConfigBasic() string { 51 | return ` 52 | resource "oasis_organization" "test_organization" { 53 | name = "test" 54 | description = "A test Oasis organization from Terraform Provider" 55 | } 56 | 57 | data "oasis_region" "test_oasis_regions" { 58 | organization = oasis_organization.test_organization.id 59 | provider_id = "aks" 60 | } 61 | ` 62 | } 63 | -------------------------------------------------------------------------------- /examples/resources/oasis_deployment/resource.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 0.13.0" 3 | required_providers { 4 | oasis = { 5 | source = "arangodb-managed/oasis" 6 | version = ">=2.1.8" 7 | } 8 | } 9 | } 10 | 11 | provider "oasis" { 12 | api_key_id = "" // API Key ID generated in Oasis platform 13 | api_key_secret = "" // API Key Secret generated in Oasis platform 14 | organization = "" // Your Oasis organization where you want to create the resources 15 | } 16 | 17 | // Terraform created project. 18 | resource "oasis_project" "oasis_test_project" { 19 | name = "Terraform Oasis Project" 20 | description = "A test Oasis project within an organization from the Terraform Provider" 21 | } 22 | 23 | // Example of a oneshard deployment 24 | resource "oasis_deployment" "my_oneshard_deployment" { 25 | terms_and_conditions_accepted = "true" 26 | project = oasis_project.oasis_test_project.id // Project id where deployment will be created 27 | name = "oasis_test_dep_tf" 28 | 29 | location { 30 | region = "gcp-europe-west4" 31 | } 32 | 33 | configuration { 34 | model = "oneshard" 35 | } 36 | 37 | notification_settings { 38 | email_addresses = [ 39 | "test@arangodb.com" 40 | ] 41 | } 42 | } 43 | 44 | 45 | // Example of a sharded deployment 46 | resource "oasis_deployment" "my_sharded_deployment" { 47 | terms_and_conditions_accepted = "true" 48 | name = "oasis_sharded_dep_tf" 49 | project = oasis_project.oasis_test_project.id // Project id where deployment will be created 50 | location { 51 | region = "gcp-europe-west4" 52 | } 53 | 54 | version { 55 | db_version = "3.9.1" 56 | } 57 | 58 | security { // this section is optional 59 | ca_certificate = "" // If not set, uses default certificate from project (this is here as an empty string for documentation purposes) 60 | ip_allowlist = "" // If not set, no allowlist is configured (this is here as an empty string for documentation purposes) 61 | disable_foxx_authentication = false // If set to true, request to Foxx apps are not authentications. 62 | } 63 | 64 | configuration { 65 | model = "sharded" 66 | node_size_id = "c4-a4" 67 | node_disk_size = 20 68 | node_count = 5 69 | } 70 | } -------------------------------------------------------------------------------- /examples/resources/oasis_deployment/README.md: -------------------------------------------------------------------------------- 1 | # Example: Deployment 2 | 3 | This example shows how to use the Terraform Oasis provider to create an Oasis Deployment. A deployment contains an ArangoDB, configured as you choose. You can have any number of deployments under one project. 4 | 5 | ## Prerequisites 6 | 7 | *This example uses syntax elements specific to Terraform version 0.13+ (tested on Terraform version 1.1.4). 8 | It will not work out-of-the-box with Terraform 0.12.x and lower (deprecated by Terraform).* 9 | 10 | ## Environment variables 11 | Please refer to [Main README](../../README.md) file for all the environment variables you might need. 12 | 13 | ## Instructions on how to run: 14 | ``` 15 | terraform init 16 | terraform plan 17 | terraform apply 18 | ``` 19 | 20 | You can lock a Deployment by specifying the lock as an option in the schema: 21 | ```terraform 22 | resource "oasis_deployment" "my_oneshard_deployment" { 23 | terms_and_conditions_accepted = "true" 24 | project = "" // Project id where deployment will be created 25 | name = "oasis_test_dep_tf" 26 | location { 27 | region = "gcp-europe-west4" 28 | } 29 | version { 30 | db_version = "3.9.1" 31 | } 32 | configuration { 33 | model = "oneshard" 34 | } 35 | notification_settings { 36 | email_addresses = [ 37 | "test@arangodb.com" 38 | ] 39 | } 40 | locked = true 41 | } 42 | ``` 43 | Note: if you run `terraform destroy` while the Deployment is locked, an error is shown, that's because you can't delete a locked Deployment. 44 | To delete it you have to either remove the property or set `locked=false`: 45 | ```terraform 46 | resource "oasis_deployment" "my_oneshard_deployment" { 47 | terms_and_conditions_accepted = "true" 48 | project = "" // Project id where deployment will be created 49 | name = "oasis_test_dep_tf" 50 | location { 51 | region = "gcp-europe-west4" 52 | } 53 | version { 54 | db_version = "3.9.1" 55 | } 56 | configuration { 57 | model = "oneshard" 58 | } 59 | notification_settings { 60 | email_addresses = [ 61 | "test@arangodb.com" 62 | ] 63 | } 64 | locked = false 65 | } 66 | ``` 67 | After running `terraform plan` and then `terraform apply --auto-approve` you update the Deployment to not be locked anymore. This way you can run `terraform destroy` without errors, deleting the Deployment. 68 | 69 | To remove the resources created run: 70 | ``` 71 | terraform destroy 72 | ``` -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | SHELL = bash 2 | PROJECT := terraform-provider-oasis 3 | 4 | COMMIT := $(shell zutano repo build) 5 | VERSION := $(subst v,,$(shell zutano repo version)) 6 | DOCKERIMAGE ?= $(shell zutano docker image --name=$(PROJECT)) 7 | 8 | all: binaries check 9 | 10 | clean: 11 | rm -Rf bin 12 | 13 | binaries: 14 | CGO_ENABLED=0 gox \ 15 | -osarch="linux/amd64 linux/arm linux/arm64 darwin/amd64 darwin/arm64" \ 16 | -ldflags="-X main.projectVersion=${VERSION} -X main.projectBuild=${COMMIT}" \ 17 | -output="bin/{{.OS}}/{{.Arch}}/$(PROJECT)_v$(VERSION)" \ 18 | -tags="netgo" \ 19 | ./... 20 | mkdir -p assets 21 | cd bin/linux/amd64 ; zip -D ../../../assets/$(PROJECT)_$(VERSION)_linux_amd64.zip $(PROJECT)_v$(VERSION) 22 | cd bin/linux/arm64 ; zip -D ../../../assets/$(PROJECT)_$(VERSION)_linux_arm64.zip $(PROJECT)_v$(VERSION) 23 | cd bin/darwin/amd64 ; zip -D ../../../assets/$(PROJECT)_$(VERSION)_darwin_amd64.zip $(PROJECT)_v$(VERSION) 24 | cd bin/darwin/arm64 ; zip -D ../../../assets/$(PROJECT)_$(VERSION)_darwin_arm64.zip $(PROJECT)_v$(VERSION) 25 | cp -f terraform-registry-manifest.json assets/$(PROJECT)_$(VERSION)_manifest.json 26 | cd assets ; shasum -a 256 *.zip *.json > $(PROJECT)_$(VERSION)_SHA256SUMS 27 | 28 | check: 29 | zutano go check ./... 30 | 31 | prepare-release: binaries 32 | PROJECT=$(PROJECT) VERSION=$(VERSION) ./sign.sh 33 | 34 | .PHONY: test 35 | test: 36 | mkdir -p bin/test 37 | go test -coverprofile=bin/test/coverage.out -v ./... | tee bin/test/test-output.txt ; exit "$${PIPESTATUS[0]}" 38 | cat bin/test/test-output.txt | go-junit-report > bin/test/unit-tests.xml 39 | go tool cover -html=bin/test/coverage.out -o bin/test/coverage.html 40 | 41 | .PHONY: test-acc 42 | test-acc: 43 | TF_ACC=1 go test -v ./... 44 | 45 | bootstrap: 46 | GOSUMDB=off GOPROXY=direct GO111MODULE=on go get github.com/arangodb-managed/zutano 47 | go get github.com/mitchellh/gox 48 | go get github.com/jstemmer/go-junit-report 49 | go get github.com/hashicorp/terraform-plugin-sdk/plugin 50 | go get github.com/hashicorp/terraform-plugin-sdk/terraform 51 | 52 | docker: 53 | docker build \ 54 | --build-arg=GOARCH=amd64 \ 55 | -t $(DOCKERIMAGE) . 56 | 57 | docker-push: 58 | docker push $(DOCKERIMAGE) 59 | 60 | .PHONY: update-modules 61 | update-modules: 62 | zutano update-check --quiet --fail 63 | test -f go.mod || go mod init 64 | go get \ 65 | $(shell zutano go mod latest \ 66 | github.com/arangodb-managed/apis \ 67 | ) 68 | go mod tidy 69 | -------------------------------------------------------------------------------- /examples/resources/oasis_backup_policy/README.md: -------------------------------------------------------------------------------- 1 | # Example: Backup Policy 2 | 3 | This example shows how to use the Terraform Oasis provider to create a backup policy for an Oasis Deployment. 4 | 5 | ## Prerequisites 6 | 7 | *This example uses syntax elements specific to Terraform version 0.13+ (tested on Terraform version 1.1.4). 8 | It will not work out-of-the-box with Terraform 0.12.x and lower.* 9 | 10 | ## Environment variables 11 | Please refer to [Main README](../../README.md) file for all the environment variables you might need. 12 | 13 | ## Instructions on how to run: 14 | ``` 15 | terraform init 16 | terraform plan 17 | terraform apply 18 | ``` 19 | 20 | You can lock a Backup Policy by specifying the lock as an option in the schema: 21 | ```terraform 22 | resource "oasis_backup_policy" "my_backup_policy" { 23 | name = "Test Backup Policy" 24 | description = "Test Description" 25 | email_notification = "FailureOnly" 26 | deployment_id = "" // Provide Deployment ID here. 27 | retention_period_hour = 120 28 | upload = true 29 | schedule { 30 | type = "Monthly" 31 | monthly { 32 | day_of_month = 12 33 | schedule_at { 34 | hours = 15 35 | minutes = 10 36 | timezone = "UTC" 37 | } 38 | } 39 | } 40 | locked = true 41 | } 42 | ``` 43 | Note: if you run `terraform destroy` while the Backup Policy is locked, an error is shown, that's because you can't delete a locked Backup Policy. 44 | To delete it you have to either remove the property or set `locked=false`: 45 | ```terraform 46 | resource "oasis_backup_policy" "my_backup_policy" { 47 | name = "Test Backup Policy" 48 | description = "Test Description" 49 | email_notification = "FailureOnly" 50 | deployment_id = "" // Provide Deployment ID here. 51 | retention_period_hour = 120 52 | upload = true 53 | schedule { 54 | type = "Monthly" 55 | monthly { 56 | day_of_month = 12 57 | schedule_at { 58 | hours = 15 59 | minutes = 10 60 | timezone = "UTC" 61 | } 62 | } 63 | } 64 | locked = false 65 | } 66 | ``` 67 | After running `terraform plan` and then `terraform apply --auto-approve` you update the Backup Policy to not be locked anymore. This way you can run `terraform destroy` without errors, deleting the Backup Policy. 68 | 69 | To remove the resources created run: 70 | ``` 71 | terraform destroy 72 | ``` -------------------------------------------------------------------------------- /internal/resource_auditlog_test.go: -------------------------------------------------------------------------------- 1 | // 2 | // DISCLAIMER 3 | // 4 | // Copyright 2022 ArangoDB GmbH, Cologne, Germany 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | // Copyright holder is ArangoDB GmbH, Cologne, Germany 19 | // 20 | 21 | package provider 22 | 23 | import ( 24 | "testing" 25 | 26 | "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" 27 | "github.com/stretchr/testify/assert" 28 | 29 | audit "github.com/arangodb-managed/apis/audit/v1" 30 | ) 31 | 32 | // TestFlattenAuditLog tests the Oasis Audit Log flattening for Terraform schema compatibility. 33 | func TestFlattenAuditLog(t *testing.T) { 34 | auditLog := &audit.AuditLog{ 35 | Name: "test-auditlog", 36 | Description: "test-description", 37 | OrganizationId: "9047335679", 38 | } 39 | 40 | expected := map[string]interface{}{ 41 | auditLogNameFieldName: "test-auditlog", 42 | auditLogDescriptionFieldName: "test-description", 43 | auditLogOrganizationFieldName: "9047335679", 44 | } 45 | 46 | flattened := flattenAuditLogResource(auditLog) 47 | assert.Equal(t, expected, flattened) 48 | } 49 | 50 | // TestExpandAuditLog tests the Oasis AuditLog expansion for Terraform schema compatibility. 51 | func TestExpandAuditLog(t *testing.T) { 52 | raw := map[string]interface{}{ 53 | auditLogNameFieldName: "test-auditlog", 54 | auditLogDescriptionFieldName: "test-description", 55 | auditLogOrganizationFieldName: "9047335679", 56 | } 57 | 58 | expected := &audit.AuditLog{ 59 | Name: "test-auditlog", 60 | Description: "test-description", 61 | OrganizationId: "9047335679", 62 | Destinations: []*audit.AuditLog_Destination{{Type: audit.DestinationCloud}}, 63 | } 64 | 65 | s := resourceAuditLog().Schema 66 | resourceData := schema.TestResourceDataRaw(t, s, raw) 67 | expandedAuditLog, err := expandAuditLogResource(resourceData) 68 | assert.NoError(t, err) 69 | 70 | assert.Equal(t, expected, expandedAuditLog) 71 | } 72 | -------------------------------------------------------------------------------- /internal/data_source_oasis_example_dataset_installation_test.go: -------------------------------------------------------------------------------- 1 | // 2 | // DISCLAIMER 3 | // 4 | // Copyright 2020-2024 ArangoDB GmbH, Cologne, Germany 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | // Copyright holder is ArangoDB GmbH, Cologne, Germany 19 | // 20 | 21 | package provider 22 | 23 | import ( 24 | "testing" 25 | "time" 26 | 27 | "github.com/stretchr/testify/assert" 28 | "google.golang.org/protobuf/types/known/timestamppb" 29 | 30 | example "github.com/arangodb-managed/apis/example/v1" 31 | ) 32 | 33 | func TestFlattenExampleDatasetInstallations(t *testing.T) { 34 | created := timestamppb.New(time.Date(1980, 03, 03, 1, 1, 1, 0, time.UTC)) 35 | items := &example.ExampleDatasetInstallationList{ 36 | Items: []*example.ExampleDatasetInstallation{ 37 | { 38 | Id: "test-id", 39 | Url: "test-url", 40 | DeploymentId: "test-depl-id", 41 | ExampledatasetId: "test-example-id", 42 | CreatedAt: created, 43 | Status: &example.ExampleDatasetInstallation_Status{ 44 | DatabaseName: "test-db", 45 | State: example.ExampleInstallationStatusReady, 46 | IsFailed: false, 47 | IsAvailable: true, 48 | }, 49 | }, 50 | }, 51 | } 52 | expected := map[string]interface{}{ 53 | installationDeploymentIdFieldName: "test-depl-id", 54 | installationItemsFieldName: []interface{}{ 55 | map[string]interface{}{ 56 | installationExampleDatasetIdFieldName: "test-example-id", 57 | installationCreatedAtFieldName: "1980-03-03T01:01:01Z", 58 | installationStatusFieldName: []interface{}{ 59 | map[string]interface{}{ 60 | installationStatusStateFieldName: example.ExampleInstallationStatusReady, 61 | installationStatusIsFailedFieldName: false, 62 | installationStatusIsAvailableFieldName: true, 63 | installationStatusDatabaseNameFieldName: "test-db", 64 | }, 65 | }, 66 | }, 67 | }, 68 | } 69 | flattened := flattenExampleDatasetInstallations("test-depl-id", items.Items) 70 | assert.Equal(t, expected, flattened) 71 | } 72 | -------------------------------------------------------------------------------- /internal/operational_test_resources.go: -------------------------------------------------------------------------------- 1 | // 2 | // DISCLAIMER 3 | // 4 | // Copyright 2020-2022 ArangoDB GmbH, Cologne, Germany 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | // Copyright holder is ArangoDB GmbH, Cologne, Germany 19 | // 20 | 21 | package provider 22 | 23 | import ( 24 | "context" 25 | "fmt" 26 | "os" 27 | 28 | "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" 29 | "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" 30 | 31 | common "github.com/arangodb-managed/apis/common/v1" 32 | rm "github.com/arangodb-managed/apis/resourcemanager/v1" 33 | ) 34 | 35 | // FetchOrganizationID finds and retrieves the first Organization ID it finds for a user. 36 | func FetchOrganizationID() (string, error) { 37 | orgID := os.Getenv("OASIS_TEST_ORGANIZATION_ID") 38 | if orgID == "" { 39 | return "", fmt.Errorf("This test requires an organization id to be set.") 40 | } 41 | return orgID, nil 42 | } 43 | 44 | // FetchProjectID will find the first project given an organization and retrieve its ID. 45 | func FetchProjectID(ctx context.Context, orgID string, testAccProvider *schema.Provider) (string, error) { 46 | // Initialize Client with connection settings 47 | if err := testAccProvider.Configure(ctx, terraform.NewResourceConfigRaw(nil)); err != nil { 48 | return "", fmt.Errorf("terraform config error") 49 | } 50 | client := testAccProvider.Meta().(*Client) 51 | if err := client.Connect(); err != nil { 52 | client.log.Error().Err(err).Msg("Failed to connect to api") 53 | return "", err 54 | } 55 | rmc := rm.NewResourceManagerServiceClient(client.conn) 56 | if projects, err := rmc.ListProjects(client.ctxWithToken, &common.ListOptions{ContextId: orgID}); err != nil { 57 | client.log.Error().Err(err).Str("organization-id", orgID).Msg("Failed to list projects for organization") 58 | return "", err 59 | } else if len(projects.GetItems()) < 1 { 60 | client.log.Error().Err(err).Str("organization-id", orgID).Msg("No projects found") 61 | return "", fmt.Errorf("no projects found") 62 | } else { 63 | return projects.GetItems()[0].GetId(), nil 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /docs/resources/iam_policy.md: -------------------------------------------------------------------------------- 1 | --- 2 | # generated by https://github.com/hashicorp/terraform-plugin-docs 3 | page_title: "oasis_iam_policy Resource - terraform-provider-oasis" 4 | subcategory: "" 5 | description: |- 6 | Oasis IAM Policy Resource 7 | --- 8 | 9 | # oasis_iam_policy (Resource) 10 | 11 | Oasis IAM Policy Resource 12 | 13 | ## Example Usage 14 | 15 | ```terraform 16 | terraform { 17 | required_version = ">= 0.13.0" 18 | required_providers { 19 | oasis = { 20 | source = "arangodb-managed/oasis" 21 | version = ">=2.1.2" 22 | } 23 | } 24 | } 25 | 26 | provider "oasis" { 27 | api_key_id = "" // API Key ID generated in Oasis platform 28 | api_key_secret = "" // API Key Secret generated in Oasis platform 29 | } 30 | 31 | // Terraform created organization 32 | resource "oasis_organization" "oasis_test_organization" { 33 | name = "Terraform Oasis Organization" 34 | description = "A test Oasis organization from Terraform Provider" 35 | } 36 | 37 | // Terraform created IAM Group. This resource uses the computed ID value of the 38 | // previously defined organization resource. 39 | resource "oasis_iam_group" "my_iam_group" { 40 | name = "Terraform IAM Group" 41 | description = "IAM Group created by Terraform" 42 | organization = oasis_organization.oasis_test_organization.id 43 | } 44 | 45 | // Load in an Oasis Current User within an organization 46 | data "oasis_current_user" "oasis_test_current_user" {} 47 | 48 | // Terraform created IAM Policy. This resource uses the computed ID value of the 49 | // previously defined organization resource and IAM group resource. 50 | resource "oasis_iam_policy" "my_iam_policy_group" { 51 | url = "/Organization/${oasis_organization.oasis_test_organization.id}" 52 | 53 | binding { 54 | role = "auditlog-admin" 55 | group = oasis_iam_group.my_iam_group.id 56 | } 57 | 58 | binding { 59 | role = "auditlog-archive-viewer" 60 | group = oasis_iam_group.my_iam_group.id 61 | } 62 | 63 | binding { 64 | role = "auditlog-archive-viewer" 65 | user = data.oasis_current_user.oasis_test_current_user.id 66 | } 67 | } 68 | ``` 69 | 70 | 71 | ## Schema 72 | 73 | ### Required 74 | 75 | - `binding` (Block List, Min: 1) IAM Policy Resource IAM Policy Bindings (see [below for nested schema](#nestedblock--binding)) 76 | - `url` (String) IAM Policy Resource IAM Policy URL 77 | 78 | ### Read-Only 79 | 80 | - `id` (String) The ID of this resource. 81 | 82 | 83 | ### Nested Schema for `binding` 84 | 85 | Required: 86 | 87 | - `role` (String) IAM Policy Resource IAM Policy Role 88 | 89 | Optional: 90 | 91 | - `group` (String) IAM Policy Resource IAM Policy Group 92 | - `user` (String) IAM Policy Resource IAM Policy User 93 | 94 | 95 | -------------------------------------------------------------------------------- /internal/data_source_notebook_model_test.go: -------------------------------------------------------------------------------- 1 | // 2 | // DISCLAIMER 3 | // 4 | // Copyright 2022 ArangoDB GmbH, Cologne, Germany 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | // Copyright holder is ArangoDB GmbH, Cologne, Germany 19 | // 20 | 21 | package provider 22 | 23 | import ( 24 | "testing" 25 | 26 | "github.com/stretchr/testify/assert" 27 | 28 | nb "github.com/arangodb-managed/apis/notebook/v1" 29 | ) 30 | 31 | func TestFlattenNotebookModels(t *testing.T) { 32 | items := &nb.NotebookModelList{ 33 | Items: []*nb.NotebookModel{ 34 | { 35 | Id: "test-id", 36 | Name: "test-name", 37 | Cpu: 2, 38 | Memory: 10, 39 | MaxDiskSize: 20, 40 | MinDiskSize: 10, 41 | }, 42 | }, 43 | } 44 | expected := map[string]interface{}{ 45 | notebookModelDataSourceDeploymentIdFieldName: "test-depl-id", 46 | notebookModelDataSourceItemsFieldName: []interface{}{ 47 | map[string]interface{}{ 48 | notebookModelDataSourceIdFieldName: "test-id", 49 | notebookModelDataSourceNameFieldName: "test-name", 50 | notebookModelDataSourceCPUFieldName: float32(2), 51 | notebookModelDataSourceMemoryFieldName: int32(10), 52 | notebookModelDataSourceMaxDiskSizeFieldName: int32(20), 53 | notebookModelDataSourceMinDiskSizeFieldName: int32(10), 54 | }, 55 | }, 56 | } 57 | flattened := flattenNotebookModels("test-depl-id", items.Items) 58 | assert.Equal(t, expected, flattened) 59 | } 60 | 61 | func TestFlattenNotebookModelList(t *testing.T) { 62 | items := []*nb.NotebookModel{ 63 | { 64 | Id: "test-list-id", 65 | Name: "test-name", 66 | Cpu: 4, 67 | Memory: 10, 68 | MaxDiskSize: 10, 69 | MinDiskSize: 5, 70 | }} 71 | expected := []interface{}{ 72 | map[string]interface{}{ 73 | notebookModelDataSourceIdFieldName: "test-list-id", 74 | notebookModelDataSourceNameFieldName: "test-name", 75 | notebookModelDataSourceCPUFieldName: float32(4), 76 | notebookModelDataSourceMemoryFieldName: int32(10), 77 | notebookModelDataSourceMaxDiskSizeFieldName: int32(10), 78 | notebookModelDataSourceMinDiskSizeFieldName: int32(5), 79 | }, 80 | } 81 | 82 | flattened := flattenNotebookModelList(items) 83 | assert.Equal(t, expected, flattened) 84 | } 85 | -------------------------------------------------------------------------------- /docs/guides/getting-started.md: -------------------------------------------------------------------------------- 1 | --- 2 | page_title: "Getting started with Oasis Terraform Provider" 3 | description: |- 4 | Guide to getting started with the ArangoDB Cloud (Oasis) Terraform Provider 5 | --- 6 | 7 | # Getting started with Oasis Terraform Provider 8 | ArangoGraph Insights Platform (formerly called Oasis), provides ArangoDB databases as a Service (DBaaS). It enables you to use the entire functionality of an ArangoDB deployment without the need to run or manage the system yourself. 9 | 10 | Terraform Provider Oasis is a plugin for Terraform that allows for the full lifecycle management of ArangoGraph Insights Platform resources. 11 | 12 | ## Provider Setup 13 | 14 | 15 | You need to supply proper credentials to the provider before it can be used. API keys serve as the credentials to the provider. You can obtain the keys from the Oasis dashboard. 16 | Log in to the ArangoGraph Insights Platform dashboard and open the [**API Keys**](https://cloud.arangodb.com/dashboard/user/api-keys) tab of your user account. Click the **New API key** button to generate a new key, which can be used with ArangoDB's public API. 17 | 18 | ```hcl 19 | terraform { 20 | required_version = ">= 0.13.0" 21 | required_providers { 22 | oasis = { 23 | source = "arangodb-managed/oasis" 24 | version = ">=2.1.0" 25 | } 26 | } 27 | } 28 | 29 | provider "oasis" { 30 | api_key_id = "" // API Key ID generated in Oasis platform 31 | api_key_secret = "" // API Key Secret generated in Oasis platform 32 | } 33 | ``` 34 | Optionally, you can provide `oasis_endpoint`, `api_port_suffix`, `organization` or `project`. Please refer to the [Setup](setup.md) section for more information. 35 | 36 | ## Example Usage 37 | 38 | Creating your first Deployment: 39 | 40 | ```hcl 41 | # Terraform created organization 42 | resource "oasis_organization" "oasis_test_organization" { 43 | name = "Terraform Oasis Organization" 44 | description = "A test Oasis organization from Terraform Provider" 45 | } 46 | 47 | # Terraform created project. 48 | resource "oasis_project" "oasis_test_project" { 49 | name = "Terraform Oasis Project" 50 | description = "A test Oasis project within an organization from the Terraform Provider" 51 | organization = oasis_organization.oasis_test_organization.id 52 | } 53 | 54 | # Example of a oneshard deployment 55 | resource "oasis_deployment" "my_oneshard_deployment" { 56 | terms_and_conditions_accepted = "true" 57 | project = oasis_project.oasis_test_project.id // Project id where deployment will be created 58 | name = "oasis_test_dep_tf" 59 | 60 | location { 61 | region = "gcp-europe-west4" 62 | } 63 | 64 | configuration { 65 | model = "oneshard" 66 | } 67 | 68 | notification_settings { 69 | email_addresses = [ 70 | "test@arangodb.com" 71 | ] 72 | } 73 | } 74 | ``` -------------------------------------------------------------------------------- /docs/resources/backup.md: -------------------------------------------------------------------------------- 1 | --- 2 | # generated by https://github.com/hashicorp/terraform-plugin-docs 3 | page_title: "oasis_backup Resource - terraform-provider-oasis" 4 | subcategory: "" 5 | description: |- 6 | Oasis Backup Resource 7 | --- 8 | 9 | # oasis_backup (Resource) 10 | 11 | Oasis Backup Resource 12 | 13 | ## Example Usage 14 | 15 | ```terraform 16 | terraform { 17 | required_version = ">= 0.13.0" 18 | required_providers { 19 | oasis = { 20 | source = "arangodb-managed/oasis" 21 | version = ">=2.1.0" 22 | } 23 | } 24 | } 25 | 26 | provider "oasis" { 27 | api_key_id = "" // API Key ID generated in Oasis platform 28 | api_key_secret = "" // API Key Secret generated in Oasis platform 29 | organization = "" // Your Oasis organization where you want to create the resources 30 | } 31 | 32 | // Terraform created project. 33 | resource "oasis_project" "oasis_test_project" { 34 | name = "Terraform Oasis Project" 35 | description = "A test Oasis project within an organization from the Terraform Provider" 36 | } 37 | 38 | // Example of a oneshard deployment 39 | resource "oasis_deployment" "my_oneshard_deployment" { 40 | terms_and_conditions_accepted = "true" 41 | project = oasis_project.oasis_test_project.id // Project id where deployment will be created 42 | name = "oasis_test_dep_tf" 43 | location { 44 | region = "gcp-europe-west4" 45 | } 46 | 47 | configuration { 48 | model = "oneshard" 49 | node_size_id = "c4-a8" 50 | node_disk_size = 20 51 | } 52 | notification_settings { 53 | email_addresses = [ 54 | "test@arangodb.com" 55 | ] 56 | } 57 | } 58 | 59 | // Oasis backup 60 | // This resources uses the computed ID of the deployment created above. 61 | resource "oasis_backup" "my_backup" { 62 | name = "test tf backup" 63 | description = "test backup description from terraform" 64 | deployment_id = oasis_deployment.my_oneshard_deployment.id 65 | upload = true 66 | auto_deleted_at = 3 // auto delete after 3 days 67 | } 68 | ``` 69 | 70 | 71 | ## Schema 72 | 73 | ### Required 74 | 75 | - `deployment_id` (String) Oasis Backup Resource Backup Deployment ID field 76 | - `name` (String) Oasis Backup Resource Backup Name field 77 | 78 | ### Optional 79 | 80 | - `auto_deleted_at` (Number) Oasis Backup Resource Backup Auto Delete At field 81 | - `backup_policy_id` (String) Oasis Backup Resource Backup Policy ID field 82 | - `description` (String) Oasis Backup Resource Backup Description field 83 | - `upload` (Boolean) Oasis Backup Resource Backup Upload field 84 | 85 | ### Read-Only 86 | 87 | - `id` (String) The ID of this resource. 88 | - `region_id` (String) Oasis Backup Resource Region Identifier 89 | - `url` (String) Oasis Backup Resource Backup URL field 90 | 91 | 92 | -------------------------------------------------------------------------------- /templates/guides/getting-started.md.tmpl: -------------------------------------------------------------------------------- 1 | --- 2 | page_title: "Getting started with Oasis Terraform Provider" 3 | description: |- 4 | Guide to getting started with the ArangoDB Cloud (Oasis) Terraform Provider 5 | --- 6 | 7 | # Getting started with Oasis Terraform Provider 8 | ArangoGraph Insights Platform (formerly called Oasis), provides ArangoDB databases as a Service (DBaaS). It enables you to use the entire functionality of an ArangoDB deployment without the need to run or manage the system yourself. 9 | 10 | Terraform Provider Oasis is a plugin for Terraform that allows for the full lifecycle management of ArangoGraph Insights Platform resources. 11 | 12 | ## Provider Setup 13 | 14 | 15 | You need to supply proper credentials to the provider before it can be used. API keys serve as the credentials to the provider. You can obtain the keys from the Oasis dashboard. 16 | Log in to the ArangoGraph Insights Platform dashboard and open the [**API Keys**](https://cloud.arangodb.com/dashboard/user/api-keys) tab of your user account. Click the **New API key** button to generate a new key, which can be used with ArangoDB's public API. 17 | 18 | ```hcl 19 | terraform { 20 | required_version = ">= 0.13.0" 21 | required_providers { 22 | oasis = { 23 | source = "arangodb-managed/oasis" 24 | version = ">=2.1.0" 25 | } 26 | } 27 | } 28 | 29 | provider "oasis" { 30 | api_key_id = "" // API Key ID generated in Oasis platform 31 | api_key_secret = "" // API Key Secret generated in Oasis platform 32 | } 33 | ``` 34 | Optionally, you can provide `oasis_endpoint`, `api_port_suffix`, `organization` or `project`. Please refer to the [Setup](setup.md) section for more information. 35 | 36 | ## Example Usage 37 | 38 | Creating your first Deployment: 39 | 40 | ```hcl 41 | # Terraform created organization 42 | resource "oasis_organization" "oasis_test_organization" { 43 | name = "Terraform Oasis Organization" 44 | description = "A test Oasis organization from Terraform Provider" 45 | } 46 | 47 | # Terraform created project. 48 | resource "oasis_project" "oasis_test_project" { 49 | name = "Terraform Oasis Project" 50 | description = "A test Oasis project within an organization from the Terraform Provider" 51 | organization = oasis_organization.oasis_test_organization.id 52 | } 53 | 54 | # Example of a oneshard deployment 55 | resource "oasis_deployment" "my_oneshard_deployment" { 56 | terms_and_conditions_accepted = "true" 57 | project = oasis_project.oasis_test_project.id // Project id where deployment will be created 58 | name = "oasis_test_dep_tf" 59 | 60 | location { 61 | region = "gcp-europe-west4" 62 | } 63 | 64 | configuration { 65 | model = "oneshard" 66 | } 67 | 68 | notification_settings { 69 | email_addresses = [ 70 | "test@arangodb.com" 71 | ] 72 | } 73 | } 74 | ``` -------------------------------------------------------------------------------- /internal/resource_iam_policy_test.go: -------------------------------------------------------------------------------- 1 | // 2 | // DISCLAIMER 3 | // 4 | // Copyright 2022 ArangoDB GmbH, Cologne, Germany 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | // Copyright holder is ArangoDB GmbH, Cologne, Germany 19 | // 20 | 21 | package provider 22 | 23 | import ( 24 | "fmt" 25 | "testing" 26 | 27 | "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" 28 | "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" 29 | "github.com/stretchr/testify/assert" 30 | 31 | iam "github.com/arangodb-managed/apis/iam/v1" 32 | ) 33 | 34 | // TestFlattenIAMPolicy tests the Oasis IAM Policy flattening for Terraform schema compatibility. 35 | func TestFlattenIAMPolicy(t *testing.T) { 36 | organization := fmt.Sprintf("/Organization/%s", acctest.RandString(10)) 37 | iamPolicy := &iam.Policy{ 38 | ResourceUrl: organization, 39 | Bindings: []*iam.RoleBinding{ 40 | { 41 | RoleId: "test-role", 42 | MemberId: "group:300480957", 43 | }, 44 | }, 45 | } 46 | 47 | expected := map[string]interface{}{ 48 | iamPolicyURLFieldName: organization, 49 | iamPolicyRoleBindingFieldName: []interface{}{ 50 | map[string]interface{}{ 51 | iamPolicyGroupFieldName: "group:300480957", 52 | iamPolicyRoleFieldName: "test-role", 53 | }, 54 | }, 55 | } 56 | 57 | flattened := flattenIAMPolicyResource(iamPolicy) 58 | assert.Equal(t, expected, flattened) 59 | } 60 | 61 | // TestExpandIAMPolicy tests the Oasis IAM Policy expansion for Terraform schema compatibility. 62 | func TestExpandIAMPolicy(t *testing.T) { 63 | organization := fmt.Sprintf("/Organization/%s", acctest.RandString(10)) 64 | raw := map[string]interface{}{ 65 | iamPolicyURLFieldName: organization, 66 | iamPolicyRoleBindingFieldName: []interface{}{ 67 | map[string]interface{}{ 68 | iamPolicyRoleFieldName: "test-role", 69 | iamPolicyGroupFieldName: "321370957", 70 | }, 71 | }} 72 | 73 | expected := &iam.RoleBindingsRequest{ 74 | ResourceUrl: organization, 75 | Bindings: []*iam.RoleBinding{ 76 | { 77 | RoleId: "test-role", 78 | MemberId: "group:321370957", 79 | }, 80 | }, 81 | } 82 | 83 | s := resourceIAMPolicy().Schema 84 | resourceData := schema.TestResourceDataRaw(t, s, raw) 85 | expandedIAMPolicy, err := expandToIAMPolicy(resourceData) 86 | assert.NoError(t, err) 87 | 88 | assert.Equal(t, expected, expandedIAMPolicy) 89 | } 90 | -------------------------------------------------------------------------------- /internal/resource_example_dataset_installation_test.go: -------------------------------------------------------------------------------- 1 | // 2 | // DISCLAIMER 3 | // 4 | // Copyright 2020-2024 ArangoDB GmbH, Cologne, Germany 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | // Copyright holder is ArangoDB GmbH, Cologne, Germany 19 | // 20 | 21 | package provider 22 | 23 | import ( 24 | "testing" 25 | "time" 26 | 27 | "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" 28 | "github.com/stretchr/testify/assert" 29 | "google.golang.org/protobuf/types/known/timestamppb" 30 | 31 | example "github.com/arangodb-managed/apis/example/v1" 32 | ) 33 | 34 | func TestFlattenExampleDatasetInstallation(t *testing.T) { 35 | created := timestamppb.New(time.Date(1980, 03, 03, 1, 1, 1, 0, time.UTC)) 36 | testInt := &example.ExampleDatasetInstallation{ 37 | Id: "test-id", 38 | Url: "test-url", 39 | DeploymentId: "test-depl-id", 40 | ExampledatasetId: "test-example-id", 41 | CreatedAt: created, 42 | Status: &example.ExampleDatasetInstallation_Status{ 43 | DatabaseName: "test-db", 44 | State: example.ExampleInstallationStatusReady, 45 | IsFailed: false, 46 | IsAvailable: true, 47 | }, 48 | } 49 | expected := map[string]interface{}{ 50 | datasetDeploymentIdFieldName: "test-depl-id", 51 | datasetExampleDatasetIdFieldName: "test-example-id", 52 | datasetCreatedAtFieldName: "1980-03-03T01:01:01Z", 53 | datasetStatusFieldName: []interface{}{ 54 | map[string]interface{}{ 55 | datasetStatusStateFieldName: example.ExampleInstallationStatusReady, 56 | datasetStatusIsFailedFieldName: false, 57 | datasetStatusIsAvailableFieldName: true, 58 | datasetStatusDatabaseNameFieldName: "test-db", 59 | }, 60 | }, 61 | } 62 | flattened := flattenExampleDatasetInstallation(testInt) 63 | assert.Equal(t, expected, flattened) 64 | } 65 | 66 | func TestExpandExampleDatasetInstallation(t *testing.T) { 67 | raw := map[string]interface{}{ 68 | datasetDeploymentIdFieldName: "test-depl-id", 69 | datasetExampleDatasetIdFieldName: "test-example-id", 70 | } 71 | s := resourceExampleDatasetInstallation().Schema 72 | data := schema.TestResourceDataRaw(t, s, raw) 73 | expanded := expandExampleDatasetInstallation(data) 74 | assert.Equal(t, raw[datasetDeploymentIdFieldName], expanded.DeploymentId) 75 | assert.Equal(t, raw[datasetExampleDatasetIdFieldName], expanded.ExampledatasetId) 76 | } 77 | -------------------------------------------------------------------------------- /examples/resources/oasis_private_endpoint/resource.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 0.13.0" 3 | required_providers { 4 | oasis = { 5 | source = "arangodb-managed/oasis" 6 | version = ">=2.1.1" 7 | } 8 | } 9 | } 10 | 11 | provider "oasis" { 12 | api_key_id = "" // API Key ID generated in Oasis platform 13 | api_key_secret = "" // API Key Secret generated in Oasis platform 14 | organization = "" 15 | } 16 | 17 | // Terraform created project 18 | resource "oasis_project" "oasis_test_project" { 19 | name = "Terraform Oasis Project" 20 | description = "A test Oasis project within an organization from the Terraform Provider" 21 | } 22 | 23 | // Example of a oneshard deployment 24 | resource "oasis_deployment" "my_aks_oneshard_deployment" { 25 | terms_and_conditions_accepted = "true" 26 | project = oasis_project.oasis_test_project.id // Project id where deployment will be created 27 | name = "oasis_test_aks_dep_tf" 28 | 29 | location { 30 | region = "aks-westus2" 31 | } 32 | 33 | configuration { 34 | model = "oneshard" 35 | } 36 | 37 | notification_settings { 38 | email_addresses = [ 39 | "test@arangodb.com" 40 | ] 41 | } 42 | } 43 | 44 | // Example of an AKS Private Endpoint 45 | resource "oasis_private_endpoint" "my_aks_private_endpoint" { 46 | name = "tf-private-endpoint-test" 47 | description = "Terraform generated AKS private endpoint" 48 | deployment = oasis_deployment.my_aks_oneshard_deployment.id 49 | dns_names = ["test.example.com", "test2.example.com"] 50 | aks { 51 | az_client_subscription_ids = ["291bba3f-e0a5-47bc-a099-3bdcb2a50a05"] 52 | } 53 | } 54 | 55 | // Example of an AWS oneshard deployment 56 | resource "oasis_deployment" "my_aws_oneshard_deployment" { 57 | terms_and_conditions_accepted = "true" 58 | project = oasis_project.oasis_test_project.id // Project id where deployment will be created 59 | name = "oasis_test_aws_dep_tf" 60 | 61 | location { 62 | region = "aws-us-east-2" 63 | } 64 | 65 | configuration { 66 | model = "oneshard" 67 | } 68 | 69 | notification_settings { 70 | email_addresses = [ 71 | "test@arangodb.com" 72 | ] 73 | } 74 | } 75 | 76 | // Example of an AWS Private Endpoint 77 | resource "oasis_private_endpoint" "my_aws_private_endpoint" { 78 | name = "tf-private-endpoint-test" 79 | description = "Terraform generated AWS private endpoint" 80 | deployment = oasis_deployment.my_aws_oneshard_deployment.id 81 | dns_names = ["test.example.com", "test2.example.com"] 82 | aws { 83 | principal { 84 | account_id = "123123123123" // 12 digit AWS Account Identifier 85 | user_names = ["test@arangodb.com"] // User names (IAM User(s) that are able to setup the private endpoint) 86 | role_names = ["test"] // Role names (IAM role(s) that are able to setup the endpoint) 87 | } 88 | } 89 | } -------------------------------------------------------------------------------- /internal/data_source_oasis_terms_and_conditions_test.go: -------------------------------------------------------------------------------- 1 | // 2 | // DISCLAIMER 3 | // 4 | // Copyright 2020-2024 ArangoDB GmbH, Cologne, Germany 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | // Copyright holder is ArangoDB GmbH, Cologne, Germany 19 | // 20 | 21 | package provider 22 | 23 | import ( 24 | "fmt" 25 | "os" 26 | "testing" 27 | "time" 28 | 29 | "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" 30 | "github.com/stretchr/testify/assert" 31 | "google.golang.org/protobuf/types/known/timestamppb" 32 | 33 | rm "github.com/arangodb-managed/apis/resourcemanager/v1" 34 | ) 35 | 36 | func TestOasisTermsAndConditionsDataSource_Basic(t *testing.T) { 37 | if _, ok := os.LookupEnv("TF_ACC"); !ok { 38 | t.Skip() 39 | } 40 | if _, ok := os.LookupEnv("TF_OASIS_TERMS_AND_CONDITIONS"); !ok { 41 | t.Skip() 42 | } 43 | tAndCID := os.Getenv("TF_OASIS_TERMS_AND_CONDITIONS") 44 | resource.ParallelTest(t, resource.TestCase{ 45 | PreCheck: func() { testTAndCAccDataSourcePreCheck(t) }, 46 | ProviderFactories: testProviderFactories, 47 | Steps: []resource.TestStep{ 48 | { 49 | Config: testBasicOasisTandCDataSourceConfig(tAndCID), 50 | Check: resource.ComposeTestCheckFunc( 51 | resource.TestCheckResourceAttrSet("data.oasis_terms_and_conditions.test_t_and_c", tcIDFieldName), 52 | resource.TestCheckResourceAttrSet("data.oasis_terms_and_conditions.test_t_and_c", tcContentFieldName), 53 | resource.TestCheckResourceAttrSet("data.oasis_terms_and_conditions.test_t_and_c", tcCreatedAtFieldName), 54 | resource.TestCheckResourceAttrSet("data.oasis_terms_and_conditions.test_t_and_c", tcOrganizationFieldName), 55 | ), 56 | }, 57 | }, 58 | }) 59 | } 60 | 61 | func TestFlattenTAndCDataSource(t *testing.T) { 62 | createdAtTimeStamp := timestamppb.New(time.Date(1980, 1, 1, 1, 1, 1, 0, time.UTC)) 63 | term := rm.TermsAndConditions{ 64 | Id: "test-id", 65 | Content: "Content", 66 | CreatedAt: createdAtTimeStamp, 67 | } 68 | expected := map[string]interface{}{ 69 | tcIDFieldName: "test-id", 70 | tcCreatedAtFieldName: "1980-01-01T01:01:01Z", 71 | tcContentFieldName: "Content", 72 | } 73 | got := flattenTCObject(&term) 74 | assert.Equal(t, expected, got) 75 | } 76 | 77 | func testTAndCAccDataSourcePreCheck(t *testing.T) { 78 | if v := os.Getenv("OASIS_API_KEY_ID"); v == "" { 79 | t.Fatal("the test needs a test account key to run") 80 | } 81 | } 82 | 83 | func testBasicOasisTandCDataSourceConfig(pid string) string { 84 | return fmt.Sprintf(`data "oasis_terms_and_conditions" "test_t_and_c" { 85 | id = "%s" 86 | }`, pid) 87 | } 88 | -------------------------------------------------------------------------------- /internal/data_source_current_user.go: -------------------------------------------------------------------------------- 1 | // 2 | // DISCLAIMER 3 | // 4 | // Copyright 2022 ArangoDB GmbH, Cologne, Germany 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | // Copyright holder is ArangoDB GmbH, Cologne, Germany 19 | // 20 | 21 | package provider 22 | 23 | import ( 24 | "context" 25 | 26 | "github.com/hashicorp/terraform-plugin-sdk/v2/diag" 27 | "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" 28 | 29 | common "github.com/arangodb-managed/apis/common/v1" 30 | iam "github.com/arangodb-managed/apis/iam/v1" 31 | ) 32 | 33 | const ( 34 | // current user source fields 35 | userIdFieldName = "id" 36 | userEmailFieldName = "email" 37 | userNameFieldName = "name" 38 | ) 39 | 40 | // dataSourceOasisCurrentUser defines a Current User datasource terraform type. 41 | func dataSourceOasisCurrentUser() *schema.Resource { 42 | return &schema.Resource{ 43 | Description: "Oasis Current User Data Source", 44 | ReadContext: dataSourceOasisCurrentUserRead, 45 | 46 | Schema: map[string]*schema.Schema{ 47 | userIdFieldName: { 48 | Type: schema.TypeString, 49 | Description: "Current User Data Source User ID field", 50 | Optional: true, 51 | }, 52 | userEmailFieldName: { 53 | Type: schema.TypeString, 54 | Description: "Current User Data Source Email field", 55 | Optional: true, 56 | }, 57 | userNameFieldName: { 58 | Type: schema.TypeString, 59 | Description: "Current User Data Source Name field", 60 | Optional: true, 61 | }, 62 | }, 63 | } 64 | } 65 | 66 | // dataSourceOasisCurrentUserRead reloads the resource object from the terraform store. 67 | func dataSourceOasisCurrentUserRead(ctx context.Context, data *schema.ResourceData, m interface{}) diag.Diagnostics { 68 | client := m.(*Client) 69 | if err := client.Connect(); err != nil { 70 | client.log.Error().Err(err).Msg("Failed to connect to api") 71 | return diag.FromErr(err) 72 | } 73 | 74 | iamc := iam.NewIAMServiceClient(client.conn) 75 | user, err := iamc.GetThisUser(client.ctxWithToken, &common.Empty{}) 76 | if err != nil { 77 | return diag.FromErr(err) 78 | } 79 | 80 | for k, v := range flattenCurrentUserObject(user) { 81 | if err := data.Set(k, v); err != nil { 82 | return diag.FromErr(err) 83 | } 84 | } 85 | data.SetId(user.GetId()) 86 | return nil 87 | } 88 | 89 | // flattenCurrentUserObject creates a map from an Oasis Current User for easy digestion by the terraform schema. 90 | func flattenCurrentUserObject(user *iam.User) map[string]interface{} { 91 | return map[string]interface{}{ 92 | userIdFieldName: user.GetId(), 93 | userEmailFieldName: user.GetEmail(), 94 | userNameFieldName: user.GetName(), 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /internal/client.go: -------------------------------------------------------------------------------- 1 | // 2 | // DISCLAIMER 3 | // 4 | // Copyright 2020-2023 ArangoDB GmbH, Cologne, Germany 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | // Copyright holder is ArangoDB GmbH, Cologne, Germany 19 | // 20 | 21 | package provider 22 | 23 | import ( 24 | "context" 25 | "crypto/tls" 26 | 27 | "github.com/rs/zerolog" 28 | "google.golang.org/grpc" 29 | "google.golang.org/grpc/credentials" 30 | 31 | "github.com/arangodb-managed/apis/common/auth" 32 | commonGrpc "github.com/arangodb-managed/apis/common/v1/grpc" 33 | iam "github.com/arangodb-managed/apis/iam/v1" 34 | lh "github.com/arangodb-managed/log-helper" 35 | ) 36 | 37 | // Client is responsible for connecting to the Arango Graph API 38 | type Client struct { 39 | ApiKeyID string 40 | ApiKeySecret string 41 | ApiEndpoint string 42 | ApiPortSuffix string 43 | ProjectID string 44 | OrganizationID string 45 | ctxWithToken context.Context 46 | conn *grpc.ClientConn 47 | log zerolog.Logger 48 | } 49 | 50 | // Connect connects to Arango Graph API 51 | func (c *Client) Connect() error { 52 | ctx := context.Background() 53 | c.log = lh.MustNew(lh.DefaultConfig()) 54 | 55 | var err error 56 | c.conn, err = c.mustDialAPI() 57 | if err != nil { 58 | return err 59 | } 60 | 61 | token, err := c.getToken(ctx, c.ApiKeyID, c.ApiKeySecret) 62 | if err != nil { 63 | c.log.Error().Err(err).Msg("Could not get Auth Token") 64 | return err 65 | } 66 | // Add Access Token 67 | ctxWithToken := auth.WithAccessToken(ctx, token) 68 | // Add the User Agent as well 69 | ua := commonGrpc.CreateUserAgent("terraform-provider-oasis", currentVersion) 70 | c.ctxWithToken = commonGrpc.WithUserAgent(ctxWithToken, ua) 71 | return nil 72 | } 73 | 74 | // mustDialAPI dials the Arango Graph API 75 | func (c *Client) mustDialAPI() (*grpc.ClientConn, error) { 76 | // Set up a connection to the server. 77 | tc := credentials.NewTLS(&tls.Config{}) 78 | conn, err := grpc.Dial(c.ApiEndpoint+c.ApiPortSuffix, grpc.WithTransportCredentials(tc)) 79 | if err != nil { 80 | c.log.Error().Err(err).Msg("Failed to connect to Arango Graph API") 81 | return nil, err 82 | } 83 | return conn, nil 84 | } 85 | 86 | func (c *Client) getToken(ctx context.Context, apiKeyID, apiKeySecret string) (string, error) { 87 | 88 | iamc := iam.NewIAMServiceClient(c.conn) 89 | 90 | resp, err := iamc.AuthenticateAPIKey(ctx, &iam.AuthenticateAPIKeyRequest{ 91 | Id: apiKeyID, 92 | Secret: apiKeySecret, 93 | }) 94 | if err != nil { 95 | c.log.Error().Err(err).Msg("Authentication failed") 96 | return "", err 97 | } 98 | c.log.Print("Retrieved Auth token successfully.") 99 | return resp.GetToken(), nil 100 | } 101 | -------------------------------------------------------------------------------- /internal/data_source_oasis_project_test.go: -------------------------------------------------------------------------------- 1 | // 2 | // DISCLAIMER 3 | // 4 | // Copyright 2020-2024 ArangoDB GmbH, Cologne, Germany 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | // Copyright holder is ArangoDB GmbH, Cologne, Germany 19 | // 20 | 21 | package provider 22 | 23 | import ( 24 | "context" 25 | "fmt" 26 | "os" 27 | "testing" 28 | "time" 29 | 30 | "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" 31 | "github.com/stretchr/testify/assert" 32 | "github.com/stretchr/testify/require" 33 | "google.golang.org/protobuf/types/known/timestamppb" 34 | 35 | rm "github.com/arangodb-managed/apis/resourcemanager/v1" 36 | ) 37 | 38 | func TestOasisProjectDataSource_Basic(t *testing.T) { 39 | if _, ok := os.LookupEnv("TF_ACC"); !ok { 40 | t.Skip() 41 | } 42 | orgID, err := FetchOrganizationID() 43 | require.NoError(t, err) 44 | pid, err := FetchProjectID(context.Background(), orgID, testAccProvider) 45 | if err != nil { 46 | t.Fatal(err) 47 | } 48 | resource.ParallelTest(t, resource.TestCase{ 49 | PreCheck: func() { testProjectAccDataSourcePreCheck(t) }, 50 | ProviderFactories: testProviderFactories, 51 | Steps: []resource.TestStep{ 52 | { 53 | Config: testBasicOasisProjectDataSourceConfig(pid), 54 | Check: resource.ComposeTestCheckFunc( 55 | resource.TestCheckResourceAttrSet("data.oasis_project.test", projIdFieldName), 56 | resource.TestCheckResourceAttrSet("data.oasis_project.test", projNameFieldName), 57 | resource.TestCheckResourceAttrSet("data.oasis_project.test", projCreatedAtFieldName), 58 | resource.TestCheckResourceAttrSet("data.oasis_project.test", projUrlFieldName), 59 | ), 60 | }, 61 | }, 62 | }) 63 | } 64 | 65 | func testProjectAccDataSourcePreCheck(t *testing.T) { 66 | if v := os.Getenv("OASIS_API_KEY_ID"); v == "" { 67 | t.Fatal("the test needs a test account key to run") 68 | } 69 | } 70 | 71 | func TestFlattenProjectDataSource(t *testing.T) { 72 | createdAtTimeStamp := timestamppb.New(time.Date(1980, 1, 1, 1, 1, 1, 0, time.UTC)) 73 | proj := rm.Project{ 74 | Id: "test-id", 75 | Url: "https://test.url", 76 | Name: "test-name", 77 | Description: "test-description", 78 | OrganizationId: "org-id", 79 | CreatedAt: createdAtTimeStamp, 80 | } 81 | expected := map[string]interface{}{ 82 | projIdFieldName: "test-id", 83 | projNameFieldName: "test-name", 84 | projDescriptionFieldName: "test-description", 85 | projUrlFieldName: "https://test.url", 86 | projCreatedAtFieldName: "1980-01-01T01:01:01Z", 87 | } 88 | got := flattenProjectObject(&proj) 89 | assert.Equal(t, expected, got) 90 | } 91 | 92 | func testBasicOasisProjectDataSourceConfig(pid string) string { 93 | return fmt.Sprintf(`data "oasis_project" "test" { 94 | id = "%s" 95 | }`, pid) 96 | } 97 | -------------------------------------------------------------------------------- /docs/resources/multi_region_backup.md: -------------------------------------------------------------------------------- 1 | --- 2 | # generated by https://github.com/hashicorp/terraform-plugin-docs 3 | page_title: "oasis_multi_region_backup Resource - terraform-provider-oasis" 4 | subcategory: "" 5 | description: |- 6 | Oasis Multi Region Backup Resource 7 | --- 8 | 9 | # oasis_multi_region_backup (Resource) 10 | 11 | Oasis Multi Region Backup Resource 12 | 13 | ## Example Usage 14 | 15 | ```terraform 16 | terraform { 17 | required_version = ">= 0.13.0" 18 | required_providers { 19 | oasis = { 20 | source = "arangodb-managed/oasis" 21 | version = ">=2.1.6" 22 | } 23 | } 24 | } 25 | 26 | provider "oasis" { 27 | api_key_id = "" // API Key ID generated in Oasis platform 28 | api_key_secret = "" // API Key Secret generated in Oasis platform 29 | organization = "" // Your Oasis organization where you want to create the resources 30 | } 31 | 32 | // Create Project 33 | resource "oasis_project" "oasis_test_project" { 34 | name = "Terraform Oasis Project" 35 | description = "A test Oasis project within an organization from the Terraform Provider" 36 | } 37 | 38 | // Create Deployment 39 | resource "oasis_deployment" "my_oneshard_deployment" { 40 | terms_and_conditions_accepted = "true" 41 | project = oasis_project.oasis_test_project.id // Project id where deployment will be created 42 | name = "oasis_multi_region_deployment" 43 | location { 44 | region = "gcp-europe-west4" 45 | } 46 | security { 47 | disable_foxx_authentication = false 48 | } 49 | disk_performance = "dp30" 50 | configuration { 51 | model = "oneshard" 52 | node_size_id = "c4-a8" 53 | node_disk_size = 20 54 | maximum_node_disk_size = 40 55 | } 56 | notification_settings { 57 | email_addresses = [ 58 | "test@arangodb.com" 59 | ] 60 | } 61 | } 62 | 63 | // Create Backup 64 | resource "oasis_backup" "backup" { 65 | name = "oasis_backup" 66 | description = "test backup description update from terraform" 67 | deployment_id = oasis_deployment.my_oneshard_deployment.id 68 | upload = true 69 | auto_deleted_at = 3 // auto delete after 3 days 70 | } 71 | 72 | // Create Multi Region Backup 73 | resource "oasis_multi_region_backup" "backup" { 74 | source_backup_id = oasis_backup.backup.id // Existing backup ID 75 | region_id = "gcp-us-central1" // Oasis region identifier, which is other than the deployment region 76 | } 77 | ``` 78 | 79 | 80 | ## Schema 81 | 82 | ### Optional 83 | 84 | - `region_id` (String) Oasis Multi Region Backup Resource Region Identifier 85 | - `source_backup_id` (String) Oasis Multi Region Backup Resource Region Identifier 86 | 87 | ### Read-Only 88 | 89 | - `auto_deleted_at` (Number) Oasis Multi Region Backup Resource Backup Auto Delete At field, generated based on source backup 90 | - `backup_policy_id` (String) Oasis Multi Region Backup Resource Backup Policy ID field, generated based on source backup 91 | - `deployment_id` (String) Oasis Multi Region Backup Resource Backup Deployment ID field, generated based on source backup 92 | - `description` (String) Oasis Multi Region Backup Resource Backup Description field, generated based on source backup 93 | - `id` (String) The ID of this resource. 94 | - `name` (String) Oasis Multi Region Backup Resource Backup Name field, generated based on source backup 95 | - `upload` (Boolean) Oasis Multi Region Backup Resource Backup Upload field, generated based on source backup 96 | - `url` (String) Oasis Multi Region Backup Resource Backup URL field, generated based on source backup 97 | 98 | 99 | -------------------------------------------------------------------------------- /internal/data_source_oasis_project.go: -------------------------------------------------------------------------------- 1 | // 2 | // DISCLAIMER 3 | // 4 | // Copyright 2020-2024 ArangoDB GmbH, Cologne, Germany 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | // Copyright holder is ArangoDB GmbH, Cologne, Germany 19 | // 20 | 21 | package provider 22 | 23 | import ( 24 | "context" 25 | "time" 26 | 27 | "github.com/hashicorp/terraform-plugin-sdk/v2/diag" 28 | "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" 29 | 30 | common "github.com/arangodb-managed/apis/common/v1" 31 | rm "github.com/arangodb-managed/apis/resourcemanager/v1" 32 | ) 33 | 34 | const ( 35 | // project data source fields 36 | projIdFieldName = "id" 37 | projNameFieldName = "name" 38 | projDescriptionFieldName = "description" 39 | projUrlFieldName = "url" 40 | projCreatedAtFieldName = "created_at" 41 | ) 42 | 43 | // dataSourceOasisProject defines a Project datasource terraform type. 44 | func dataSourceOasisProject() *schema.Resource { 45 | return &schema.Resource{ 46 | Description: "Oasis Project Data Source", 47 | ReadContext: dataSourceOasisProjectRead, 48 | 49 | Schema: map[string]*schema.Schema{ 50 | projIdFieldName: { 51 | Type: schema.TypeString, 52 | Description: "Project Data Source Project ID field", 53 | Required: true, 54 | }, 55 | projNameFieldName: { 56 | Type: schema.TypeString, 57 | Description: "Project Data Source Project Name field", 58 | Optional: true, 59 | }, 60 | projDescriptionFieldName: { 61 | Type: schema.TypeString, 62 | Description: "Project Data Source Project Description field", 63 | Optional: true, 64 | }, 65 | projUrlFieldName: { 66 | Type: schema.TypeString, 67 | Description: "Project Data Source Project URL field", 68 | Computed: true, 69 | }, 70 | projCreatedAtFieldName: { 71 | Type: schema.TypeString, 72 | Description: "Project Data Source Project Created At field", 73 | Computed: true, 74 | }, 75 | }, 76 | } 77 | } 78 | 79 | // dataSourceOasisProjectRead reloads the resource object from the terraform store. 80 | func dataSourceOasisProjectRead(ctx context.Context, data *schema.ResourceData, m interface{}) diag.Diagnostics { 81 | client := m.(*Client) 82 | if err := client.Connect(); err != nil { 83 | client.log.Error().Err(err).Msg("Failed to connect to api") 84 | return diag.FromErr(err) 85 | } 86 | 87 | rmc := rm.NewResourceManagerServiceClient(client.conn) 88 | pid := data.Get(projIdFieldName).(string) 89 | proj, err := rmc.GetProject(client.ctxWithToken, &common.IDOptions{Id: pid}) 90 | if err != nil { 91 | return diag.FromErr(err) 92 | } 93 | 94 | for k, v := range flattenProjectObject(proj) { 95 | if err := data.Set(k, v); err != nil { 96 | return diag.FromErr(err) 97 | } 98 | } 99 | data.SetId(proj.GetId()) 100 | return nil 101 | } 102 | 103 | // flattenProjectObject creates a map from an Oasis Project for easy digestion by the terraform schema. 104 | func flattenProjectObject(proj *rm.Project) map[string]interface{} { 105 | return map[string]interface{}{ 106 | projIdFieldName: proj.GetId(), 107 | projNameFieldName: proj.GetName(), 108 | projDescriptionFieldName: proj.GetDescription(), 109 | projUrlFieldName: proj.GetUrl(), 110 | projCreatedAtFieldName: proj.GetCreatedAt().AsTime().Format(time.RFC3339Nano), 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /internal/data_source_oasis_organization_test.go: -------------------------------------------------------------------------------- 1 | // 2 | // DISCLAIMER 3 | // 4 | // Copyright 2020-2024 ArangoDB GmbH, Cologne, Germany 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | // Copyright holder is ArangoDB GmbH, Cologne, Germany 19 | // 20 | 21 | package provider 22 | 23 | import ( 24 | "fmt" 25 | "os" 26 | "testing" 27 | "time" 28 | 29 | "google.golang.org/protobuf/types/known/timestamppb" 30 | 31 | "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" 32 | "github.com/stretchr/testify/assert" 33 | 34 | rm "github.com/arangodb-managed/apis/resourcemanager/v1" 35 | ) 36 | 37 | func TestOasisOrganizationDataSource_Basic(t *testing.T) { 38 | if _, ok := os.LookupEnv("TF_ACC"); !ok { 39 | t.Skip() 40 | } 41 | organizationID, err := FetchOrganizationID() 42 | if err != nil { 43 | t.Fatal(err) 44 | } 45 | resource.ParallelTest(t, resource.TestCase{ 46 | PreCheck: func() { testOrgAccDataSourcePreCheck(t) }, 47 | ProviderFactories: testProviderFactories, 48 | Steps: []resource.TestStep{ 49 | { 50 | Config: testBasicOasisOrganizationDataSourceConfig(organizationID), 51 | Check: resource.ComposeTestCheckFunc( 52 | resource.TestCheckResourceAttrSet("data.oasis_organization.test", orgIdFieldName), 53 | resource.TestCheckResourceAttrSet("data.oasis_organization.test", orgNameFieldName), 54 | resource.TestCheckResourceAttrSet("data.oasis_organization.test", orgCreatedAtFieldName), 55 | resource.TestCheckResourceAttrSet("data.oasis_organization.test", orgUrlFieldName), 56 | ), 57 | }, 58 | }, 59 | }) 60 | } 61 | 62 | func testOrgAccDataSourcePreCheck(t *testing.T) { 63 | if v := os.Getenv("OASIS_API_KEY_ID"); v == "" { 64 | t.Fatal("the test needs a test account key to run") 65 | } 66 | } 67 | 68 | func TestFlattenOrganizationDataSource(t *testing.T) { 69 | createdAtTimeStamp := timestamppb.New(time.Date(1980, 1, 1, 1, 1, 1, 0, time.UTC)) 70 | org := rm.Organization{ 71 | Id: "test-id", 72 | Url: "https://test.url", 73 | Name: "test-name", 74 | Description: "test-description", 75 | CreatedAt: createdAtTimeStamp, 76 | Tier: &rm.Tier{ 77 | Id: "free", 78 | Name: "Free to try", 79 | HasSupportPlans: true, 80 | HasBackupUploads: true, 81 | RequiresTermsAndConditions: true, 82 | }, 83 | } 84 | flattenedTier := flattenTierObject(org.Tier) 85 | expected := map[string]interface{}{ 86 | orgIdFieldName: "test-id", 87 | orgNameFieldName: "test-name", 88 | orgDescriptionFieldName: "test-description", 89 | orgUrlFieldName: "https://test.url", 90 | orgCreatedAtFieldName: "1980-01-01T01:01:01Z", 91 | tierFieldName: flattenedTier, 92 | } 93 | got := flattenOrganizationObject(&org) 94 | assert.Equal(t, expected[orgIdFieldName], got[orgIdFieldName]) 95 | assert.Equal(t, expected[orgNameFieldName], got[orgNameFieldName]) 96 | assert.Equal(t, expected[orgDescriptionFieldName], got[orgDescriptionFieldName]) 97 | assert.Equal(t, expected[orgUrlFieldName], got[orgUrlFieldName]) 98 | assert.Equal(t, expected[orgCreatedAtFieldName], got[orgCreatedAtFieldName]) 99 | assert.True(t, flattenedTier.Equal(got[tierFieldName])) 100 | 101 | } 102 | 103 | func testBasicOasisOrganizationDataSourceConfig(id string) string { 104 | return fmt.Sprintf(`data "oasis_organization" "test" { 105 | id = "%s" 106 | }`, id) 107 | } 108 | -------------------------------------------------------------------------------- /.circleci/config.yml: -------------------------------------------------------------------------------- 1 | version: 2.1 2 | executors: 3 | go-executor: 4 | docker: 5 | - image: arangodboasis/golang-ci:latest 6 | jobs: 7 | build: 8 | parameters: 9 | update_modules: 10 | type: boolean 11 | default: false 12 | executor: go-executor 13 | steps: 14 | - checkout 15 | - setup_remote_docker 16 | - run: cp go.sum go.sum.orig 17 | - restore_cache: 18 | keys: 19 | - go-mod-v1-{{ checksum "go.sum.orig" }} 20 | - when: 21 | condition: <> 22 | steps: 23 | - run: | 24 | make update-modules 25 | - run: | 26 | make all 27 | - run: | 28 | make test 29 | - store_test_results: 30 | path: bin/test/ 31 | - store_artifacts: # upload test summary for display in Artifacts 32 | path: bin/test/ 33 | destination: raw-test-output 34 | - save_cache: 35 | key: go-mod-v1-{{ checksum "go.sum.orig" }} 36 | paths: 37 | - "/go/pkg/mod" 38 | 39 | deploy-release: 40 | executor: go-executor 41 | steps: 42 | - checkout 43 | - setup_remote_docker 44 | - run: cp go.sum go.sum.orig 45 | - restore_cache: 46 | keys: 47 | - go-mod-v1-{{ checksum "go.sum.orig" }} 48 | - run: | 49 | make all prepare-release 50 | - run: 51 | name: "Publish Release on GitHub" 52 | command: | 53 | github-release release --user ${CIRCLE_PROJECT_USERNAME} --repo ${CIRCLE_PROJECT_REPONAME} --tag ${CIRCLE_TAG} 54 | sleep 10 55 | github-release upload --user ${CIRCLE_PROJECT_USERNAME} --repo ${CIRCLE_PROJECT_REPONAME} --tag ${CIRCLE_TAG} --name terraform-provider-oasis_${CIRCLE_TAG:1}_darwin_amd64.zip --file ./assets/terraform-provider-oasis_${CIRCLE_TAG:1}_darwin_amd64.zip 56 | github-release upload --user ${CIRCLE_PROJECT_USERNAME} --repo ${CIRCLE_PROJECT_REPONAME} --tag ${CIRCLE_TAG} --name terraform-provider-oasis_${CIRCLE_TAG:1}_darwin_arm64.zip --file ./assets/terraform-provider-oasis_${CIRCLE_TAG:1}_darwin_arm64.zip 57 | github-release upload --user ${CIRCLE_PROJECT_USERNAME} --repo ${CIRCLE_PROJECT_REPONAME} --tag ${CIRCLE_TAG} --name terraform-provider-oasis_${CIRCLE_TAG:1}_linux_amd64.zip --file ./assets/terraform-provider-oasis_${CIRCLE_TAG:1}_linux_amd64.zip 58 | github-release upload --user ${CIRCLE_PROJECT_USERNAME} --repo ${CIRCLE_PROJECT_REPONAME} --tag ${CIRCLE_TAG} --name terraform-provider-oasis_${CIRCLE_TAG:1}_linux_arm64.zip --file ./assets/terraform-provider-oasis_${CIRCLE_TAG:1}_linux_arm64.zip 59 | github-release upload --user ${CIRCLE_PROJECT_USERNAME} --repo ${CIRCLE_PROJECT_REPONAME} --tag ${CIRCLE_TAG} --name terraform-provider-oasis_${CIRCLE_TAG:1}_SHA256SUMS --file ./assets/terraform-provider-oasis_${CIRCLE_TAG:1}_SHA256SUMS 60 | github-release upload --user ${CIRCLE_PROJECT_USERNAME} --repo ${CIRCLE_PROJECT_REPONAME} --tag ${CIRCLE_TAG} --name terraform-provider-oasis_${CIRCLE_TAG:1}_SHA256SUMS.sig --file ./assets/terraform-provider-oasis_${CIRCLE_TAG:1}_SHA256SUMS.sig 61 | github-release upload --user ${CIRCLE_PROJECT_USERNAME} --repo ${CIRCLE_PROJECT_REPONAME} --tag ${CIRCLE_TAG} --name terraform-provider-oasis_${CIRCLE_TAG:1}_manifest.json --file ./terraform-registry-manifest.json 62 | 63 | workflows: 64 | version: 2 65 | build_test_store_artifacts: 66 | jobs: 67 | - build: 68 | context: agrelease 69 | filters: 70 | tags: 71 | only: /.*/ 72 | - deploy-release: 73 | context: agrelease 74 | requires: 75 | - build 76 | filters: 77 | branches: 78 | ignore: /.*/ 79 | tags: 80 | only: /^v.*/ 81 | nightly: 82 | triggers: 83 | - schedule: 84 | cron: "30 3 * * *" # format: -- so every day at 03:30 85 | filters: 86 | branches: 87 | only: master 88 | jobs: 89 | - build: 90 | context: agrelease 91 | update_modules: true -------------------------------------------------------------------------------- /internal/data_source_oasis_terms_and_conditions.go: -------------------------------------------------------------------------------- 1 | // 2 | // DISCLAIMER 3 | // 4 | // Copyright 2020-2024 ArangoDB GmbH, Cologne, Germany 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | // Copyright holder is ArangoDB GmbH, Cologne, Germany 19 | // 20 | 21 | package provider 22 | 23 | import ( 24 | "context" 25 | "time" 26 | 27 | "github.com/hashicorp/terraform-plugin-sdk/v2/diag" 28 | "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" 29 | 30 | common "github.com/arangodb-managed/apis/common/v1" 31 | rm "github.com/arangodb-managed/apis/resourcemanager/v1" 32 | ) 33 | 34 | const ( 35 | // t&c data source fields 36 | tcIDFieldName = "id" 37 | tcCreatedAtFieldName = "created_at" 38 | tcContentFieldName = "content" 39 | tcOrganizationFieldName = "organization" 40 | ) 41 | 42 | // dataSourceTermsAndConditions defines a T&C datasource terraform type. 43 | func dataSourceTermsAndConditions() *schema.Resource { 44 | return &schema.Resource{ 45 | Description: "Terms and Conditions Data Source", 46 | ReadContext: dataSourceTermsAndConditionsRead, 47 | 48 | Schema: map[string]*schema.Schema{ 49 | tcIDFieldName: { 50 | Type: schema.TypeString, 51 | Description: "Terms and Conditions Data Source ID field", 52 | Optional: true, 53 | }, 54 | tcContentFieldName: { 55 | Type: schema.TypeString, 56 | Description: "Terms and Conditions Data Source Content field", 57 | Computed: true, 58 | }, 59 | tcCreatedAtFieldName: { 60 | Type: schema.TypeString, 61 | Description: "Terms and Conditions Data Source Created At field", 62 | Computed: true, 63 | }, 64 | tcOrganizationFieldName: { 65 | Type: schema.TypeString, 66 | Description: "Terms and Conditions Data Source Organization field", 67 | Optional: true, // if given, overwrites the plugin level organization 68 | }, 69 | }, 70 | } 71 | } 72 | 73 | // dataSourceTermsAndConditionsRead reloads the resource object from the terraform store. 74 | func dataSourceTermsAndConditionsRead(ctx context.Context, data *schema.ResourceData, m interface{}) diag.Diagnostics { 75 | client := m.(*Client) 76 | if err := client.Connect(); err != nil { 77 | client.log.Error().Err(err).Msg("Failed to connect to api") 78 | return diag.FromErr(err) 79 | } 80 | 81 | rmc := rm.NewResourceManagerServiceClient(client.conn) 82 | var ( 83 | tc *rm.TermsAndConditions 84 | err error 85 | ) 86 | if v, ok := data.GetOk(tcIDFieldName); ok { 87 | tc, err = rmc.GetTermsAndConditions(client.ctxWithToken, &common.IDOptions{Id: v.(string)}) 88 | if err != nil { 89 | return diag.FromErr(err) 90 | } 91 | } else { 92 | var orgID string 93 | if v, ok := data.GetOk(tcOrganizationFieldName); ok { 94 | orgID = v.(string) 95 | } 96 | tc, err = rmc.GetCurrentTermsAndConditions(client.ctxWithToken, &common.IDOptions{Id: orgID}) 97 | if err != nil { 98 | return diag.FromErr(err) 99 | } 100 | } 101 | 102 | for k, v := range flattenTCObject(tc) { 103 | if err := data.Set(k, v); err != nil { 104 | return diag.FromErr(err) 105 | } 106 | } 107 | data.SetId(tc.GetId()) 108 | return nil 109 | } 110 | 111 | // flattenTCObject creates a map from an Oasis Terms and Condition object for easy digestion by the terraform. 112 | func flattenTCObject(tc *rm.TermsAndConditions) map[string]interface{} { 113 | return map[string]interface{}{ 114 | tcIDFieldName: tc.GetId(), 115 | tcCreatedAtFieldName: tc.GetCreatedAt().AsTime().Format(time.RFC3339Nano), 116 | tcContentFieldName: tc.GetContent(), 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /docs/resources/notebook.md: -------------------------------------------------------------------------------- 1 | --- 2 | # generated by https://github.com/hashicorp/terraform-plugin-docs 3 | page_title: "oasis_notebook Resource - terraform-provider-oasis" 4 | subcategory: "" 5 | description: |- 6 | Oasis Notebook Resource 7 | --- 8 | 9 | # oasis_notebook (Resource) 10 | 11 | Oasis Notebook Resource 12 | 13 | ## Example Usage 14 | 15 | ```terraform 16 | terraform { 17 | required_version = ">= 0.13.0" 18 | required_providers { 19 | oasis = { 20 | source = "arangodb-managed/oasis" 21 | version = ">=2.1.7" 22 | } 23 | } 24 | } 25 | 26 | provider "oasis" { 27 | api_key_id = "" // API Key ID generated in Oasis platform 28 | api_key_secret = "" // API Key Secret generated in Oasis platform 29 | } 30 | 31 | // Create Project 32 | resource "oasis_project" "oasis_test_project" { 33 | name = "Terraform Oasis Project" 34 | description = "A test Oasis project within an organization from the Terraform Provider" 35 | } 36 | 37 | // Create Deployment 38 | resource "oasis_deployment" "my_oneshard_deployment" { 39 | terms_and_conditions_accepted = "true" 40 | project = oasis_project.oasis_test_project.id // Project id where deployment will be created 41 | name = "oasis_jupyter_notebook_deployment" 42 | location { 43 | region = "gcp-europe-west4" 44 | } 45 | security { 46 | disable_foxx_authentication = false 47 | } 48 | disk_performance = "dp30" 49 | configuration { 50 | model = "oneshard" 51 | node_size_id = "c4-a8" 52 | node_disk_size = 20 53 | maximum_node_disk_size = 40 54 | } 55 | notification_settings { 56 | email_addresses = [ 57 | "test@arangodb.com" 58 | ] 59 | } 60 | } 61 | 62 | // Create Notebook 63 | resource "oasis_notebook" "oasis_test_notebook" { 64 | deployment_id = oasis_deployment.my_oneshard_deployment.id 65 | name = "Test Oasis Jupyter Notebook" 66 | description = "Test Description" 67 | model { 68 | notebook_model_id = "basic" 69 | disk_size = "10" 70 | } 71 | } 72 | ``` 73 | 74 | 75 | ## Schema 76 | 77 | ### Required 78 | 79 | - `deployment_id` (String) Notebook Resource Notebook Deployment ID field 80 | - `model` (Block List, Min: 1, Max: 1) Notebook Resource Notebook Model field (see [below for nested schema](#nestedblock--model)) 81 | - `name` (String) Notebook Resource Notebook Name field 82 | 83 | ### Optional 84 | 85 | - `description` (String) Notebook Resource Notebook Description field 86 | - `url` (String) Notebook Resource Notebook URL field 87 | 88 | ### Read-Only 89 | 90 | - `created_at` (String) Notebook Resource Notebook Created At field 91 | - `created_by_id` (String) Notebook Resource Notebook Created By Id field 92 | - `deleted_at` (String) Notebook Resource Notebook Deleted At field 93 | - `id` (String) The ID of this resource. 94 | - `is_deleted` (Boolean) Notebook Resource Notebook Is Deleted field 95 | - `is_paused` (Boolean) Notebook Resource Notebook Is Paused field 96 | - `last_paused_at` (String) Notebook Resource Notebook Last Paused field 97 | - `last_resumed_at` (String) Notebook Resource Notebook Last Resumed field 98 | - `status` (List of Object) Notebook Resource Notebook Status field (see [below for nested schema](#nestedatt--status)) 99 | 100 | 101 | ### Nested Schema for `model` 102 | 103 | Required: 104 | 105 | - `disk_size` (Number) Notebook Resource Notebook Model Disk Size field 106 | - `notebook_model_id` (String) Notebook Resource Notebook Model ID field 107 | 108 | 109 | 110 | ### Nested Schema for `status` 111 | 112 | Read-Only: 113 | 114 | - `endpoint` (String) 115 | - `last_updated_at` (String) 116 | - `message` (String) 117 | - `phase` (String) 118 | - `usage` (List of Object) (see [below for nested schema](#nestedobjatt--status--usage)) 119 | 120 | 121 | ### Nested Schema for `status.usage` 122 | 123 | Read-Only: 124 | 125 | - `last_cpu_limit` (Number) 126 | - `last_cpu_usage` (Number) 127 | - `last_memory_limit` (Number) 128 | - `last_memory_usage` (Number) 129 | 130 | 131 | -------------------------------------------------------------------------------- /internal/data_source_cloud_providers.go: -------------------------------------------------------------------------------- 1 | // 2 | // DISCLAIMER 3 | // 4 | // Copyright 2022 ArangoDB GmbH, Cologne, Germany 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | // Copyright holder is ArangoDB GmbH, Cologne, Germany 19 | // 20 | 21 | package provider 22 | 23 | import ( 24 | "context" 25 | "crypto/sha256" 26 | "fmt" 27 | 28 | "github.com/hashicorp/terraform-plugin-sdk/v2/diag" 29 | "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" 30 | 31 | common "github.com/arangodb-managed/apis/common/v1" 32 | platform "github.com/arangodb-managed/apis/platform/v1" 33 | ) 34 | 35 | const ( 36 | // provider data source fields 37 | providerIdFieldName = "id" 38 | providerNameFieldName = "name" 39 | providerOrganizationFieldName = "organization" 40 | providerProvidersFieldName = "providers" 41 | ) 42 | 43 | // dataSourceOasisCloudProvider defines a Cloud Provider datasource terraform type. 44 | func dataSourceOasisCloudProvider() *schema.Resource { 45 | return &schema.Resource{ 46 | Description: "Oasis Cloud Providers Data Source", 47 | 48 | ReadContext: dataSourceOasisCloudProviderRead, 49 | 50 | Schema: map[string]*schema.Schema{ 51 | providerOrganizationFieldName: { 52 | Type: schema.TypeString, 53 | Description: "Cloud Provider Data Source Organization ID field", 54 | Required: true, 55 | }, 56 | providerProvidersFieldName: { 57 | Type: schema.TypeList, 58 | Description: "List of all supported cloud providers in Oasis.", 59 | Computed: true, 60 | Elem: &schema.Resource{ 61 | Schema: map[string]*schema.Schema{ 62 | providerIdFieldName: { 63 | Type: schema.TypeString, 64 | Description: "Cloud Provider ID field", 65 | Computed: true, 66 | }, 67 | providerNameFieldName: { 68 | Type: schema.TypeString, 69 | Description: "Cloud Provider Name field", 70 | Computed: true, 71 | }, 72 | }, 73 | }, 74 | }, 75 | }, 76 | } 77 | } 78 | 79 | // dataSourceOasisCloudProviderRead reloads the resource object from the terraform store. 80 | func dataSourceOasisCloudProviderRead(ctx context.Context, data *schema.ResourceData, m interface{}) diag.Diagnostics { 81 | client := m.(*Client) 82 | if err := client.Connect(); err != nil { 83 | client.log.Error().Err(err).Msg("Failed to connect to api") 84 | return diag.FromErr(err) 85 | } 86 | 87 | platformc := platform.NewPlatformServiceClient(client.conn) 88 | organizationId := data.Get(providerOrganizationFieldName).(string) 89 | providersRaw, err := platformc.ListProviders(client.ctxWithToken, &platform.ListProvidersRequest{OrganizationId: organizationId, Options: &common.ListOptions{}}) 90 | if err != nil { 91 | return diag.FromErr(err) 92 | } 93 | 94 | providers := make([]*platform.Provider, len(providersRaw.Items)) 95 | 96 | providerItems := flattenCloudProviders(providersRaw.Items) 97 | err = data.Set(providerProvidersFieldName, providerItems) 98 | if err != nil { 99 | return diag.FromErr(err) 100 | } 101 | 102 | idsum := sha256.New() 103 | for _, v := range providers { 104 | _, err := idsum.Write([]byte(v.GetId())) 105 | if err != nil { 106 | return diag.FromErr(err) 107 | } 108 | } 109 | id := fmt.Sprintf("%x", idsum.Sum(nil)) 110 | data.SetId(id) 111 | 112 | return nil 113 | } 114 | 115 | // flattenCloudProviders takes result of datasets and converts them into a Terraform consumable format. 116 | func flattenCloudProviders(providers []*platform.Provider) []interface{} { 117 | if providers != nil { 118 | flattened := make([]interface{}, len(providers)) 119 | 120 | for i, providerItem := range providers { 121 | platformSubItems := make(map[string]interface{}) 122 | 123 | platformSubItems["id"] = providerItem.GetId() 124 | platformSubItems["name"] = providerItem.GetName() 125 | 126 | flattened[i] = platformSubItems 127 | } 128 | 129 | return flattened 130 | } 131 | 132 | return make([]interface{}, 0) 133 | } 134 | -------------------------------------------------------------------------------- /internal/resource_multi_region_backup_test.go: -------------------------------------------------------------------------------- 1 | // 2 | // DISCLAIMER 3 | // 4 | // Copyright 2022 ArangoDB GmbH, Cologne, Germany 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | // Copyright holder is ArangoDB GmbH, Cologne, Germany 19 | // 20 | 21 | package provider 22 | 23 | import ( 24 | "context" 25 | "fmt" 26 | "os" 27 | "regexp" 28 | "testing" 29 | 30 | backup "github.com/arangodb-managed/apis/backup/v1" 31 | common "github.com/arangodb-managed/apis/common/v1" 32 | "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" 33 | "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" 34 | "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" 35 | "github.com/stretchr/testify/require" 36 | ) 37 | 38 | // TestAccResourceMultiRegionBackup verifies the Oasis Multi Region Backup resource is created along with the specified properties 39 | func TestAccResourceMultiRegionBackup(t *testing.T) { 40 | if _, ok := os.LookupEnv("TF_ACC"); !ok { 41 | t.Skip() 42 | } 43 | t.Parallel() 44 | 45 | resourceName := "terraform-multi-region-backup-" + acctest.RandString(10) 46 | regionID := "gcp-us-central1" 47 | 48 | orgID, err := FetchOrganizationID() 49 | require.NoError(t, err) 50 | projectID, err := FetchProjectID(context.Background(), orgID, testAccProvider) 51 | require.NoError(t, err) 52 | 53 | resource.Test(t, resource.TestCase{ 54 | PreCheck: func() { testAccPreCheck(t) }, 55 | ProviderFactories: testProviderFactories, 56 | CheckDestroy: testAccCheckDestroyMultiRegionBackup, 57 | Steps: []resource.TestStep{ 58 | { 59 | Config: testMultiRegionBackupConfig(projectID, resourceName, ""), 60 | ExpectError: regexp.MustCompile("unable to find parse field region_id"), 61 | }, 62 | { 63 | Config: testMultiRegionBackupConfig(projectID, resourceName, regionID), 64 | Check: resource.ComposeTestCheckFunc( 65 | resource.TestCheckResourceAttr("oasis_deployment.my_oneshard_deployment", deplNameFieldName, "oasis_multi_region_deployment"), 66 | resource.TestCheckResourceAttr("oasis_backup.backup", backupNameFieldName, "oasis_backup"), 67 | resource.TestCheckResourceAttr("oasis_multi_region_backup."+resourceName, backupRegionIDFieldName, regionID), 68 | ), 69 | }, 70 | }, 71 | }) 72 | } 73 | 74 | // testMultiRegionBackupConfig contains the Terraform resource definitions for testing usage 75 | func testMultiRegionBackupConfig(project, backupResource, regionID string) string { 76 | return fmt.Sprintf(` 77 | resource "oasis_deployment" "my_oneshard_deployment" { 78 | terms_and_conditions_accepted = "true" 79 | project = "%s" 80 | name = "oasis_multi_region_deployment" 81 | location { 82 | region = "gcp-europe-west4" 83 | } 84 | security { 85 | disable_foxx_authentication = false 86 | } 87 | disk_performance = "dp30" 88 | configuration { 89 | model = "oneshard" 90 | node_size_id = "c4-a8" 91 | node_disk_size = 20 92 | maximum_node_disk_size = 40 93 | } 94 | notification_settings { 95 | email_addresses = [ 96 | "test@arangodb.com" 97 | ] 98 | } 99 | } 100 | 101 | resource "oasis_backup" "backup" { 102 | name = "oasis_backup" 103 | description = "test backup description update from terraform" 104 | deployment_id = oasis_deployment.my_oneshard_deployment.id 105 | upload = true 106 | auto_deleted_at = 20 107 | } 108 | 109 | resource "oasis_multi_region_backup" "%s" { 110 | source_backup_id = oasis_backup.backup.id 111 | region_id = "%s" 112 | } 113 | `, project, backupResource, regionID) 114 | } 115 | 116 | // testAccCheckDestroyMultiRegionBackup verifies the Terraform oasis_multi_region_backup resource cleanup. 117 | func testAccCheckDestroyMultiRegionBackup(s *terraform.State) error { 118 | client := testAccProvider.Meta().(*Client) 119 | if err := client.Connect(); err != nil { 120 | client.log.Error().Err(err).Msg("Failed to connect to api") 121 | return err 122 | } 123 | backupc := backup.NewBackupServiceClient(client.conn) 124 | 125 | for _, rs := range s.RootModule().Resources { 126 | if rs.Type != "oasis_multi_region_backup" { 127 | continue 128 | } 129 | 130 | if _, err := backupc.GetBackup(client.ctxWithToken, &common.IDOptions{Id: rs.Primary.ID}); !common.IsNotFound(err) { 131 | return fmt.Errorf("backup still present") 132 | } 133 | } 134 | 135 | return nil 136 | } 137 | -------------------------------------------------------------------------------- /internal/data_source_backup.go: -------------------------------------------------------------------------------- 1 | // 2 | // DISCLAIMER 3 | // 4 | // Copyright 2022-2024 ArangoDB GmbH, Cologne, Germany 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | // Copyright holder is ArangoDB GmbH, Cologne, Germany 19 | // 20 | 21 | package provider 22 | 23 | import ( 24 | "context" 25 | "time" 26 | 27 | "github.com/hashicorp/terraform-plugin-sdk/v2/diag" 28 | "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" 29 | 30 | backup "github.com/arangodb-managed/apis/backup/v1" 31 | common "github.com/arangodb-managed/apis/common/v1" 32 | ) 33 | 34 | const ( 35 | // Backup data source field names 36 | backupDataSourceIdFieldName = "id" 37 | backupDataSourceNameFieldName = "name" 38 | backupDataSourceDescriptionFieldName = "description" 39 | backupDataSourceURLFieldName = "url" 40 | backupDataSourcePolicyIDFieldName = "backup_policy_id" 41 | backupDataSourceDeploymentIDFieldName = "deployment_id" 42 | backupDataSourceCreatedAtFieldName = "created_at" 43 | ) 44 | 45 | // dataSourceOasisBackup defines a Backup datasource terraform type. 46 | func dataSourceOasisBackup() *schema.Resource { 47 | return &schema.Resource{ 48 | Description: "Oasis Backup Data Source", 49 | 50 | ReadContext: dataSourceOasisBackupRead, 51 | 52 | Schema: map[string]*schema.Schema{ 53 | backupDataSourceIdFieldName: { 54 | Type: schema.TypeString, 55 | Description: "Backup Data Source ID field", 56 | Required: true, 57 | }, 58 | backupDataSourceNameFieldName: { 59 | Type: schema.TypeString, 60 | Description: "Backup Data Source Name field", 61 | Optional: true, 62 | }, 63 | backupDataSourceDescriptionFieldName: { 64 | Type: schema.TypeString, 65 | Description: "Backup Data Source Description field", 66 | Optional: true, 67 | }, 68 | backupDataSourceURLFieldName: { 69 | Type: schema.TypeString, 70 | Description: "Backup Data Source URL field", 71 | Optional: true, 72 | }, 73 | backupDataSourcePolicyIDFieldName: { 74 | Type: schema.TypeString, 75 | Description: "Backup Data Source Policy ID field", 76 | Optional: true, 77 | }, 78 | backupDataSourceDeploymentIDFieldName: { 79 | Type: schema.TypeString, 80 | Description: "Backup Sata Source Deployment ID field", 81 | Optional: true, 82 | }, 83 | backupDataSourceCreatedAtFieldName: { 84 | Type: schema.TypeString, 85 | Description: "Backup Sata Source Created At field", 86 | Computed: true, 87 | }, 88 | }, 89 | } 90 | } 91 | 92 | // dataSourceOasisBackupRead reloads the resource object from the Terraform store. 93 | func dataSourceOasisBackupRead(ctx context.Context, data *schema.ResourceData, m interface{}) diag.Diagnostics { 94 | client := m.(*Client) 95 | if err := client.Connect(); err != nil { 96 | client.log.Error().Err(err).Msg("Failed to connect to api") 97 | return diag.FromErr(err) 98 | } 99 | 100 | backupc := backup.NewBackupServiceClient(client.conn) 101 | bid := data.Get(backupDataSourceIdFieldName).(string) 102 | backup, err := backupc.GetBackup(client.ctxWithToken, &common.IDOptions{Id: bid}) 103 | if err != nil || backup == nil { 104 | client.log.Error().Err(err).Str("backup-id", data.Id()).Msg("Failed to find backup") 105 | data.SetId("") 106 | return diag.FromErr(err) 107 | } 108 | 109 | for k, v := range flattenBackupObject(backup) { 110 | if err := data.Set(k, v); err != nil { 111 | return diag.FromErr(err) 112 | } 113 | } 114 | 115 | data.SetId(backup.GetId()) 116 | return nil 117 | } 118 | 119 | // flattenBackupObject creates a map from an Oasis Backup for easy digestion by the Terraform schema. 120 | func flattenBackupObject(backup *backup.Backup) map[string]interface{} { 121 | return map[string]interface{}{ 122 | backupDataSourceIdFieldName: backup.GetId(), 123 | backupDataSourceNameFieldName: backup.GetName(), 124 | backupDataSourceDescriptionFieldName: backup.GetDescription(), 125 | backupDataSourceURLFieldName: backup.GetUrl(), 126 | backupDataSourcePolicyIDFieldName: backup.GetBackupPolicyId(), 127 | backupDataSourceDeploymentIDFieldName: backup.GetDeploymentId(), 128 | backupDataSourceCreatedAtFieldName: backup.GetCreatedAt().AsTime().Format(time.RFC3339Nano), 129 | backupRegionIDFieldName: backup.GetRegionId(), 130 | } 131 | } 132 | -------------------------------------------------------------------------------- /internal/resource_iam_group_test.go: -------------------------------------------------------------------------------- 1 | // 2 | // DISCLAIMER 3 | // 4 | // Copyright 2022 ArangoDB GmbH, Cologne, Germany 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | // Copyright holder is ArangoDB GmbH, Cologne, Germany 19 | // 20 | 21 | package provider 22 | 23 | import ( 24 | "fmt" 25 | "os" 26 | "regexp" 27 | "testing" 28 | 29 | "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" 30 | "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" 31 | "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" 32 | "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" 33 | "github.com/stretchr/testify/assert" 34 | "github.com/stretchr/testify/require" 35 | 36 | common "github.com/arangodb-managed/apis/common/v1" 37 | iam "github.com/arangodb-managed/apis/iam/v1" 38 | ) 39 | 40 | // TestAccResourceIAMGroup verifies the Oasis IAM Group resource is created along with the specified properties. 41 | func TestAccResourceIAMGroup(t *testing.T) { 42 | if _, ok := os.LookupEnv("TF_ACC"); !ok { 43 | t.Skip() 44 | } 45 | t.Parallel() 46 | 47 | orgID, err := FetchOrganizationID() 48 | require.NoError(t, err) 49 | 50 | name := acctest.RandString(5) 51 | 52 | resource.Test(t, resource.TestCase{ 53 | PreCheck: func() { testAccPreCheck(t) }, 54 | ProviderFactories: testProviderFactories, 55 | CheckDestroy: testAccCheckDestroyIAMGroup, 56 | Steps: []resource.TestStep{ 57 | { 58 | Config: testIAMGroupConfig("", name), 59 | ExpectError: regexp.MustCompile("failed to parse field organization"), 60 | }, 61 | { 62 | Config: testIAMGroupConfig(orgID, name), 63 | Check: resource.ComposeTestCheckFunc( 64 | resource.TestCheckResourceAttr("oasis_iam_group.oasis_iam_group_test", iamGroupOrganizationFieldName, orgID), 65 | resource.TestCheckResourceAttr("oasis_iam_group.oasis_iam_group_test", iamGroupNameFieldName, name), 66 | ), 67 | }, 68 | }, 69 | }) 70 | } 71 | 72 | // testAccCheckDestroyIAMGroup verifies the Terraform oasis_iam_group resource cleanup. 73 | func testAccCheckDestroyIAMGroup(s *terraform.State) error { 74 | client := testAccProvider.Meta().(*Client) 75 | if err := client.Connect(); err != nil { 76 | client.log.Error().Err(err).Msg("Failed to connect to api") 77 | return err 78 | } 79 | iamc := iam.NewIAMServiceClient(client.conn) 80 | 81 | for _, rs := range s.RootModule().Resources { 82 | if rs.Type != "oasis_iam_group" { 83 | continue 84 | } 85 | 86 | if _, err := iamc.GetGroup(client.ctxWithToken, &common.IDOptions{Id: rs.Primary.ID}); err == nil { 87 | return fmt.Errorf("iam group still present") 88 | } 89 | } 90 | 91 | return nil 92 | } 93 | 94 | // TestFlattenIAMGroup tests the Oasis IAM Group flattening for Terraform schema compatibility. 95 | func TestFlattenIAMGroup(t *testing.T) { 96 | organizationId := acctest.RandString(10) 97 | iamGroup := &iam.Group{ 98 | Name: "test-iam-group", 99 | Description: "test-description", 100 | OrganizationId: organizationId, 101 | } 102 | 103 | expected := map[string]interface{}{ 104 | iamGroupNameFieldName: "test-iam-group", 105 | iamGroupDescriptionFieldName: "test-description", 106 | iamGroupOrganizationFieldName: organizationId, 107 | } 108 | 109 | flattened := flattenIAMGroupResource(iamGroup) 110 | assert.Equal(t, expected, flattened) 111 | } 112 | 113 | // TestExpandIAMGroup tests the Oasis IAM Group expansion for Terraform schema compatibility. 114 | func TestExpandIAMGroup(t *testing.T) { 115 | organizationId := acctest.RandString(10) 116 | raw := map[string]interface{}{ 117 | iamGroupNameFieldName: "test-iam-group", 118 | iamGroupDescriptionFieldName: "test-description", 119 | iamGroupOrganizationFieldName: organizationId, 120 | } 121 | expected := &iam.Group{ 122 | Name: "test-iam-group", 123 | Description: "test-description", 124 | OrganizationId: organizationId, 125 | } 126 | 127 | s := resourceIAMGroup().Schema 128 | resourceData := schema.TestResourceDataRaw(t, s, raw) 129 | expandedOrganization, err := expandToIAMGroup(resourceData) 130 | assert.NoError(t, err) 131 | 132 | assert.Equal(t, expected, expandedOrganization) 133 | } 134 | 135 | // testIAMGroupConfig contains the Terraform resource definitions for testing usage 136 | func testIAMGroupConfig(orgID, name string) string { 137 | return fmt.Sprintf(`resource "oasis_iam_group" "oasis_iam_group_test" { 138 | organization = "%s" 139 | name = "%s" 140 | description = "test description from Terraform Provider" 141 | } 142 | `, orgID, name) 143 | } 144 | -------------------------------------------------------------------------------- /internal/resource_organization_invite_test.go: -------------------------------------------------------------------------------- 1 | // 2 | // DISCLAIMER 3 | // 4 | // Copyright 2022 ArangoDB GmbH, Cologne, Germany 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | // Copyright holder is ArangoDB GmbH, Cologne, Germany 19 | // 20 | 21 | package provider 22 | 23 | import ( 24 | "fmt" 25 | "os" 26 | "regexp" 27 | "testing" 28 | 29 | "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" 30 | "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" 31 | "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" 32 | "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" 33 | "github.com/stretchr/testify/assert" 34 | "github.com/stretchr/testify/require" 35 | 36 | common "github.com/arangodb-managed/apis/common/v1" 37 | rm "github.com/arangodb-managed/apis/resourcemanager/v1" 38 | ) 39 | 40 | // TestAccResourceOrganizationInvite verifies the Oasis Organization Invite resource is created along with the specified properties. 41 | func TestAccResourceOrganizationInvite(t *testing.T) { 42 | if _, ok := os.LookupEnv("TF_ACC"); !ok { 43 | t.Skip() 44 | } 45 | t.Parallel() 46 | 47 | orgID, err := FetchOrganizationID() 48 | require.NoError(t, err) 49 | 50 | username := acctest.RandString(7) 51 | 52 | resource.Test(t, resource.TestCase{ 53 | PreCheck: func() { testAccPreCheck(t) }, 54 | ProviderFactories: testProviderFactories, 55 | CheckDestroy: testAccCheckDestroyOrganizationInvoice, 56 | Steps: []resource.TestStep{ 57 | { 58 | Config: testOrganizationInviteConfig("", username), 59 | ExpectError: regexp.MustCompile("failed to parse field organization"), 60 | }, 61 | { 62 | Config: testOrganizationInviteConfig(orgID, username), 63 | Check: resource.ComposeTestCheckFunc( 64 | resource.TestCheckResourceAttr("oasis_organization_invite.oasis_organization_invite_test", organizationInviteEmailFieldName, username+"@arangodb.com"), 65 | resource.TestCheckResourceAttr("oasis_organization_invite.oasis_organization_invite_test", organizationInviteOrganizationFieldName, orgID), 66 | ), 67 | }, 68 | }, 69 | }) 70 | } 71 | 72 | // testAccCheckDestroyOrganization verifies the Terraform oasis_organization_invite resource cleanup. 73 | func testAccCheckDestroyOrganizationInvoice(s *terraform.State) error { 74 | client := testAccProvider.Meta().(*Client) 75 | if err := client.Connect(); err != nil { 76 | client.log.Error().Err(err).Msg("Failed to connect to api") 77 | return err 78 | } 79 | rmc := rm.NewResourceManagerServiceClient(client.conn) 80 | 81 | for _, rs := range s.RootModule().Resources { 82 | if rs.Type != "oasis_organization_invite" { 83 | continue 84 | } 85 | 86 | if _, err := rmc.GetOrganizationInvite(client.ctxWithToken, &common.IDOptions{Id: rs.Primary.ID}); err == nil { 87 | return fmt.Errorf("organization invite still present") 88 | } 89 | } 90 | 91 | return nil 92 | } 93 | 94 | // TestFlattenOrganizationInvite tests the Oasis Organization Invite flattening for Terraform schema compatibility. 95 | func TestFlattenOrganizationInvite(t *testing.T) { 96 | organizationId := acctest.RandString(10) 97 | testUsername := acctest.RandString(7) 98 | organizationInvite := &rm.OrganizationInvite{ 99 | OrganizationId: organizationId, 100 | Email: testUsername + "@arangodb.com", 101 | } 102 | 103 | expected := map[string]interface{}{ 104 | organizationInviteOrganizationFieldName: organizationId, 105 | organizationInviteEmailFieldName: testUsername + "@arangodb.com", 106 | } 107 | flattened := flattenOrganizationInviteResource(organizationInvite) 108 | assert.Equal(t, expected, flattened) 109 | } 110 | 111 | // TestExpandOrganizationInvite tests the Oasis Organization Invite expansion for Terraform schema compatibility. 112 | func TestExpandOrganizationInvite(t *testing.T) { 113 | organizationId := acctest.RandString(10) 114 | testUsername := acctest.RandString(7) 115 | raw := map[string]interface{}{ 116 | organizationInviteOrganizationFieldName: organizationId, 117 | organizationInviteEmailFieldName: testUsername + "@arangodb.com", 118 | } 119 | s := resourceOrganizationInvite().Schema 120 | data := schema.TestResourceDataRaw(t, s, raw) 121 | orgInvite, err := expandToOrganizationInvite(data) 122 | assert.NoError(t, err) 123 | 124 | assert.Equal(t, raw[organizationInviteEmailFieldName], orgInvite.GetEmail()) 125 | } 126 | 127 | // testOrganizationInviteConfig contains the Terraform resource definitions for testing usage 128 | func testOrganizationInviteConfig(orgID, username string) string { 129 | return fmt.Sprintf(`resource "oasis_organization_invite" "oasis_organization_invite_test" { 130 | organization = "%s" 131 | email = "%s@arangodb.com" 132 | } 133 | `, orgID, username) 134 | } 135 | -------------------------------------------------------------------------------- /internal/data_source_regions.go: -------------------------------------------------------------------------------- 1 | // 2 | // DISCLAIMER 3 | // 4 | // Copyright 2022 ArangoDB GmbH, Cologne, Germany 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | // Copyright holder is ArangoDB GmbH, Cologne, Germany 19 | // 20 | 21 | package provider 22 | 23 | import ( 24 | "context" 25 | "crypto/sha256" 26 | "fmt" 27 | 28 | "github.com/hashicorp/terraform-plugin-sdk/v2/diag" 29 | "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" 30 | 31 | common "github.com/arangodb-managed/apis/common/v1" 32 | platform "github.com/arangodb-managed/apis/platform/v1" 33 | ) 34 | 35 | const ( 36 | // region data source fields 37 | regionIdFieldName = "id" 38 | regionProviderIdFieldName = "provider_id" 39 | regionLocationFieldName = "location" 40 | regionAvailableFieldName = "available" 41 | regionOrganizationFieldName = "organization" 42 | regionRegionsFieldName = "regions" 43 | ) 44 | 45 | // dataSourceOasisRegion defines a Cloud Provider Region datasource terraform type. 46 | func dataSourceOasisRegion() *schema.Resource { 47 | return &schema.Resource{ 48 | Description: "Oasis Cloud Provider Regions Data Source", 49 | ReadContext: dataSourceOasisRegionRead, 50 | 51 | Schema: map[string]*schema.Schema{ 52 | regionOrganizationFieldName: { 53 | Type: schema.TypeString, 54 | Description: "Regions Data Source Organization ID field", 55 | Required: true, 56 | }, 57 | regionProviderIdFieldName: { 58 | Type: schema.TypeString, 59 | Description: "Regions Data Source Provider ID field", 60 | Required: true, 61 | }, 62 | regionRegionsFieldName: { 63 | Type: schema.TypeList, 64 | Description: "List of all supported regions for a Cloud Provider in Oasis.", 65 | Computed: true, 66 | Elem: &schema.Resource{ 67 | Schema: map[string]*schema.Schema{ 68 | regionIdFieldName: { 69 | Type: schema.TypeString, 70 | Description: "Regions Data Source Region ID field", 71 | Computed: true, 72 | }, 73 | regionProviderIdFieldName: { 74 | Type: schema.TypeString, 75 | Description: "Regions Data Source Region Provider ID field", 76 | Computed: true, 77 | }, 78 | regionLocationFieldName: { 79 | Type: schema.TypeString, 80 | Description: "Regions Data Source Region Location field", 81 | Computed: true, 82 | }, 83 | regionAvailableFieldName: { 84 | Type: schema.TypeBool, 85 | Description: "Regions Data Source Region Available field", 86 | Computed: true, 87 | }, 88 | }, 89 | }, 90 | }, 91 | }, 92 | } 93 | } 94 | 95 | // dataSourceOasisRegionRead reloads the resource object from the Terraform store. 96 | func dataSourceOasisRegionRead(ctx context.Context, data *schema.ResourceData, m interface{}) diag.Diagnostics { 97 | client := m.(*Client) 98 | if err := client.Connect(); err != nil { 99 | client.log.Error().Err(err).Msg("Failed to connect to api") 100 | return diag.FromErr(err) 101 | } 102 | 103 | platformc := platform.NewPlatformServiceClient(client.conn) 104 | organizationId := data.Get(regionOrganizationFieldName).(string) 105 | providerId := data.Get(regionProviderIdFieldName).(string) 106 | regionsRaw, err := platformc.ListRegions(client.ctxWithToken, &platform.ListRegionsRequest{OrganizationId: organizationId, ProviderId: providerId, Options: &common.ListOptions{}}) 107 | if err != nil { 108 | return diag.FromErr(err) 109 | } 110 | 111 | regions := make([]*platform.Region, len(regionsRaw.Items)) 112 | 113 | regionItems := flattenRegions(regionsRaw.Items) 114 | err = data.Set(regionRegionsFieldName, regionItems) 115 | if err != nil { 116 | return diag.FromErr(err) 117 | } 118 | 119 | idsum := sha256.New() 120 | for _, v := range regions { 121 | _, err := idsum.Write([]byte(v.GetId())) 122 | if err != nil { 123 | return diag.FromErr(err) 124 | } 125 | } 126 | id := fmt.Sprintf("%x", idsum.Sum(nil)) 127 | data.SetId(id) 128 | 129 | return nil 130 | } 131 | 132 | // flattenRegions takes result of datasets and converts them into a Terraform consumable format. 133 | func flattenRegions(regions []*platform.Region) []interface{} { 134 | if regions != nil { 135 | flattened := make([]interface{}, len(regions)) 136 | 137 | for i, regionItem := range regions { 138 | regionSubItems := make(map[string]interface{}) 139 | 140 | regionSubItems["id"] = regionItem.GetId() 141 | regionSubItems["provider_id"] = regionItem.GetProviderId() 142 | regionSubItems["location"] = regionItem.GetLocation() 143 | regionSubItems["available"] = regionItem.GetAvailable() 144 | 145 | flattened[i] = regionSubItems 146 | } 147 | 148 | return flattened 149 | } 150 | 151 | return make([]interface{}, 0) 152 | } 153 | --------------------------------------------------------------------------------