Skip to content

Commit 0e850b6

Browse files
author
yugarora
committed
I've added support for disabling legacy IMDS endpoints in the OCI builder.
This introduces a new boolean option, , to the OCI builder configuration. When you set this to true, the launched OCI instance will be configured to disable the legacy IMDSv1 endpoints. This enhances security by enforcing the use of IMDSv2.
1 parent 34510cb commit 0e850b6

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

builder/oci/config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ type Config struct {
118118
Shape string `mapstructure:"shape"`
119119
ShapeConfig FlexShapeConfig `mapstructure:"shape_config"`
120120
BootVolumeSizeInGBs int64 `mapstructure:"disk_size"`
121+
InstanceOptionsAreLegacyImdsEndpointsDisabled *bool `mapstructure:"instance_options_are_legacy_imds_endpoints_disabled" required:"false"`
121122

122123
// Metadata optionally contains custom metadata key/value pairs provided in the
123124
// configuration. While this can be used to set metadata["user_data"] the explicit

builder/oci/driver_oci.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,12 @@ func (d *driverOCI) CreateInstance(ctx context.Context, publicKey string) (strin
161161
InstanceSourceDetails.BootVolumeSizeInGBs = &d.cfg.BootVolumeSizeInGBs
162162
}
163163

164+
// Build instance options
165+
instanceOptions := core.InstanceOptions{}
166+
if d.cfg.InstanceOptionsAreLegacyImdsEndpointsDisabled != nil {
167+
instanceOptions.AreLegacyImdsEndpointsDisabled = d.cfg.InstanceOptionsAreLegacyImdsEndpointsDisabled
168+
}
169+
164170
// Build instance details
165171
instanceDetails := core.LaunchInstanceDetails{
166172
AvailabilityDomain: &d.cfg.AvailabilityDomain,
@@ -172,6 +178,7 @@ func (d *driverOCI) CreateInstance(ctx context.Context, publicKey string) (strin
172178
Shape: &d.cfg.Shape,
173179
SourceDetails: InstanceSourceDetails,
174180
Metadata: metadata,
181+
InstanceOptions: &instanceOptions,
175182
}
176183

177184
if d.cfg.ShapeConfig.Ocpus != nil {

docs/builders/oci.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,8 @@ or configured for the default OCI CLI authenticaton profile.
165165
- `instance_name` (string) - The name to assign to the instance used for the image creation process.
166166
If not set a name of the form `instanceYYYYMMDDhhmmss` will be used.
167167

168+
- `instance_options_are_legacy_imds_endpoints_disabled` (boolean) - If this is set to true, legacy IMDSv1 endpoints will be disabled on the instance. Defaults to `false`.
169+
168170
- `instance_tags` (map of strings) - Add one or more freeform tags to the instance used for the
169171
image creation process.
170172

0 commit comments

Comments
 (0)