-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #241 from Azure/jdc/open-ai-module
Cognitive Deployment Module
- Loading branch information
Showing
26 changed files
with
436 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// For format details, see https://aka.ms/devcontainer.json. For config options, see the | ||
// README at: https://github.com/devcontainers/templates/tree/main/src/ubuntu | ||
{ | ||
"name": "Ubuntu", | ||
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile | ||
"image": "mcr.microsoft.com/devcontainers/base:jammy", | ||
"features": { | ||
"ghcr.io/devcontainers/features/azure-cli:1": {}, | ||
"ghcr.io/devcontainers/features/github-cli:1": {}, | ||
"ghcr.io/devcontainers/features/python:1": {}, | ||
"ghcr.io/devcontainers/features/terraform:1": {} | ||
}, | ||
"customizations": { | ||
"vscode": { | ||
"extensions": [ | ||
"GitHub.codespaces" | ||
] | ||
} | ||
} | ||
|
||
// Features to add to the dev container. More info: https://containers.dev/features. | ||
// "features": {}, | ||
|
||
// Use 'forwardPorts' to make a list of ports inside the container available locally. | ||
// "forwardPorts": [], | ||
|
||
// Use 'postCreateCommand' to run commands after the container is created. | ||
// "postCreateCommand": "uname -a", | ||
|
||
// Configure tool-specific properties. | ||
// "customizations": {}, | ||
|
||
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. | ||
// "remoteUser": "root" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
name: Module:cognitive-services | ||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
branches: | ||
- main | ||
paths: | ||
- '.github/workflows/cognitive-services-deployment.yml' | ||
- 'terraform/cognitive-services/cognitive-deployment**' | ||
# - '.github/actions/**' | ||
|
||
env: | ||
terraform_workingdir: "terraform/cognitive-services/cognitive-deployment" | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
jobs: | ||
terraform-lint: | ||
name: Run Terraform lint | ||
runs-on: ubuntu-latest | ||
defaults: | ||
run: | ||
working-directory: "${{ env.terraform_workingdir }}" | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: hashicorp/setup-terraform@v2 | ||
|
||
- name: Terraform fmt | ||
id: fmt | ||
run: terraform fmt -check | ||
continue-on-error: false | ||
|
||
terraform-sec: | ||
name: Run Terraform tfsec | ||
needs: | ||
- terraform-lint | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Check out code | ||
uses: actions/checkout@main | ||
|
||
- name: Run tfsec with reviewdog output on the PR | ||
uses: ./.github/actions/run-terraform-sec | ||
|
||
terratest: | ||
name: Run Terratest | ||
needs: | ||
- terraform-sec | ||
runs-on: [self-hosted, 1ES.Pool=azure-data-labs-modules] | ||
environment: | ||
name: acctests | ||
|
||
defaults: | ||
run: | ||
working-directory: "${{ env.terraform_workingdir }}/test" | ||
|
||
steps: | ||
- name: Check out code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.18.2 | ||
|
||
- name: Setup Dependencies | ||
run: | | ||
az login --identity > /dev/null | ||
export ARM_USE_MSI=true | ||
export ARM_SUBSCRIPTION_ID=$(az login --identity | jq -r '.[0] | .id') | ||
export ARM_TENANT_ID=$(az login --identity | jq -r '.[0] | .tenantId') | ||
go mod init test && go mod tidy | ||
env: | ||
GOPATH: "/home/cloudtest/work/azure-labs-modules/azure-labs-modules/${{ env.terraform_workingdir }}" | ||
|
||
- name: Unit-test | ||
run: | | ||
az login --identity > /dev/null | ||
export ARM_USE_MSI=true | ||
export ARM_SUBSCRIPTION_ID=$(az login --identity | jq -r '.[0] | .id') | ||
export ARM_TENANT_ID=$(az login --identity | jq -r '.[0] | .tenantId') | ||
go test -v -timeout 45m | ||
env: | ||
GOPATH: "/home/cloudtest/work/azure-labs-modules/azure-labs-modules/${{ env.terraform_workingdir }}" | ||
|
||
terraform-docs: | ||
name: Run Terraform Docs | ||
needs: | ||
- terratest | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Check out code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Render terraform docs and push changes back to PR | ||
uses: ./.github/actions/run-terraform-docs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
output "id" { | ||
value = ( | ||
length(azurerm_cognitive_account.adl_cog_acc) > 0 ? | ||
azurerm_cognitive_account.adl_cog_acc[0].id : "" | ||
) | ||
description = "Resource identifier of the instance of Cognitive Services." | ||
} | ||
|
||
output "name" { | ||
value = ( | ||
length(azurerm_cognitive_account.adl_cog_acc) > 0 ? | ||
azurerm_cognitive_account.adl_cog_acc[0].name : "" | ||
) | ||
description = "The name of the Cognitive Services." | ||
} | ||
|
||
output "resource_group_name" { | ||
value = ( | ||
length(azurerm_cognitive_account.adl_cog_acc) > 0 ? | ||
azurerm_cognitive_account.adl_cog_acc[0].resource_group_name : "" | ||
) | ||
description = "Resource Group where the Cognitive Services exists." | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
terraform/cognitive-services/test/locals.tf → ...services/cognitive-account/test/locals.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
terraform/cognitive-services/cognitive-account/test/outputs.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
output "id" { | ||
value = module.cognitive_account.id | ||
} | ||
|
||
output "name" { | ||
value = module.cognitive_account.name | ||
} | ||
|
||
output "resource_group_name" { | ||
value = module.cognitive_account.resource_group_name | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
28 changes: 28 additions & 0 deletions
28
terraform/cognitive-services/cognitive-deployment/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<!-- BEGIN_TF_DOCS --> | ||
## Resources | ||
|
||
| Name | Type | | ||
|------|------| | ||
| [azurerm_cognitive_deployment.adl_cog_dpl](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/cognitive_deployment) | resource | | ||
|
||
## Inputs | ||
|
||
| Name | Description | Type | Default | Required | | ||
|------|-------------|------|---------|:--------:| | ||
| <a name="input_basename"></a> [basename](#input\_basename) | Basename of the module. | `string` | n/a | yes | | ||
| <a name="input_cognitive_account_id"></a> [cognitive\_account\_id](#input\_cognitive\_account\_id) | The ID of the Cognitive Services Account. Changing this forces a new resource to be created. | `string` | n/a | yes | | ||
| <a name="input_model_format"></a> [model\_format](#input\_model\_format) | The format of the Cognitive Services Account Deployment model. Changing this forces a new resource to be created. Possible value is OpenAI. | `string` | `"OpenAI"` | no | | ||
| <a name="input_model_name"></a> [model\_name](#input\_model\_name) | The name of the Cognitive Services Account Deployment model. Changing this forces a new resource to be created. | `string` | n/a | yes | | ||
| <a name="input_model_version"></a> [model\_version](#input\_model\_version) | The version of Cognitive Services Account Deployment model. | `string` | n/a | yes | | ||
| <a name="input_scale_type"></a> [scale\_type](#input\_scale\_type) | TDeployment scale type. Possible value is Standard. Changing this forces a new resource to be created. | `string` | `"Standard"` | no | | ||
| <a name="input_rai_policy_name"></a> [rai\_policy\_name](#input\_rai\_policy\_name) | The name of RAI policy. Changing this forces a new resource to be created. | `string` | `null` | no | | ||
| <a name="input_tags"></a> [tags](#input\_tags) | A mapping of tags which should be assigned to the deployed resource. | `map(string)` | `{}` | no | | ||
| <a name="input_module_enabled"></a> [module\_enabled](#input\_module\_enabled) | Variable to enable or disable the module. | `bool` | `true` | no | | ||
|
||
## Outputs | ||
|
||
| Name | Description | | ||
|------|-------------| | ||
| <a name="output_id"></a> [id](#output\_id) | Resource identifier of the instance of Cognitive Deployment. | | ||
| <a name="output_name"></a> [name](#output\_name) | The name of the Cognitive Deployment. | | ||
<!-- END_TF_DOCS --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/cognitive_deployment | ||
|
||
resource "azurerm_cognitive_deployment" "adl_cog_dpl" { | ||
name = "cog-dpl-${var.basename}" | ||
cognitive_account_id = var.cognitive_account_id | ||
model { | ||
format = var.model_format | ||
name = var.model_name | ||
version = var.model_version | ||
} | ||
scale { | ||
type = var.scale_type | ||
} | ||
rai_policy_name = var.rai_policy_name | ||
|
||
count = var.module_enabled ? 1 : 0 | ||
} |
15 changes: 15 additions & 0 deletions
15
terraform/cognitive-services/cognitive-deployment/outputs.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
output "id" { | ||
value = ( | ||
length(azurerm_cognitive_deployment.adl_cog_dpl) > 0 ? | ||
azurerm_cognitive_deployment.adl_cog_dpl[0].id : "" | ||
) | ||
description = "Resource identifier of the instance of Cognitive Deployment." | ||
} | ||
|
||
output "name" { | ||
value = ( | ||
length(azurerm_cognitive_deployment.adl_cog_dpl) > 0 ? | ||
azurerm_cognitive_deployment.adl_cog_dpl[0].name : "" | ||
) | ||
description = "The name of the Cognitive Deployment." | ||
} |
Oops, something went wrong.