Skip to content

Commit 5e8df69

Browse files
author
Jiawei Tao
committed
New Resource: azurerm_container_app_connection
1 parent b2ccf1d commit 5e8df69

4 files changed

Lines changed: 26 additions & 243 deletions

File tree

internal/services/serviceconnector/container_app_connection_resource.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ type ContainerAppConnectorResourceModel struct {
3434
AuthInfo []AuthInfoModel `tfschema:"authentication"`
3535
VnetSolution string `tfschema:"vnet_solution"`
3636
SecretStore []SecretStoreModel `tfschema:"secret_store"`
37+
Scope string `tfschema:"scope"`
3738
}
3839

3940
func (r ContainerAppConnectorResource) Arguments() map[string]*schema.Schema {
@@ -59,6 +60,13 @@ func (r ContainerAppConnectorResource) Arguments() map[string]*schema.Schema {
5960
ValidateFunc: azure.ValidateResourceID,
6061
},
6162

63+
"scope": {
64+
Type: pluginsdk.TypeString,
65+
Required: true,
66+
ForceNew: true,
67+
ValidateFunc: validation.StringIsNotEmpty,
68+
},
69+
6270
"client_type": {
6371
Type: pluginsdk.TypeString,
6472
Optional: true,
@@ -132,12 +140,14 @@ func (r ContainerAppConnectorResource) Create() sdk.ResourceFunc {
132140

133141
serviceConnectorProperties := servicelinker.LinkerProperties{
134142
AuthInfo: authInfo,
143+
Scope: pointer.To(model.Scope),
135144
}
136145

137146
if storageAccountId, err := commonids.ParseStorageAccountID(model.TargetResourceId); err == nil {
138147
targetResourceId := fmt.Sprintf("%s/blobServices/default", storageAccountId.ID())
139148
serviceConnectorProperties.TargetService = servicelinker.AzureResource{
140-
Id: &targetResourceId,
149+
Id: &targetResourceId,
150+
Type: servicelinker.TargetServiceTypeAzureResource,
141151
}
142152
} else {
143153
serviceConnectorProperties.TargetService = servicelinker.AzureResource{
@@ -210,6 +220,7 @@ func (r ContainerAppConnectorResource) Read() sdk.ResourceFunc {
210220
ContainerAppId: id.ResourceUri,
211221
TargetResourceId: flattenTargetService(props.TargetService),
212222
AuthInfo: flattenServiceConnectorAuthInfo(props.AuthInfo, pwd),
223+
Scope: pointer.From(props.Scope),
213224
}
214225

215226
if props.ClientType != nil {

internal/services/serviceconnector/container_app_connection_resource_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ resource "azurerm_container_app_connection" "test" {
208208
name = "acctestserviceconnector%[3]d"
209209
container_app_id = azurerm_container_app.test.id
210210
target_resource_id = azurerm_cosmosdb_sql_database.test.id
211+
scope = azurerm_container_app.test.template[0].container[0].name
211212
authentication {
212213
type = "systemAssignedIdentity"
213214
}
@@ -224,6 +225,7 @@ resource "azurerm_container_app_connection" "test" {
224225
name = "acctestserviceconnector%[2]d"
225226
container_app_id = azurerm_container_app.test.id
226227
target_resource_id = azurerm_cosmosdb_sql_database.test.id
228+
scope = azurerm_container_app.test.template[0].container[0].name
227229
authentication {
228230
type = "secret"
229231
name = "foo"
@@ -248,6 +250,7 @@ resource "azurerm_container_app_connection" "test" {
248250
name = "acctestserviceconnector%[3]d"
249251
container_app_id = azurerm_container_app.test.id
250252
target_resource_id = azurerm_cosmosdb_sql_database.test.id
253+
scope = azurerm_container_app.test.template[0].container[0].name
251254
authentication {
252255
type = "servicePrincipalSecret"
253256
client_id = "someclientid"
@@ -275,6 +278,7 @@ resource "azurerm_container_app_connection" "test" {
275278
name = "acctestserviceconnector%[3]d"
276279
container_app_id = azurerm_container_app.test.id
277280
target_resource_id = azurerm_cosmosdb_sql_database.test.id
281+
scope = azurerm_container_app.test.template[0].container[0].name
278282
authentication {
279283
type = "userAssignedIdentity"
280284
subscription_id = data.azurerm_subscription.test.subscription_id
@@ -336,6 +340,7 @@ resource "azurerm_container_app" "test" {
336340
ignore_changes = [
337341
template[0].container[0].env,
338342
identity,
343+
secret,
339344
]
340345
}
341346
}
@@ -459,6 +464,7 @@ resource "azurerm_container_app" "test" {
459464
ignore_changes = [
460465
template[0].container[0].env,
461466
identity,
467+
secret,
462468
]
463469
}
464470
}
@@ -539,6 +545,7 @@ resource "azurerm_container_app" "test" {
539545
ignore_changes = [
540546
template[0].container[0].env,
541547
identity,
548+
secret,
542549
]
543550
}
544551
}

0 commit comments

Comments
 (0)