Skip to content

Commit

Permalink
Add initial module passing all tests
Browse files Browse the repository at this point in the history
Signed-off-by: Roman Schwarz <rs@cloudeteer.de>
  • Loading branch information
rswrz committed Dec 16, 2024
1 parent d3e8a51 commit 724bbc6
Show file tree
Hide file tree
Showing 19 changed files with 485 additions and 86 deletions.
1 change: 0 additions & 1 deletion .github/PULL_REQUEST_TEMPLATE/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,3 @@
## Breaking Changes
<!-- Does this break backwards compatibility with the current major version? -->
<!-- If so, please provide an explanation why it is necessary. -->

36 changes: 34 additions & 2 deletions .tflint.examples.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,46 @@ tflint {
required_version = "~> 0.50"
}

rule "terraform_required_version" {
plugin "terraform" {
enabled = true

source = "github.com/terraform-linters/tflint-ruleset-terraform"
version = "0.9.1"

preset = "all"
}

plugin "azurerm" {
enabled = true

source = "github.com/terraform-linters/tflint-ruleset-azurerm"
version = "0.27.0"
}

rule "terraform_documented_variables" {
enabled = false
}

rule "terraform_required_providers" {
rule "terraform_documented_outputs" {
enabled = false
}

rule "terraform_module_version" {
enabled = false
}

rule "terraform_required_providers" {
enabled = false
}

rule "terraform_required_version" {
enabled = false
}

rule "terraform_standard_module_structure" {
enabled = false
}

rule "terraform_unused_required_providers" {
enabled = false
}
15 changes: 15 additions & 0 deletions .tflint.hcl
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
tflint {
required_version = "~> 0.50"
}

plugin "terraform" {
enabled = true

source = "github.com/terraform-linters/tflint-ruleset-terraform"
version = "0.9.1"

preset = "all"
}

plugin "azurerm" {
enabled = true
version = "0.27.0"
source = "github.com/terraform-linters/tflint-ruleset-azurerm"
}
20 changes: 16 additions & 4 deletions .tflint.tests.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,26 @@ tflint {
required_version = "~> 0.50"
}

rule "terraform_required_version" {
enabled = false
plugin "terraform" {
enabled = true

source = "github.com/terraform-linters/tflint-ruleset-terraform"
version = "0.9.1"

preset = "all"
}

plugin "azurerm" {
enabled = true

source = "github.com/terraform-linters/tflint-ruleset-azurerm"
version = "0.27.0"
}

rule "terraform_required_providers" {
rule "terraform_unused_required_providers" {
enabled = false
}

rule "terraform_module_version" {
rule "terraform_standard_module_structure" {
enabled = false
}
180 changes: 172 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,37 +17,201 @@ Terraform Module Template
This example demonstrates the usage of this Terraform module with default settings.

```hcl
module "example" {
# Change "module" and "provider" accordingly to match you new module
source = "cloudeteer/module/provider"
resource "azurerm_resource_group" "example" {
name = "rg-example-dev-euw-01"
location = "westeurope"
}
resource "azurerm_virtual_network" "example" {
name = "vnet-example-dev-euw-01"
resource_group_name = azurerm_resource_group.example.name
location = azurerm_resource_group.example.location
address_space = ["10.0.0.0/8"]
}
resource "azurerm_subnet" "example" {
name = "snet-example"
resource_group_name = azurerm_resource_group.example.name
virtual_network_name = azurerm_virtual_network.example.name
address_prefixes = ["10.1.0.0/16"]
}
example_variable = "example_value"
module "example" {
source = "cloudeteer/ai/azurerm"
name = "oai-example-dev-euw-01"
resource_group_name = azurerm_resource_group.example.name
location = azurerm_resource_group.example.location
subnet_id = azurerm_subnet.example.id
kind = "OpenAI"
sku_name = "S0"
models = [
{
rai_policy_name = "Microsoft.Default"
format = "OpenAI"
name = "gpt-4o-mini"
version = "2024-07-18"
sku = {
name = "GlobalStandard"
capacity = 100
}
}
]
}
```

## Providers

The following providers are used by this module:

- <a name="provider_azurerm"></a> [azurerm](#provider\_azurerm) (>= 3.0)



## Resources

The following resources are used by this module:

- [azurerm_cognitive_account.this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/cognitive_account) (resource)
- [azurerm_cognitive_deployment.this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/cognitive_deployment) (resource)
- [azurerm_private_dns_zone.this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/private_dns_zone) (resource)
- [azurerm_private_dns_zone_virtual_network_link.this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/private_dns_zone_virtual_network_link) (resource)
- [azurerm_private_endpoint.this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/private_endpoint) (resource)

## Required Inputs

The following input variables are required:

### <a name="input_example_variable"></a> [example\_variable](#input\_example\_variable)
### <a name="input_kind"></a> [kind](#input\_kind)

Description: Specifies the type of Cognitive Service Account that should be created. Possible values are:

- `Academic`
- `AnomalyDetector`
- `Bing.Autosuggest.v7`
- `Bing.Autosuggest`
- `Bing.CustomSearch`
- `Bing.Search.v7`
- `Bing.Search`
- `Bing.Speech`
- `Bing.SpellCheck.v7`
- `Bing.SpellCheck`
- `CognitiveServices`
- `ComputerVision`
- `ContentModerator`
- `ContentSafety`
- `CustomSpeech`
- `CustomVision.Prediction`
- `CustomVision.Training`
- `Emotion`
- `Face`
- `FormRecognizer`
- `ImmersiveReader`
- `LUIS.Authoring`
- `LUIS`
- `MetricsAdvisor`
- `OpenAI`
- `Personalizer`
- `QnAMaker`
- `Recommendations`
- `SpeakerRecognition`
- `Speech`
- `SpeechServices`
- `SpeechTranslation`
- `TextAnalytics`
- `TextTranslation
- `WebLM`
`

Type: `string`

### <a name="input_location"></a> [location](#input\_location)

Description: Specifies the supported Azure location where the resource exists.

Type: `string`

### <a name="input_name"></a> [name](#input\_name)

Description: Specifies the name of the Cognitive Service Account.

Type: `string`

### <a name="input_resource_group_name"></a> [resource\_group\_name](#input\_resource\_group\_name)

Description: The name of the resource group in which the Cognitive Service Account is created.

Type: `string`

### <a name="input_sku_name"></a> [sku\_name](#input\_sku\_name)

Description: Example variable (between 3 and 13 characters)
Description: Specifies the SKU Name for this Cognitive Service Account. Possible values are `F0`, `F1`, `S0`, `S`, `S1`, `S2`, `S3`, `S4`, `S5`, `S6`, `P0`, `P1`, `P2`, `E0` and `DC0`.

Type: `string`

### <a name="input_subnet_id"></a> [subnet\_id](#input\_subnet\_id)

Description: The ID of the subnet which should be able to access this Cognitive Account.

Type: `string`

## Optional Inputs

The following input variables are optional (have default values):

### <a name="input_custom_subdomain_name"></a> [custom\_subdomain\_name](#input\_custom\_subdomain\_name)

Description: The subdomain name used for token-based authentication.

Type: `string`

Default: `null`

### <a name="input_models"></a> [models](#input\_models)

Description: value

Type: `list(any)`

Default: `[]`

### <a name="input_public_network_access_enabled"></a> [public\_network\_access\_enabled](#input\_public\_network\_access\_enabled)

Description: Whether public network access is allowed for the Cognitive Account.

Type: `bool`

Default: `false`

### <a name="input_tags"></a> [tags](#input\_tags)

Description: A mapping of tags which should be assigned to all resources in this module.

Type: `map(string)`

Default: `null`

## Outputs

The following outputs are exported:

### <a name="output_example_output"></a> [example\_output](#output\_example\_output)
### <a name="output_endpoint"></a> [endpoint](#output\_endpoint)

Description: The endpoint used to connect to the Cognitive Service Account.

### <a name="output_primary_access_key"></a> [primary\_access\_key](#output\_primary\_access\_key)

Description: A primary access key which can be used to connect to the Cognitive Service Account.

### <a name="output_secondary_access_key"></a> [secondary\_access\_key](#output\_secondary\_access\_key)

Description: Example output
Description: The secondary access key which can be used to connect to the Cognitive Service Account.
<!-- END_TF_DOCS -->

## Contributions
Expand Down
47 changes: 44 additions & 3 deletions examples/usage/main.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,47 @@
resource "azurerm_resource_group" "example" {
name = "rg-example-dev-euw-01"
location = "westeurope"
}

resource "azurerm_virtual_network" "example" {
name = "vnet-example-dev-euw-01"
resource_group_name = azurerm_resource_group.example.name
location = azurerm_resource_group.example.location

address_space = ["10.0.0.0/8"]
}

resource "azurerm_subnet" "example" {
name = "snet-example"
resource_group_name = azurerm_resource_group.example.name
virtual_network_name = azurerm_virtual_network.example.name

address_prefixes = ["10.1.0.0/16"]
}


module "example" {
# Change "module" and "provider" accordingly to match you new module
source = "cloudeteer/module/provider"
source = "cloudeteer/ai/azurerm"

name = "oai-example-dev-euw-01"
resource_group_name = azurerm_resource_group.example.name
location = azurerm_resource_group.example.location

subnet_id = azurerm_subnet.example.id

kind = "OpenAI"
sku_name = "S0"

example_variable = "example_value"
models = [
{
rai_policy_name = "Microsoft.Default"
format = "OpenAI"
name = "gpt-4o-mini"
version = "2024-07-18"
sku = {
name = "GlobalStandard"
capacity = 100
}
}
]
}
7 changes: 3 additions & 4 deletions examples/usage/tests_override.tf
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
# This override file is mandatory for Terraform tests.
# Not needed to use this example.
terraform {
# add all providers used in the module to run tests
#required_providers {
# random = { source = "hashicorp/random" }
#}
required_providers {
azurerm = { source = "hashicorp/azurerm" }
}
}

module "example" { source = "../.." }
Loading

0 comments on commit 724bbc6

Please sign in to comment.