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

Comply with the Google Cloud impersonate library #2052

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

fgateuil
Copy link

Update code to comply with the must-use Google Coud impersonate library.

@fgateuil
Copy link
Author

fgateuil commented Apr 2, 2022

I couldn't find any integration tests to test this new way of using Google impersonation. Could you help me please? Is there any Google Cloud project that I could use? Note that with the one I'm using, it's working fine but it's relatively subjective.
Thanks for the help.

@fgateuil fgateuil changed the title WIP: Comply with the Google Cloud impersonate library Comply with the Google Cloud impersonate library Apr 2, 2022
@denis256
Copy link
Member

denis256 commented Apr 3, 2022

Hi,
I think it will be helpful to create a test for this, maybe create service accounts and try to impersonate, GCP project is defined during tests execution through env variable GOOGLE_CLOUD_PROJECT

@dennislapchenko
Copy link

@denis256 @yorinasub17 @fgateuil GCS double impersonation is still big sore thumb :( can I assist you in writing tests to make this pass? Just couple pointers and I'll be happy to speed up this PR.

@denis256
Copy link
Member

Hello,
CI job passed so there is regression after changes, local test with impersonate_service_account also worked, I will look if will be possible to enable impersonation for the service account used in integration tests

@fgateuil
Copy link
Author

Hi @denis256. Thanks your reply.
Let me know if you need me regarding the impersonation configuration. Even if I don't have any access to the GCP project used by the integration tests, I might help you a bit.

@denis256
Copy link
Member

denis256 commented Jun 1, 2022

Hi,
I was thinking about basic test like: https://github.com/gruntwork-io/terragrunt/compare/denis-gs-test to track in future that impersonate_service_account will continue to work

@fgateuil
Copy link
Author

fgateuil commented Feb 2, 2023

Hi, I was thinking about basic test like: https://github.com/gruntwork-io/terragrunt/compare/denis-gs-test to track in future that impersonate_service_account will continue to work

Hmmm, @denis256 it's not that simple. To test the impersonate mechanism, some prerequisites are necessary.

Test 1:

  • Prerequisites:
    • main_sa_1 owns a single basic (testable) permission/role, let's say roles/editor role for instance to be allowed to create a new GCS bucket;
    • principal_sa_1 owns the Service Account Token Creator permission over main_sa_1 (as explained here);
  • Test:
    • Set impersonate_service_account value to principal_sa_1's email;
    • Create a GCS bucket ==> it must succeed.

Test 2:

  • Prerequisites:
    • main_sa_2 doesn't own any permission/role so that he isn't allowed to create any GCS bucket;
    • principal_sa_2 owns the Service Account Token Creator permission over main_sa_2;
  • Test:
    • Set impersonate_service_account value to principal_sa_2's email;
    • Create a GCS bucket ==> it must fail.

Thus, I need few service accounts and roles preconfigured to be able to test the impersonate mechanism and I'm not convinced it's already the case here.

@yamadayutaka
Copy link

Hi @fgateuil , @denis256.
I modified the implementation slightly based on this pull request.
I also implemented the test code.
Could you please check this pull request? #2550

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.

None yet

4 participants