diff --git a/builder/oracle/oci/config.go b/builder/oracle/oci/config.go index 16e80f2b0..eda312ee2 100644 --- a/builder/oracle/oci/config.go +++ b/builder/oracle/oci/config.go @@ -48,8 +48,12 @@ type Config struct { // Instance InstanceName string `mapstructure:"instance_name"` - // MetaData is optional but will be constructed to include UserData or UserDataFile under the "user_data" key - MetaData map[string]string `mapstructure:"metadata"` + // Metadata optionally contains custom metadata key/value pairs provided in the + // configuration. While this can be used to set metadata["user_data"] the explicit + // "user_data" and "user_data_file" values will have precedence. + // An instance's metadata can be obtained from at http://169.254.169.254 on the + // launched instance. + Metadata map[string]string `mapstructure:"metadata"` // UserData and UserDataFile file are both optional and mutually exclusive. UserData string `mapstructure:"user_data"` diff --git a/builder/oracle/oci/config_test.go b/builder/oracle/oci/config_test.go index b590bf392..51cbb386d 100644 --- a/builder/oracle/oci/config_test.go +++ b/builder/oracle/oci/config_test.go @@ -238,7 +238,6 @@ func TestConfig(t *testing.T) { t.Errorf("Expected ConfigProvider.KeyFingerprint: %s, got %s", expected, fingerprint) } }) - } // BaseTestConfig creates the base (DEFAULT) config including a temporary key diff --git a/builder/oracle/oci/driver_oci.go b/builder/oracle/oci/driver_oci.go index b1386b8c6..138bb6474 100644 --- a/builder/oracle/oci/driver_oci.go +++ b/builder/oracle/oci/driver_oci.go @@ -42,8 +42,8 @@ func (d *driverOCI) CreateInstance(ctx context.Context, publicKey string) (strin metadata := map[string]string{ "ssh_authorized_keys": publicKey, } - if d.cfg.MetaData != nil { - for key, value := range d.cfg.MetaData { + if d.cfg.Metadata != nil { + for key, value := range d.cfg.Metadata { metadata[key] = value } } diff --git a/website/source/docs/builders/oracle-oci.html.md b/website/source/docs/builders/oracle-oci.html.md index b651196d1..e2360a5c1 100644 --- a/website/source/docs/builders/oracle-oci.html.md +++ b/website/source/docs/builders/oracle-oci.html.md @@ -125,7 +125,9 @@ builder. - `use_private_ip` (boolean) - Use private ip addresses to connect to the instance via ssh. - - `metadata` (map of strings) - Metadata to be injected in the build instance. + - `metadata` (map of strings) - Metadata optionally contains custom metadata key/value pairs provided in the +configuration. While this can be used to set metadata["user_data"] the explicit "user_data" and "user_data_file" values will have precedence. An instance's metadata can be obtained from at http://169.254.169.254 on the +launched instance. - `user_data` (string) - user_data to be used by cloud init. See [the Oracle docs](https://docs.us-phoenix-1.oraclecloud.com/api/#/en/iaas/20160918/LaunchInstanceDetails) for more details. Generally speaking, it is easier to use the `user_data_file`,