-
Notifications
You must be signed in to change notification settings - Fork 301
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
bugfix: azuread_application - delete password block #1430
Conversation
89227cd
to
d1fb644
Compare
00f3897
to
8709641
Compare
8709641
to
ccdebd9
Compare
Hi @katbyte I update the pr and run all the required tests: make testacc TESTARGS='-run=TestAccApplicationPassword_with_ApplicationInlinePassword' Both passed without any issue. Can you please take a look the the rebased pr? |
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.
Hi @HappyTobi - Thanks for this, just a couple minor changes to take a look at below if you could, and then I think this will be good to go.
internal/services/applications/application_password_resource_test.go
Outdated
Show resolved
Hide resolved
internal/services/applications/application_password_resource_test.go
Outdated
Show resolved
Hide resolved
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.
Thanks @HappyTobi - this LGTM now 👍
AzureAD (Entra ID) application passwords can be represented in Terraform in two ways:
These both affect the same password property of an Entra ID application. The changes from this PR was rolled into release v3.1.0, which was released yesterday. When running # azuread_application.my_application will be updated in-place
~ resource "azuread_application" "my_application" {
id = "/applications/12345678-abcd-1234-1234-1234567890ab"
tags = []
# (25 unchanged attributes hidden)
- password {
# At least one attribute in this block is (or was) sensitive,
# so its contents will not be displayed.
}
# (8 unchanged blocks hidden)
} The majority of these affected resource "azuread_application_password" "my_application" {
application_id = azuread_application.my_application.id
display_name = "terraform managed"
end_date = "2025-03-30T09:00:00Z"
} @HappyTobi @jackofallops My question is this: |
we observed the same behaviour, which is really annoying. After another run of terraform apply, the passwords are getting recreated by the Which is annoying and surprising at the same time. |
We are experiencing the same issue reported by others in this thread with our Terraform Plan overnight after upgrading from azuread v3.0.2 to v3.1.0. A total of 43 service principals showed changes, and passwords may have been deleted. This is highly disruptive. Upon cross-referencing the 43 service principals, we found that some had their secrets deleted while others did not. |
Hi @andersthorbeck To you question: The password resources / secrets are handled by the "keyId". You can see the I will try to reproduce the issue to check why that happen. What I can tell you at the moment is, when you create the application with the latest release release v3.1.0 and do a Update: |
We are experiencing the same behaviour. How do we avoid this as it is highly disruptive? |
@enorlando like mentioned, I'm currently not able to reproduce the issue. |
I think the steps are quite simple: With the old provider version create:
Upgrade the provider and run Another Terraform apply will then create a new secret, because the After that everything works fine. Since we use the passwords only in the same terraform module we just run apply twice to get it fixed once. |
Yes that is what I also have done. I used the following snippet and I cant reproduce the issue:
|
@HappyTobi Indeed, I was not worried about the deletion of the application itself, but of its password, which may be used in a number of different contexts to authenticate as the application and thus acquire the required access to perform whichever Azure actions the application (or corresponding service principal) has been granted roles for.
You say that the However, our experience when merging the This was implied by the # azuread_application.my_application will be updated in-place
~ resource "azuread_application" "my_application" {
id = "/applications/12345678-abcd-1234-1234-1234567890ab"
tags = []
# (25 unchanged attributes hidden)
- password {
# At least one attribute in this block is (or was) sensitive,
# so its contents will not be displayed.
}
# (6 unchanged blocks hidden)
} and the corresponding
which was then followed, in the subsequent Terraform plan (from the next PR) of the same Terraform state, by a plan to create an # azuread_application_password.my_application will be created
+ resource "azuread_application_password" "my_application" {
+ application_id = "/applications/12345678-abcd-1234-1234-1234567890ab"
+ display_name = (known after apply)
+ end_date = "2099-01-01T01:02:03Z"
+ id = (known after apply)
+ key_id = (known after apply)
+ start_date = (known after apply)
+ value = (sensitive value)
} with
This is corroborated by looking at the Terraform statefile for a Terraform state where we did not bump to $ terraform show -json | jq '.values.root_module | ((.resources[] | select(.address == "azuread_application.my_other_application") | [{address, values: .values | {id, password}}]) + (.resources[] | select(.address == "azuread_application_password.my_other_application") | [{address, values: .values | {application_id, id, key_id}}]))'
[
{
"address": "azuread_application.my_other_application",
"values": {
"id": "/applications/34567890-abcd-1234-1234-1234567890ab",
"password": [
{
"display_name": "terraform managed",
"end_date": "2025-03-30T09:00:00Z",
"key_id": "567890ab-abcd-1234-1234-1234567890ab",
"start_date": "2024-04-03T11:30:18.4182226Z",
"value": ""
}
]
}
},
{
"address": "azuread_application_password.my_other_application",
"values": {
"application_id": "/applications/34567890-abcd-1234-1234-1234567890ab",
"id": "34567890-abcd-1234-1234-1234567890ab/password/567890ab-abcd-1234-1234-1234567890ab",
"key_id": "567890ab-abcd-1234-1234-1234567890ab"
}
}
]
For the record, I tried my best to reproduce this from scratch myself, using only an |
This change will delete all
|
To be more explicit, this actually did trigger an incident and downtime for us, where the application password was deleted and a new one created. The old password had (seemingly) been manually added as a secret in an Azure Key Vault, so that when it was rotated, there was no automation which also rotated the corresponding key vault secret. Thus the workload which depended on this password effectively lost the requisite Azure access. |
FIX:
Update function of application resource to update / remove the password when the inline
password
block is removed.