-
Notifications
You must be signed in to change notification settings - Fork 4.6k
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_function_app
- storage_connection_string
can now rotate keys but still a require recreate when changing the account
#5645
Closed
kraihn
wants to merge
1
commit into
hashicorp:master
from
kraihn:bugfix/function-app-storage-credentials
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 | ||||
---|---|---|---|---|---|---|
|
@@ -78,7 +78,6 @@ func resourceArmFunctionApp() *schema.Resource { | |||||
"storage_connection_string": { | ||||||
Type: schema.TypeString, | ||||||
Required: true, | ||||||
ForceNew: true, | ||||||
Sensitive: true, | ||||||
}, | ||||||
|
||||||
|
@@ -429,6 +428,16 @@ func resourceArmFunctionAppUpdate(d *schema.ResourceData, meta interface{}) erro | |||||
} | ||||||
} | ||||||
|
||||||
if d.HasChange("storage_connection_string") { | ||||||
oldValue, newValue := d.GetChange("storage_connection_string") | ||||||
oldAccount := getAccountName(fmt.Sprintf("%s", oldValue)) | ||||||
newAccount := getAccountName(fmt.Sprintf("%s", newValue)) | ||||||
|
||||||
if oldAccount != newAccount { | ||||||
return fmt.Errorf("Error updating storage_connection_string because the AccountName cannot be changed. To change the storage account the resource must be tainted.") | ||||||
} | ||||||
} | ||||||
|
||||||
future, err := client.CreateOrUpdate(ctx, resGroup, name, siteEnvelope) | ||||||
if err != nil { | ||||||
return err | ||||||
|
@@ -869,3 +878,14 @@ func flattenFunctionAppSiteCredential(input *web.UserProperties) []interface{} { | |||||
|
||||||
return append(results, result) | ||||||
} | ||||||
|
||||||
func getAccountName(storageConnectionString string) 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. in Golang functions are shared across the entire package - as such this method would probably be better named as:
Suggested change
|
||||||
connectionStringArray := strings.SplitN(storageConnectionString, ";", -1) | ||||||
connectionStringMap := make(map[string]string) | ||||||
for _, pair := range connectionStringArray { | ||||||
z := strings.Split(pair, "=") | ||||||
connectionStringMap[z[0]] = z[1] | ||||||
} | ||||||
|
||||||
return connectionStringMap["AccountName"] | ||||||
} |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
whilst this'd work it'd cause a bunch of runtime errors should someone opt to change the account being used - as such I'm wondering if we'd be better to split this field into two:
WDYT?
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.
I love that idea! It makes more sense to me. Should I make this change with 2.0 in mind and remove the old property?
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.
now that we are post 2.0 what we will have to do is deprecate the old one and make them conflict.