Skip to content

Commit 00a8786

Browse files
authored
Allow disabling default service account for assemble_gcp (#220)
## What is the goal of this PR? Previously, `packer` always attached a default service account to GCP instance it created. In case it did not exist it failed with a timeout and cryptic error message. ## What are the changes implemented in this PR? Allow to create instances without a service account attached (which is fine if you're not doing any calls to GCP APIs during image creation)
1 parent 79e556c commit 00a8786

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

gcp/packer.template.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
"image_name": "{image_name}",
1515
"image_family": "{image_family}",
1616
"image_licenses": {image_licenses},
17-
"disk_size": 20
17+
"disk_size": 20,
18+
"disable_default_service_account": {disable_default_service_account}
1819
}
1920
],
2021

gcp/rules.bzl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ def assemble_gcp(name,
2929
image_family="",
3030
files=None,
3131
image_licenses=None,
32+
disable_default_service_account=False,
3233
source_image_family="ubuntu-1604-lts"):
3334
"""Assemble files for GCP deployment
3435
@@ -41,6 +42,7 @@ def assemble_gcp(name,
4142
image_family: family of deployed image
4243
files: Files to include into GCP deployment
4344
image_licenses: licenses to attach to deployed image
45+
disable_default_service_account: disable default service account
4446
source_image_family: Family of GCP base image
4547
"""
4648
if not files:
@@ -58,6 +60,7 @@ def assemble_gcp(name,
5860
"{image_licenses}": "[\"{}\"]".format(image_licenses) if image_licenses else "[]",
5961
"{install}": install_fn,
6062
"{source_image_family}": source_image_family,
63+
"{disable_default_service_account}": str(disable_default_service_account).lower()
6164
}
6265
)
6366
files[install] = install_fn

0 commit comments

Comments
 (0)