-
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
New resource: azurerm_container_registry_token_password
#15939
New resource: azurerm_container_registry_token_password
#15939
Conversation
This commit create a separate resource for the token password.
Hi |
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.
Test failure @magodo
------- Stdout: -------
=== RUN TestAccContainerRegistryTokenPassword_requiresImport
=== PAUSE TestAccContainerRegistryTokenPassword_requiresImport
=== CONT TestAccContainerRegistryTokenPassword_requiresImport
testcase.go:110: Step 2/2, expected an error with pattern, no match on: Error running pre-apply refresh: exit status 1
Error: Missing required argument
on terraform_plugin_test.tf line 43, in resource "azurerm_container_registry_token_password" "import":
43: resource "azurerm_container_registry_token_password" "import" {
The argument "container_registry_token_id" is required, but no definition was
found.
Error: Insufficient password blocks
on terraform_plugin_test.tf line 43, in resource "azurerm_container_registry_token_password" "import":
43: resource "azurerm_container_registry_token_password" "import" {
At least 1 "password" blocks are required.
testing_new.go:70: Error running post-test destroy, there may be dangling resources: exit status 1
Error: Missing required argument
on terraform_plugin_test.tf line 43, in resource "azurerm_container_registry_token_password" "import":
43: resource "azurerm_container_registry_token_password" "import" {
The argument "container_registry_token_id" is required, but no definition was
found.
Error: Insufficient password blocks
on terraform_plugin_test.tf line 43, in resource "azurerm_container_registry_token_password" "import":
43: resource "azurerm_container_registry_token_password" "import" {
At least 1 "password" blocks are required.
--- FAIL: TestAccContainerRegistryTokenPassword_requiresImport (108.18s)
FAIL
@katbyte Sorry, I missed the requiresImport acctest config 😣. Updated now, please take another look.. |
Anything missing here? Can this be merged? ACR is largely useless as it is now because: a) service-accounts is to coarse-grained access As we now have a lot of AZ infra, this is the missing piece to get off ECR, but is not feasible for now... |
This is extremely useful, are there any news on releasing this on the azurerm provider? |
…password_separate
@katbyte could this get another review? It seems ready and I think multiple people would welcome the addition of this new resource! |
This would be a great addition. We're automating our onboarding flow and without setting passwords automatically it will lengthen our onboarding process considerably. |
"password": { | ||
Type: pluginsdk.TypeList, | ||
Required: true, | ||
MaxItems: 2, | ||
Elem: &pluginsdk.Resource{ | ||
Schema: map[string]*pluginsdk.Schema{ | ||
"name": { | ||
Type: pluginsdk.TypeString, | ||
Required: true, | ||
ValidateFunc: validation.StringInSlice([]string{ | ||
// TODO: Use below SDK enum once the following issue is resolved: https://github.com/Azure/azure-rest-api-specs/issues/18339 | ||
// string(containerregistry.PasswordNamePassword), | ||
"password1", | ||
string(containerregistry.PasswordNamePassword2), | ||
}, false), | ||
}, |
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.
Instead of a password list, that each take a name, can we instead make this two blocks: password1, password2 where the block name IS the name we pass in the the API? that way resource.password1.value is the value for the password with the name "password1"
does that makes sense? i think it would make for a better UX, 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.
@katbyte
In this case the, the HCL would be:
password1 {}
or
password1 {
expiry = "..."
}
The first form looks weired, tbh. On the other hand, to reference the value of the value of password1, users would be using password1.0.value
.
I think the current config is better in either configuring or referencing facts.
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.
Naming the blocks password1 and password2 is what we came to internally to avoid magic constants. If you want to control if to send or not send the password required you could toss an enabled in there or enforce expiry as required? but the point is to highlight there are 2 passwords only, and these are their names.
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.
@katbyte That makes sense, I've made the change accordingly, please take another look:
💢 TF_ACC=1 go test -v -timeout=20h ./internal/services/containers -run='TestAccContainerRegistryTokenPassword_'
=== RUN TestAccContainerRegistryTokenPassword_basic
=== PAUSE TestAccContainerRegistryTokenPassword_basic
=== RUN TestAccContainerRegistryTokenPassword_complete
=== PAUSE TestAccContainerRegistryTokenPassword_complete
=== RUN TestAccContainerRegistryTokenPassword_update
=== PAUSE TestAccContainerRegistryTokenPassword_update
=== RUN TestAccContainerRegistryTokenPassword_requiresImport
=== PAUSE TestAccContainerRegistryTokenPassword_requiresImport
=== CONT TestAccContainerRegistryTokenPassword_basic
=== CONT TestAccContainerRegistryTokenPassword_update
=== CONT TestAccContainerRegistryTokenPassword_requiresImport
=== CONT TestAccContainerRegistryTokenPassword_complete
--- PASS: TestAccContainerRegistryTokenPassword_requiresImport (152.96s)
--- PASS: TestAccContainerRegistryTokenPassword_basic (194.71s)
--- PASS: TestAccContainerRegistryTokenPassword_complete (204.42s)
--- PASS: TestAccContainerRegistryTokenPassword_update (213.02s)
PASS
…password_separate
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 @magodo - LGTM 🔏
internal/services/containers/container_registry_token_password_resource.go
Outdated
Show resolved
Hide resolved
This functionality has been released in v3.22.0 of the Terraform Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you! |
I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions. |
Supersedes #13782.
This PR creates a new resource
azurerm_container_registry_token_password
, which adds supports ofpassword
to ACR token. The password related API is a bit special:password
, the name of thepassword
can be eitherpassword1
orpassword2
PATCH
of the ACR token.value
Due to above fact, I'm implementing the
password
by referencing theaws_iam_user_login_profle
resource, where it sets thepassword
in the create or update method, but not in the read method. This result into the import doesn't work for thepassword
block.Test
Issues
Fixes #12810