Skip to content
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

Sets Azure Storage authentication method from Access Key to Entra User Account #5

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

bronius
Copy link
Contributor

@bronius bronius commented Nov 11, 2024

Description

Since we don't want to access Azure Storage for terraform backend storage via Access Keys, I had to do a little dance to enable Entra User Authentication.

  • I don't know if this is the right approach to solve the issue
  • It's also WIP, because I have temporarily set the new role principal_id to a group that my az-cli user is a member of for convenience, but either we need a more appropriate group or some other approach.

Another idea is to create and apply a Managed Identity. Would this work for "anyone running the parent terraform" (who ultimately needs access to read tfstate stored in the container).

Update: Each of the commits on this PR is another slightly different stab and none better than the previous. I fail to end up with an idempotent (can rerun apply and either first-time create or detect no differences) outcome: I always get either duplicate resources:
image
or failure:
image
or failure:
image

I am probably out of ideas. What I am going for is:

  • Storing remote backend in Azure Storage
  • That can be accessed by Entra User Access (without Access Keys)
  • By a developer running the parent terraform script. I'd even settle from just me running that parent terraform script.

…r Account (WIP)

- Also refreshes main and backend tfstates with the changes

WIP: I have temporarily set role principal_id to a group my az-cli user is a member of but not a preferred group. Need better options..
@bronius bronius requested a review from joraff November 11, 2024 15:54
…ning two entra users as owners (part of a possible Azure user groups behavior/bug linked in the source code), but even this fails to authorize my same-user to read/write that resource, and it cannot be run twice.
@joraff
Copy link
Contributor

joraff commented Nov 12, 2024

https://learn.microsoft.com/en-us/azure/role-based-access-control/built-in-roles/privileged#owner

Owner's DataActions == none. Simply having the Owner role assignment over the entire subscription does not grant you any permissions to access the data as an Entra ID user. Viable role assignments listed here: https://learn.microsoft.com/en-us/azure/storage/blobs/assign-azure-role-data-access

(TIL)

@bronius
Copy link
Contributor Author

bronius commented Nov 12, 2024 via email

…ng access to the newly created or the inherited backend resource.
@bronius
Copy link
Contributor Author

bronius commented Nov 12, 2024

@joraff Ready for your eyes again. See my string of commits/messages and where I ultimately landed 8ddb05a.

Please review for:

  • "Do not do it like that"
  • Prefer to do it like ... or did you try like..
  • Portability of code sample provided in this feature branch README update, considering my assumption that this module is for our own multi-env terraform scenario which we developed
  • And whatever changes you prescribe are for this PR vs a future enhancement (for which I'd like to see an issue instead)

Note that this resumes idempotency of the module.

I plan to use this commit in actual project work in the meantime, because it has finally given me the distance I needed.

Update LOL: I see that after all the string of experimentation, I did not actually change codebase other than to add one more convenience terraform output.

@bronius bronius marked this pull request as ready for review November 12, 2024 20:24
@bronius bronius changed the title Sets Azure Storage authentication method from Access Key to Entra User Account (WIP) Sets Azure Storage authentication method from Access Key to Entra User Account Nov 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants