-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support both UUIDs and names in consul_acl_role.policies (#363)
The `consul_acl_role` attribute `policies` only support UUIDs like: ```terraform resource "consul_acl_policy" "read-policy" { name = "read-policy" rules = "node \"\" { policy = \"read\" }" } resource "consul_acl_role" "read" { name = "foo" policies = [ consul_acl_policy.read-policy.id ] } ``` This differs from the Consul API payload where the `Policies` attribute is actually a list of objects, not a list of strings: ```json { "Name": "example-role", "Policies": [ { "ID": "783beef3-783f-f41f-7422-7087dc272765" } ] } ``` This makes it possible to set the policies using either the ID, or the name: ```json { "Name": "example-role", "Policies": [ { "ID": "783beef3-783f-f41f-7422-7087dc272765" }, { "Name: "Test" } ] } ``` This is not supported by the `consul_acl_role` resource. Not being able to add a policy using its name makes things harder for users and hanging its schema to make `policies` a list of objects would be best, but it would also break the backward compatibility of the provider which I always try not to. This patch makes it possible possible to use either and tries first to fetch the corresponding policy using the ID, then using the name. `resourceConsulACLRoleRead()` is also updated to set the correct value in Terraform so that we don't have a perpetual diff.
- Loading branch information
1 parent
cb7f9af
commit fe9f1cd
Showing
4 changed files
with
112 additions
and
29 deletions.
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
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
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
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
terraform import consul_acl_role.read 816a195f-6cb1-2e8d-92af-3011ae706318 |