Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add table azure_cosmosdb_mongo_collection. Closes #588 #589

Merged
merged 9 commits into from
Mar 24, 2023
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[
{
"account_name": "{{resourceName}}",
"database_name": "{{resourceName}}",
"id": "{{ output.resource_id.value }}",
"name": "{{resourceName}}",
"region": "east us",
"resource_group": "{{resourceName}}"
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
select
name,
id,
region,
account_name,
database_name,
resource_group
from
azure.azure_cosmosdb_mongo_collection
where
name = '{{resourceName}}'
and resource_group = '{{resourceName}}'
and database_name = '{{resourceName}}'
and account_name = '{{resourceName}}';
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[
{
"account_name": "{{resourceName}}",
"database_name": "{{resourceName}}",
"id": "{{ output.resource_id.value }}",
"name": "{{resourceName}}",
"region": "east us",
"resource_group": "{{resourceName}}"
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
select
name,
id,
region,
account_name,
database_name,
resource_group
from
azure.azure_cosmosdb_mongo_collection
where
name = '{{resourceName}}'
and resource_group = '{{resourceName}}'
and database_name = '{{resourceName}}'
and account_name = '{{resourceName}}';
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[
{
"account_name": "{{resourceName}}",
"database_name": "{{resourceName}}",
"id": "{{ output.resource_id.value }}",
"name": "{{resourceName}}",
"region": "east us",
"resource_group": "{{resourceName}}"
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
select
name,
id,
region,
account_name,
database_name,
resource_group
from
azure.azure_cosmosdb_mongo_collection
where
name = '{{resourceName}}'
and database_name = '{{resourceName}}';
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
null
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
select
name,
id,
region,
account_name,
database_name,
type,
resource_group
from
azure.azure_cosmosdb_mongo_collection
where
name = '{{resourceName}}-dummy'
and resource_group = '{{resourceName}}'
and database_name = '{{resourceName}}'
and account_name = '{{resourceName}}';
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[
{
"akas": [
"{{ output.resource_aka.value }}",
"{{ output.resource_aka_lower.value }}"
],
"name": "{{resourceName}}",
"title": "{{resourceName}}"
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
select
name,
akas,
title
from
azure.azure_cosmosdb_mongo_collection
where
name = '{{resourceName}}'
and resource_group = '{{resourceName}}'
and database_name = '{{resourceName}}'
and account_name = '{{resourceName}}';
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
125 changes: 125 additions & 0 deletions azure-test/tests/azure_cosmosdb_mongo_collection/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@

variable "resource_name" {
type = string
default = "turbot-test-20200125-create-update"
description = "Name of the resource used throughout the test."
}

variable "azure_environment" {
type = string
default = "public"
description = "Azure environment used for the test."
}

variable "azure_subscription" {
type = string
default = "abcd7416-f95f-4771-bbb5-529d4c76659c"
description = "Azure subscription used for the test."
}

provider "azurerm" {
# Cannot be passed as a variable
environment = var.azure_environment
subscription_id = var.azure_subscription
features {}
}

data "azurerm_client_config" "current" {}

data "null_data_source" "resource" {
inputs = {
scope = "azure:///subscriptions/${data.azurerm_client_config.current.subscription_id}"
}
}

resource "azurerm_resource_group" "named_test_resource" {
name = var.resource_name
location = "East US"
}

resource "azurerm_cosmosdb_account" "named_test_resource" {
name = var.resource_name
location = azurerm_resource_group.named_test_resource.location
resource_group_name = azurerm_resource_group.named_test_resource.name
offer_type = "Standard"
kind = "MongoDB"
enable_free_tier = true
enable_automatic_failover = false

capabilities {
name = "EnableAggregationPipeline"
}

capabilities {
name = "mongoEnableDocLevelTTL"
}

capabilities {
name = "MongoDBv3.4"
}

capabilities {
name = "EnableMongo"
}

consistency_policy {
consistency_level = "BoundedStaleness"
max_interval_in_seconds = 300
max_staleness_prefix = 1000
}


geo_location {
location = azurerm_resource_group.named_test_resource.location
failover_priority = 0
}
}

resource "null_resource" "delay" {
provisioner "local-exec" {
command = "sleep 360"
}
triggers = {
"before" = "${azurerm_cosmosdb_account.named_test_resource.id}"
}
}

resource "azurerm_cosmosdb_mongo_database" "named_test_resource" {
depends_on = [null_resource.delay]
name = var.resource_name
resource_group_name = azurerm_resource_group.named_test_resource.name
account_name = azurerm_cosmosdb_account.named_test_resource.name
}

resource "azurerm_cosmosdb_mongo_collection" "named_test_resource" {
name = var.resource_name
resource_group_name = azurerm_resource_group.named_test_resource.name
account_name = azurerm_cosmosdb_account.named_test_resource.name
database_name = azurerm_cosmosdb_mongo_database.named_test_resource.name

default_ttl_seconds = "777"
shard_key = "uniqueKey"
throughput = 400

index {
keys = ["_id"]
unique = true
}
}


output "resource_aka" {
value = "azure://${azurerm_cosmosdb_mongo_collection.named_test_resource.id}"
}

output "resource_aka_lower" {
value = "azure://${lower(azurerm_cosmosdb_mongo_collection.named_test_resource.id)}"
}

output "resource_name" {
value = var.resource_name
}

output "resource_id" {
value = azurerm_cosmosdb_mongo_collection.named_test_resource.id
}
1 change: 1 addition & 0 deletions azure/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ func Plugin(ctx context.Context) *plugin.Plugin {
"azure_compute_virtual_machine_scale_set_vm": tableAzureComputeVirtualMachineScaleSetVm(ctx),
"azure_container_registry": tableAzureContainerRegistry(ctx),
"azure_cosmosdb_account": tableAzureCosmosDBAccount(ctx),
"azure_cosmosdb_mongo_collection": tableAzureCosmosDBMongoCollection(ctx),
"azure_cosmosdb_mongo_database": tableAzureCosmosDBMongoDatabase(ctx),
"azure_cosmosdb_sql_database": tableAzureCosmosDBSQLDatabase(ctx),
"azure_data_factory": tableAzureDataFactory(ctx),
Expand Down
Loading