Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions fast/stages-aw/0-bootstrap/import.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,20 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# Assign Organization ID
ORG=$(gcloud organizations list --format='value(ID)')
# Assign Organization ID: first argument, then ORGANIZATION_ID from the
# environment, then gcloud - but only when exactly one organization is
# visible. A deployer that can see several organizations gets a multi-line
# list back, which would otherwise be spliced into every policy resource name
# below.
ORG="${1:-${ORGANIZATION_ID:-}}"
if [[ -z "${ORG}" ]]; then
mapfile -t orgs < <(gcloud organizations list --format='value(ID)' | sed '/^[[:space:]]*$/d')
if [[ ${#orgs[@]} -gt 1 ]]; then
echo "Error: more than one organization is visible (${orgs[*]}). Pass the organization ID as the first argument or set ORGANIZATION_ID." >&2
exit 1
fi
ORG="${orgs[0]:-}"
fi
if [[ -z "${ORG}" ]]; then
echo "Error: Failed to get organization ID." >&2
exit 1
Expand Down
2 changes: 1 addition & 1 deletion scripts/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -964,7 +964,7 @@ EOF
fi # End of state_migrated check

# Import Organization Polcies
handle_prompt "Would you like to import recommended org policies?" "${SCRIPT_DIR}/../fast/stages-aw/0-bootstrap/import.sh" || true
handle_prompt "Would you like to import recommended org policies?" "${SCRIPT_DIR}/../fast/stages-aw/0-bootstrap/import.sh ${ORGANIZATION_ID}" || true

# Terraform Apply #3 (after state migration, ensuring bootstrap user access)
cmd=("terraform apply -auto-approve -var bootstrap_user=$(gcloud config list --format 'value(core.account)')")
Expand Down