fix(0-bootstrap): take the organization id explicitly in import.sh - #215
Open
scottonix wants to merge 1 commit into
Open
fix(0-bootstrap): take the organization id explicitly in import.sh#215scottonix wants to merge 1 commit into
scottonix wants to merge 1 commit into
Conversation
import.sh assigned ORG from 'gcloud organizations list', which returns one line per organization the caller can see. Any deployer with access to more than one organization (a consultancy account, a shared service account) got a multi-line value spliced into every policy resource name, and the generated imports.tf referenced organizations that do not exist. import.sh now takes the organization id as its first argument or from ORGANIZATION_ID, and only falls back to gcloud when exactly one organization is visible; with several it fails with a message naming them instead of generating bad imports. deploy.sh passes ORGANIZATION_ID, as it already does for setIAM.sh and enableServices.sh. Signed-off-by: Scott McDonald <scott.mcdonald@onixnet.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
fast/stages-aw/0-bootstrap/import.shassigns the organization fromgcloud organizations list --format='value(ID)', which prints one line per organization the caller can see. For any deployer with access to more than one organization — a consultancy account, a shared automation identity —ORGbecomes a multi-line string that is spliced into every policy resource name, and the generatedimports.tfreferences organizations that do not exist.import.shnow takes the organization id as its first argument or fromORGANIZATION_ID, and only falls back togcloud organizations listwhen exactly one organization is visible; with several it exits with a message naming them instead of generating bad imports.scripts/deploy.shpasses${ORGANIZATION_ID}, exactly as it already does forsetIAM.shandenableServices.sh.Type of Change
Deployment & Compliance Impact
importblocks for the org policies the stage already manages).Checklist
Code Quality & Reusability
modules/orfast/can be leveraged for this change.documentation/naming-convention.md.Documentation
README.mdof the modified module or blueprint. (The README does not describeimport.sh's inputs; the comment in the script now does.)Security
Testing
Testing Performed
bash -nandshellcheck(all severities) onimport.sh: clean, before and after.The organization-selection block was exercised against a stub
gcloudonPATH:ORG= the argument, gcloud not consultedORGANIZATION_IDset, no argumentORG= the variableORG= that organizationmore than one organization is visible (111 222). Pass the organization ID as the first argument or set ORGANIZATION_ID.Failed to get organization ID.(unchanged message)Observed originally on a deployment whose deployer could see two organizations: the previous script produced a two-line
ORGand animports.tfwith malformed ids.