Skip to content

Conversation

@jose-pablo-camacho
Copy link
Contributor

@jose-pablo-camacho jose-pablo-camacho commented Sep 6, 2024

xref: https://sysdig.atlassian.net/browse/SSPROD-46145

This is a WIP for providing TF snippets to enable GCP APIs to customer so they don't have to do it manually.

All is working and the APIs are enabled properly for the GCP project and organization. The only thing that needs to be done is the scrapping of the folders within a GCP organization since the google_projects resource only provides the root projects within the organization and not the ones within folders, basically for a scenario like:

  • MyOrg
    • MyProject1
    • MyProject2
    • MyFolder1
      • MyProject3

The google_projects resource is only retrieving the projects: MyProject1 and MyProject2. In order to change this I'll need to use another resource that grabs the folders and create a recursive functionality to scrape all the Org - working on this already.

Update:
This was done via a null_resource resource in TF, basically this resource makes some API calls using gcloud and the context of the user machine to create a recursive function that scrapes the whole organization, after that a json file is saved to the local directory and then this is used to create the API enablement resources.

TF does not let a plan or apply step without knowing the data that it's going to be scraped so a target apply needs to be done prior since the null_resource is only executed during an apply, the command will be:

terraform init && terraform apply -target=null_resource.get_projects_from_folders --auto-approve && terraform apply --auto-approve

With this command, we make sure that the projects from folder are picked before starting the API enablement. It's also an easier way to avoid more work for the user.

@jose-pablo-camacho jose-pablo-camacho marked this pull request as ready for review September 6, 2024 21:58
@jose-pablo-camacho jose-pablo-camacho requested a review from a team as a code owner September 6, 2024 21:58
@haresh-suresh
Copy link
Contributor

haresh-suresh commented Sep 8, 2024

LGTM, let's add the folders list + projects underneath each to the final projects list and we can merge this 👍

@haresh-suresh
Copy link
Contributor

@jose-pablo-camacho Talked to @claffin for feedback, let's stick to TF inline calling the bash script to recursively call it for now, as you have it 👍 We will then get some feedback from PS (Support) team next to see if they find it useful.

@jose-pablo-camacho
Copy link
Contributor Author

@haresh-suresh Sounds good! So let me know if it looks good, I can merge this

Copy link
Contributor

@haresh-suresh haresh-suresh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jose-pablo-camacho jose-pablo-camacho merged commit 24dce9b into master Sep 10, 2024
@jose-pablo-camacho jose-pablo-camacho deleted the feat/modular/enable-gcp-apis branch September 10, 2024 19:08
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.

3 participants