Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .web-docs/components/builder/oci/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ based on which authentication method is used.
- `use_instance_principals` (boolean) - Whether to use [Instance
Principals](https://docs.cloud.oracle.com/en-us/iaas/Content/Identity/Tasks/callingservicesfrominstances.htm)
instead of User Principals. If this key is set to true, setting any one of the `access_cfg_file`,
`access_cfg_file_account`, `region`, `tenancy_ocid`, `user_ocid`, `key_file`, `fingerprint`,
`access_cfg_file_account`, `region`, `tenancy_ocid`, `user_ocid`, `key`, `key_file`, `fingerprint`,
`pass_phrase` parameters will cause an invalid configuration error.
Defaults to `false`.

Expand Down Expand Up @@ -135,6 +135,11 @@ or configured for the default OCI CLI authenticaton profile.
[OCI config file](https://docs.us-phoenix-1.oraclecloud.com/Content/API/Concepts/sdkconfig.htm)
if present. This cannot be used along with the `use_instance_principals` key.

- `key` (string) - The contents of the OCI API signing key. Overrides value provided by the `key_file`.
This cannot be used along with the `use_instance_principals` key. Also, the `key` is meant to be used with dynamic secret fetching,
for example, [`aws_secretsmanager` function](https://developer.hashicorp.com/packer/docs/templates/hcl_templates/functions/contextual/aws_secretsmanager),
storing secrets in a versioning system should be avoided.

- `key_file` (string) - Full path and filename of the OCI API signing key. Overrides value provided
by the [OCI config file](https://docs.us-phoenix-1.oraclecloud.com/Content/API/Concepts/sdkconfig.htm)
if present. This cannot be used along with the `use_instance_principals` key.
Expand Down
9 changes: 9 additions & 0 deletions builder/oci/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ type Config struct {
TenancyID string `mapstructure:"tenancy_ocid"`
Region string `mapstructure:"region"`
Fingerprint string `mapstructure:"fingerprint"`
Key string `mapstructure:"key"`
KeyFile string `mapstructure:"key_file"`
PassPhrase string `mapstructure:"pass_phrase"`
UsePrivateIP bool `mapstructure:"use_private_ip"`
Expand Down Expand Up @@ -211,6 +212,9 @@ func (c *Config) Prepare(raws ...interface{}) error {
if c.Fingerprint != "" {
errs = packersdk.MultiErrorAppend(errs, errors.New("fingerprint"+message))
}
if c.Key != "" {
errs = packersdk.MultiErrorAppend(errs, errors.New("key"+message))
}
if c.KeyFile != "" {
errs = packersdk.MultiErrorAppend(errs, errors.New("key_file"+message))
}
Expand Down Expand Up @@ -246,6 +250,7 @@ func (c *Config) Prepare(raws ...interface{}) error {
c.AccessCfgFileAccount = "DEFAULT"
}

// Read API signing key
var keyContent []byte
if c.KeyFile != "" {
path, err := pathing.ExpandUser(c.KeyFile)
Expand All @@ -259,7 +264,11 @@ func (c *Config) Prepare(raws ...interface{}) error {
return err
}
}
if c.Key != "" {
keyContent = []byte(c.Key)
}

// Providers
fileProvider, _ := ocicommon.ConfigurationProviderFromFileWithProfile(c.AccessCfgFile, c.AccessCfgFileAccount, c.PassPhrase)
if c.Region == "" {
var region string
Expand Down
2 changes: 2 additions & 0 deletions builder/oci/config.hcl2spec.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions builder/oci/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,7 @@ func TestConfig(t *testing.T) {
"tenancy_ocid",
"region",
"fingerprint",
"key",
"key_file",
"pass_phrase",
}
Expand Down
7 changes: 6 additions & 1 deletion docs/builders/oci.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ based on which authentication method is used.
- `use_instance_principals` (boolean) - Whether to use [Instance
Principals](https://docs.cloud.oracle.com/en-us/iaas/Content/Identity/Tasks/callingservicesfrominstances.htm)
instead of User Principals. If this key is set to true, setting any one of the `access_cfg_file`,
`access_cfg_file_account`, `region`, `tenancy_ocid`, `user_ocid`, `key_file`, `fingerprint`,
`access_cfg_file_account`, `region`, `tenancy_ocid`, `user_ocid`, `key`, `key_file`, `fingerprint`,
`pass_phrase` parameters will cause an invalid configuration error.
Defaults to `false`.

Expand Down Expand Up @@ -142,6 +142,11 @@ or configured for the default OCI CLI authenticaton profile.
[OCI config file](https://docs.us-phoenix-1.oraclecloud.com/Content/API/Concepts/sdkconfig.htm)
if present. This cannot be used along with the `use_instance_principals` key.

- `key` (string) - The contents of the OCI API signing key. Overrides value provided by the `key_file`.
This cannot be used along with the `use_instance_principals` key. Also, the `key` is meant to be used with dynamic secret fetching,
for example, [`aws_secretsmanager` function](https://developer.hashicorp.com/packer/docs/templates/hcl_templates/functions/contextual/aws_secretsmanager),
storing secrets in a versioning system should be avoided.

- `key_file` (string) - Full path and filename of the OCI API signing key. Overrides value provided
by the [OCI config file](https://docs.us-phoenix-1.oraclecloud.com/Content/API/Concepts/sdkconfig.htm)
if present. This cannot be used along with the `use_instance_principals` key.
Expand Down
Loading