Skip to content

Commit 68826f0

Browse files
Merge pull request #55 from n3xtio/feat/secure-boot
feat: add secure boot option to instance
2 parents b07c8e5 + aebecda commit 68826f0

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,22 @@ To this end, this provider supports the following extra specs schema:
164164
"type": "boolean",
165165
"description": "Enable boot debug on the VM."
166166
},
167+
"disable_updates": {
168+
"type": "boolean",
169+
"description": "Disable OS updates on boot."
170+
},
171+
"enable_secure_boot": {
172+
"type": "boolean",
173+
"desctipyion": "Enable Secure Boot on the VM. Requires a Shielded VM compatible image."
174+
},
175+
"enable_vtpm": {
176+
"type": "boolean",
177+
"desctipyion": "Enable virtual Trusted Platform Module (vTPM) on the VM."
178+
},
179+
"enable_integrity_monitoring": {
180+
"type": "boolean",
181+
"desctipyion": "Enable integrity monitoring on the VM."
182+
},
167183
"runner_install_template": {
168184
"type": "string",
169185
"description": "This option can be used to override the default runner install template. If used, the caller is responsible for the correctness of the template as well as the suitability of the template for the target OS. Use the extra_context extra spec if your template has variables in it that need to be expanded."

internal/client/gcp.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,11 @@ func (g *GcpCli) CreateInstance(ctx context.Context, spec *spec.RunnerSpec) (*co
173173
Items: spec.NetworkTags,
174174
},
175175
ServiceAccounts: spec.ServiceAccounts,
176+
ShieldedInstanceConfig: &computepb.ShieldedInstanceConfig{
177+
EnableSecureBoot: proto.Bool(spec.EnableSecureBoot),
178+
EnableVtpm: proto.Bool(spec.EnableVTPM),
179+
EnableIntegrityMonitoring: proto.Bool(spec.EnableIntegrityMonitoring),
180+
},
176181
}
177182

178183
if !g.cfg.ExternalIPAccess {

internal/spec/spec.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,10 @@ type extraSpecs struct {
141141
SSHKeys []string `json:"ssh_keys,omitempty" jsonschema:"description=A list of SSH keys to be added to the instance. The format is USERNAME:SSH_KEY"`
142142
EnableBootDebug *bool `json:"enable_boot_debug,omitempty" jsonschema:"description=Enable boot debug on the VM."`
143143
DisableUpdates *bool `json:"disable_updates,omitempty" jsonschema:"description=Disable OS updates on boot."`
144+
// Shielded VM options
145+
EnableSecureBoot bool `json:"enable_secure_boot,omitempty" jsonschema:"description=Enable Secure Boot on the VM. Requires a Shielded VM compatible image."`
146+
EnableVTPM bool `json:"enable_vtpm,omitempty" jsonschema:"description=Enable virtual Trusted Platform Module (vTPM) on the VM."`
147+
EnableIntegrityMonitoring bool `json:"enable_integrity_monitoring,omitempty" jsonschema:"description=Enable integrity monitoring on the VM."`
144148
// The Cloudconfig struct from common package
145149
cloudconfig.CloudConfigSpec
146150
}
@@ -197,6 +201,10 @@ type RunnerSpec struct {
197201
SSHKeys string
198202
EnableBootDebug bool
199203
DisableUpdates bool
204+
// Shielded VM options
205+
EnableSecureBoot bool
206+
EnableVTPM bool
207+
EnableIntegrityMonitoring bool
200208
}
201209

202210
func (r *RunnerSpec) MergeExtraSpecs(extraSpecs *extraSpecs) {
@@ -241,6 +249,15 @@ func (r *RunnerSpec) MergeExtraSpecs(extraSpecs *extraSpecs) {
241249
if extraSpecs.DisableUpdates != nil {
242250
r.DisableUpdates = *extraSpecs.DisableUpdates
243251
}
252+
if extraSpecs.EnableSecureBoot {
253+
r.EnableSecureBoot = extraSpecs.EnableSecureBoot
254+
}
255+
if extraSpecs.EnableVTPM {
256+
r.EnableVTPM = extraSpecs.EnableVTPM
257+
}
258+
if extraSpecs.EnableIntegrityMonitoring {
259+
r.EnableIntegrityMonitoring = extraSpecs.EnableIntegrityMonitoring
260+
}
244261
}
245262

246263
func (r *RunnerSpec) Validate() error {

0 commit comments

Comments
 (0)