Skip to content

Conversation

@hrvolapeter
Copy link

Add functionality for Oracle Cloud (OCI) and it's KMS.

Implements authentication using DEFAULT profile which is read from ~/.oci/config file

Signed-off-by: Peter Hrvola <[email protected]>
@felixfontein
Copy link
Contributor

Related: #1226


func (key *MasterKey) newKMSClient() (*kms.KmsCryptoClient, error) {
// Right now only implements authentication using default profile
configProvider := common.DefaultConfigProvider()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather not have this just be the default config provider. Here's some reasons:

  1. It doesn't work with any sort of standard environment variables. The TF_VAR_* stuff is in there, but no OCI_* or OCI_CLI_*
  2. It doesn't work with the security_token auth that you get when you use SSO / SAML / Federation stuff.
  3. It requires you always create a ~/.oci/config which is a pain when you're running somewhere temporary, like in a container, and might not have proper users, etc.

I've written a small library that could help: https://github.com/ontariosystems/oci-cli-env-provider

It uses the semi-standard OCI_CLI_* environment variables used by the oci cli.

So what I'd do here is change it get the provider that way, and include the instance identity provider so we can run it on compute instances too (which I definitely need sops to be able to do).

import "github.com/ontariosystems/oci-cli-env-provider"

func (key *MasterKey) newKMSClient() (*kms.KmsCryptoClient, error) {
	configProvider, err := configurationProvider()
	if err != nil {
		return nil, err 
	}

	// ...
}

func configurationProvider() (common.ConfigurationProvider, error) {
	var providers []common.ConfigurationProvider

	providers = append(providers, ocep.DefaultConfigProvider())
	ip, err := auth.InstancePrincipalConfigurationProvider()
	if err != nil {
		return nil, err
	}
	providers = append(providers, ip)

	return common.ComposingConfigurationProvider(providers)
}

I've added a similar comment on #1226

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants