diff --git a/builder/oracle/oci/config.go b/builder/oracle/oci/config.go index 052e07ab2..2e40489e1 100644 --- a/builder/oracle/oci/config.go +++ b/builder/oracle/oci/config.go @@ -276,11 +276,18 @@ func (c *Config) Prepare(raws ...interface{}) error { errs, errors.New("'shape' must be specified")) } - if c.SubnetID == "" { + if (c.SubnetID == "") && (c.CreateVnicDetails.SubnetId == nil) { errs = packer.MultiErrorAppend( errs, errors.New("'subnet_ocid' must be specified")) } + if c.CreateVnicDetails.SubnetId == nil { + c.CreateVnicDetails.SubnetId = &c.SubnetID + } else if (*c.CreateVnicDetails.SubnetId != c.SubnetID) && (c.SubnetID != "") { + errs = packer.MultiErrorAppend( + errs, errors.New("'create_vnic_details[subnet]' must match 'subnet_ocid' if both are specified")) + } + if (c.BaseImageID == "") && (c.BaseImageFilter == ListImagesRequest{}) { errs = packer.MultiErrorAppend( errs, errors.New("'base_image_ocid' or 'base_image_filter' must be specified")) diff --git a/builder/oracle/oci/driver_oci.go b/builder/oracle/oci/driver_oci.go index bd3cb24be..8e572441e 100644 --- a/builder/oracle/oci/driver_oci.go +++ b/builder/oracle/oci/driver_oci.go @@ -124,7 +124,6 @@ func (d *driverOCI) CreateInstance(ctx context.Context, publicKey string) (strin FreeformTags: d.cfg.InstanceTags, Shape: &d.cfg.Shape, SourceDetails: InstanceSourceDetails, - SubnetId: &d.cfg.SubnetID, Metadata: metadata, }