-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
azurerm_data_factory_linked_service_sql_server
: add key_vault_connection_string
argument
#12117
Changes from 4 commits
0efaba7
9cb37a1
1f53b94
c4ab3a0
98f5419
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -2,7 +2,6 @@ package datafactory | |||||||
|
||||||||
import ( | ||||||||
"fmt" | ||||||||
"log" | ||||||||
"time" | ||||||||
|
||||||||
"github.com/Azure/azure-sdk-for-go/services/datafactory/mgmt/2018-06-01/datafactory" | ||||||||
|
@@ -55,11 +54,36 @@ func resourceDataFactoryLinkedServiceSQLServer() *pluginsdk.Resource { | |||||||
|
||||||||
"connection_string": { | ||||||||
Type: pluginsdk.TypeString, | ||||||||
Required: true, | ||||||||
Optional: true, | ||||||||
AtLeastOneOf: []string{"connection_string", "key_vault_connection_string"}, | ||||||||
ConflictsWith: []string{"key_vault_connection_string"}, | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you mean
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh yes, thank you. Got lost in all those :) will push in a sec. |
||||||||
DiffSuppressFunc: azureRmDataFactoryLinkedServiceConnectionStringDiff, | ||||||||
ValidateFunc: validation.StringIsNotEmpty, | ||||||||
}, | ||||||||
|
||||||||
"key_vault_connection_string": { | ||||||||
Type: pluginsdk.TypeList, | ||||||||
Optional: true, | ||||||||
AtLeastOneOf: []string{"connection_string", "key_vault_connection_string"}, | ||||||||
ConflictsWith: []string{"connection_string"}, | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you mean |
||||||||
MaxItems: 1, | ||||||||
Elem: &pluginsdk.Resource{ | ||||||||
Schema: map[string]*pluginsdk.Schema{ | ||||||||
"linked_service_name": { | ||||||||
Type: pluginsdk.TypeString, | ||||||||
Required: true, | ||||||||
ValidateFunc: validation.StringIsNotEmpty, | ||||||||
}, | ||||||||
|
||||||||
"secret_name": { | ||||||||
Type: pluginsdk.TypeString, | ||||||||
Required: true, | ||||||||
ValidateFunc: validation.StringIsNotEmpty, | ||||||||
}, | ||||||||
}, | ||||||||
}, | ||||||||
}, | ||||||||
|
||||||||
"key_vault_password": { | ||||||||
Type: pluginsdk.TypeList, | ||||||||
Optional: true, | ||||||||
|
@@ -150,12 +174,19 @@ func resourceDataFactoryLinkedServiceSQLServerCreateUpdate(d *pluginsdk.Resource | |||||||
sqlServerLinkedService := &datafactory.SQLServerLinkedService{ | ||||||||
Description: utils.String(d.Get("description").(string)), | ||||||||
SQLServerLinkedServiceTypeProperties: &datafactory.SQLServerLinkedServiceTypeProperties{ | ||||||||
ConnectionString: d.Get("connection_string").(string), | ||||||||
Password: expandAzureKeyVaultPassword(password), | ||||||||
Password: expandAzureKeyVaultSecretReference(password), | ||||||||
}, | ||||||||
Type: datafactory.TypeBasicLinkedServiceTypeSQLServer, | ||||||||
} | ||||||||
|
||||||||
if v, ok := d.GetOk("connection_string"); ok { | ||||||||
sqlServerLinkedService.SQLServerLinkedServiceTypeProperties.ConnectionString = v.(string) | ||||||||
} | ||||||||
|
||||||||
if v, ok := d.GetOk("key_vault_connection_string"); ok { | ||||||||
sqlServerLinkedService.SQLServerLinkedServiceTypeProperties.ConnectionString = expandAzureKeyVaultSecretReference(v.([]interface{})) | ||||||||
} | ||||||||
|
||||||||
if v, ok := d.GetOk("parameters"); ok { | ||||||||
sqlServerLinkedService.Parameters = expandDataFactoryParameters(v.(map[string]interface{})) | ||||||||
} | ||||||||
|
@@ -245,11 +276,14 @@ func resourceDataFactoryLinkedServiceSQLServerRead(d *pluginsdk.ResourceData, me | |||||||
|
||||||||
if properties := sqlServer.SQLServerLinkedServiceTypeProperties; properties != nil { | ||||||||
if properties.ConnectionString != nil { | ||||||||
if val, ok := properties.ConnectionString.(string); ok { | ||||||||
if val, ok := properties.ConnectionString.(map[string]interface{}); ok { | ||||||||
if err := d.Set("key_vault_connection_string", flattenAzureKeyVaultConnectionString(val)); err != nil { | ||||||||
return fmt.Errorf("setting `key_vault_connection_string`: %+v", err) | ||||||||
} | ||||||||
} else if val, ok := properties.ConnectionString.(string); ok { | ||||||||
d.Set("connection_string", val) | ||||||||
} else { | ||||||||
d.Set("connection_string", "") | ||||||||
log.Printf("[DEBUG] Skipping connection string %q since it's not a string", val) | ||||||||
return fmt.Errorf("setting `connection_string`: %+v", err) | ||||||||
} | ||||||||
} | ||||||||
|
||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we also rename method to
flattenAzureKeyVaultSecretReference
?