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

Add Automation Service Accounts Output #2640

Merged
merged 7 commits into from
Nov 17, 2024

Conversation

joshw123
Copy link
Contributor


Checklist

I applicable, I acknowledge that I have:

  • Read the contributing guide
  • Ran terraform fmt on all modified files
  • Regenerated the relevant README.md files using tools/tfdoc.py
  • Made sure all relevant tests pass

@joshw123 joshw123 changed the title Add output Add Automation Service Accounts Output Oct 28, 2024
@ludoo ludoo self-requested a review October 28, 2024 09:33
@ludoo
Copy link
Collaborator

ludoo commented Oct 28, 2024

Thanks for this PR, can you address the linting errors?

@juliocc
Copy link
Collaborator

juliocc commented Oct 28, 2024

Hey @joshw123, thanks for this PR. I had a similar issue recently and decided to go with something like this in the FAST stage.

output "projects" {
  description = "Created projects."
  value = {
    for k, v in module.projects.projects : k => {
      number     = v.number
      project_id = v.id
      automation_buckets = {
        for kk, vv in module.projects.automation_buckets :
        trimprefix(kk, "${k}/") => vv.name
        if startswith(kk, "${k}/")
      }
      automation_service_accounts = {
        for kk, vv in module.projects.automation_service_accounts :
        trimprefix(kk, "${k}/") => vv.email
        if startswith(kk, "${k}/")
      }
    }
  }
}

This links the actual automation service account to the project that created it, and it also gives you the buckets as well.

What do you think?

@joshw123
Copy link
Contributor Author

Hey @joshw123, thanks for this PR. I had a similar issue recently and decided to go with something like this in the FAST stage.

output "projects" {
  description = "Created projects."
  value = {
    for k, v in module.projects.projects : k => {
      number     = v.number
      project_id = v.id
      automation_buckets = {
        for kk, vv in module.projects.automation_buckets :
        trimprefix(kk, "${k}/") => vv.name
        if startswith(kk, "${k}/")
      }
      automation_service_accounts = {
        for kk, vv in module.projects.automation_service_accounts :
        trimprefix(kk, "${k}/") => vv.email
        if startswith(kk, "${k}/")
      }
    }
  }
}

This links the actual automation service account to the project that created it, and it also gives you the buckets as well.

What do you think?

Ah nice, Yeah this is a nicer way of doing it :) Thank You

@joshw123
Copy link
Contributor Author

Hey @joshw123, thanks for this PR. I had a similar issue recently and decided to go with something like this in the FAST stage.

output "projects" {
  description = "Created projects."
  value = {
    for k, v in module.projects.projects : k => {
      number     = v.number
      project_id = v.id
      automation_buckets = {
        for kk, vv in module.projects.automation_buckets :
        trimprefix(kk, "${k}/") => vv.name
        if startswith(kk, "${k}/")
      }
      automation_service_accounts = {
        for kk, vv in module.projects.automation_service_accounts :
        trimprefix(kk, "${k}/") => vv.email
        if startswith(kk, "${k}/")
      }
    }
  }
}

This links the actual automation service account to the project that created it, and it also gives you the buckets as well.

What do you think?

Have you got a PR open for this already @juliocc Thank You!

@juliocc
Copy link
Collaborator

juliocc commented Oct 28, 2024

@joshw123 I don't have any open PR for it. Feel free to include it directly in yours.

@joshw123
Copy link
Contributor Author

Ready to Approve when you are @juliocc @ludoo Thank You! :)

@juliocc juliocc enabled auto-merge (squash) October 28, 2024 17:51
@ludoo ludoo disabled auto-merge November 1, 2024 07:57
@juliocc juliocc enabled auto-merge (squash) November 17, 2024 17:15
@juliocc juliocc merged commit 2676010 into GoogleCloudPlatform:master Nov 17, 2024
14 checks passed
@joshw123
Copy link
Contributor Author

Thank You for taking a look at this @juliocc I completely forgot about it tbh 😄 ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants