Skip to content

Commit be5560d

Browse files
committed
Add custom Azure provider configuration for Terraform Azure test
Signed-off-by: Karishma Chawla <[email protected]>
1 parent 976886a commit be5560d

File tree

4 files changed

+60
-1
lines changed

4 files changed

+60
-1
lines changed

.github/workflows/functional-test-cloud.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -784,6 +784,8 @@ jobs:
784784
BICEP_RECIPE_TAG_VERSION: ${{ env.BICEP_RECIPE_TAG_VERSION }}
785785
GH_TOKEN: ${{ steps.get_installation_token.outputs.token }}
786786
GOTESTSUM_OPTS: "--junitfile ./dist/functional_test/results.xml"
787+
AZURE_CLIENT_ID: ${{ secrets.AZURE_SP_TESTS_APPID }}
788+
AZURE_TENANT_ID: ${{ secrets.AZURE_SP_TESTS_TENANTID }}
787789

788790
- name: Process Functional Test Results
789791
uses: ./.github/actions/process-test-results

test/functional-portable/corerp/cloud/resources/recipe_terraform_test.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ package resource_test
2525

2626
import (
2727
"context"
28+
"os"
2829
"strings"
2930
"testing"
3031

@@ -50,9 +51,15 @@ func Test_TerraformRecipe_AzureResourceGroup(t *testing.T) {
5051
appName := "corerp-resources-terraform-azrg-app"
5152
envName := "corerp-resources-terraform-azrg-env"
5253

54+
if os.Getenv("AZURE_CLIENT_ID") == "" || os.Getenv("AZURE_TENANT_ID") == "" {
55+
t.Error("AZURE_CLIENT_ID and AZURE_TENANT_ID environment variables must be set to run this test.")
56+
}
57+
clientID := os.Getenv("AZURE_CLIENT_ID")
58+
tenantID := os.Getenv("AZURE_TENANT_ID")
59+
5360
test := rp.NewRPTest(t, name, []rp.TestStep{
5461
{
55-
Executor: step.NewDeployExecutor(template, testutil.GetTerraformRecipeModuleServerURL(), "appName="+appName),
62+
Executor: step.NewDeployExecutor(template, testutil.GetTerraformRecipeModuleServerURL(), "appName="+appName, "clientID="+clientID, "tenantID="+tenantID),
5663
RPResources: &validation.RPResourceSet{
5764
Resources: []validation.RPResource{
5865
{

test/functional-portable/corerp/cloud/resources/testdata/corerp-resources-terraform-azurerg.bicep

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ param moduleServer string
88
@description('Name of the Radius Application.')
99
param appName string
1010

11+
@description('Client ID for Azure.')
12+
param clientID string
13+
14+
@description('Tenant ID for Azure.')
15+
param tenantID string
16+
1117
resource env 'Applications.Core/environments@2023-10-01-preview' = {
1218
name: 'corerp-resources-terraform-azrg-env'
1319
properties: {
@@ -21,6 +27,33 @@ resource env 'Applications.Core/environments@2023-10-01-preview' = {
2127
scope: resourceGroup().id
2228
}
2329
}
30+
recipeConfig: {
31+
terraform: {
32+
providers: {
33+
azurerm: [ {
34+
alias: 'azure-test'
35+
features: '{}'
36+
subscription_id: subscription().subscriptionId
37+
secrets: {
38+
tenant_id: {
39+
source: secretstore.id
40+
key: 'tenantID'
41+
}
42+
}
43+
} ]
44+
}
45+
}
46+
env: {
47+
ARM_USE_AKS_WORKLOAD_IDENTITY: 'true'
48+
ARM_USE_CLI: 'false'
49+
}
50+
envSecrets: {
51+
ARM_CLIENT_ID: {
52+
source: secretstore.id
53+
key: 'clientID'
54+
}
55+
}
56+
}
2457
recipes: {
2558
'Applications.Core/extenders': {
2659
default: {
@@ -56,3 +89,19 @@ resource webapp 'Applications.Core/extenders@2023-10-01-preview' = {
5689
environment: env.id
5790
}
5891
}
92+
93+
resource secretstore 'Applications.Core/secretStores@2023-10-01-preview' = {
94+
name: 'corerp-resources-terraform-azrg-secretstore'
95+
properties: {
96+
resource: 'corerp-resources-terraform-azrg/secretstore'
97+
type: 'generic'
98+
data: {
99+
tenantID: {
100+
value: tenantID
101+
}
102+
clientID: {
103+
value: clientID
104+
}
105+
}
106+
}
107+
}

test/testrecipes/test-terraform-recipes/azure-rg/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ terraform {
33
azurerm = {
44
source = "hashicorp/azurerm"
55
version = "~> 3.114.0"
6+
configuration_aliases = [azurerm.azure-test]
67
}
78
}
89
}

0 commit comments

Comments
 (0)