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

Fix GCP deployment manager formatting #2529

Closed
wants to merge 1 commit into from
Closed

Conversation

orouz
Copy link
Collaborator

@orouz orouz commented Sep 15, 2024

Summary of your changes

there were 2 issues preventing GCP CSPM on agentless from successfully deploying a service account for organizations. the first was a slightly off copy-paste command in kibana which ended up not passing ORG_ID to the deployment script, so the deployment assumed it's for a project. the second issue, after providing ORG_ID, the deployment script complained about it being a number and not a string (as per its schema). this is what this PR fixes.

after fixing both of these, i've deployed GCP CSPM on agentless and got findings for an organization account:

Screenshot/Data

Screenshot 2024-09-15 at 17 59 46

Related Issues

@@ -35,7 +35,7 @@ fi

result="$(gcloud deployment-manager deployments create --automatic-rollback-on-error "${DEPLOYMENT_NAME}" --project "${PROJECT_NAME}" \
--template service_account.py \
--properties scope:"${SCOPE}",parentId:"${PARENT_ID}",serviceAccountName:"${SERVICE_ACCOUNT_NAME}")"
--properties "scope:'${SCOPE}',parentId:'${PARENT_ID}',serviceAccountName:'${SERVICE_ACCOUNT_NAME}'")"
Copy link
Collaborator Author

@orouz orouz Sep 15, 2024

Choose a reason for hiding this comment

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

this format is required to ensure the values passed are treated as strings

see https://cloud.google.com/sdk/gcloud/reference/deployment-manager/deployments/create

in this specific case, ORG_ID is actually a number, but we need it as a string

@mergify mergify bot assigned orouz Sep 15, 2024
Copy link

mergify bot commented Sep 15, 2024

This pull request does not have a backport label. Could you fix it @orouz? 🙏
To fixup this pull request, you need to add the backport labels for the needed
branches, such as:

  • backport-v./d./d./d is the label to automatically backport to the 8./d branch. /d is the digit
    NOTE: backport-v8.x has been added to help with the transition to the new branch 8.x.

@@ -14,7 +14,7 @@ def generate_config(context):
"name": sa_name,
"type": "iam.v1.serviceAccount",
"properties": {
"accountId": sa_name,
"accountId": f"{sa_name}-id",
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

i'm not entirely sure why this is needed in addition to dependsOn, but i ran into some flakiness when deploying the service account, this seems to fix it.

@orouz
Copy link
Collaborator Author

orouz commented Sep 15, 2024

moved to #2530

@orouz orouz closed this Sep 15, 2024
Copy link

mergify bot commented Sep 15, 2024

⚠️ The sha of the head commit of this PR conflicts with #2530. Mergify cannot evaluate rules on this PR. ⚠️

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.

Agentless service account deployment lacks organization permissions
1 participant