terraformibm-cloudobject-storageterraform-provider-ibm

IBM Cloud: How to create HMAC credentials for COS using Terraform?


I am using IBM Cloud Object Storage (COS) to store files on IBM Cloud. I have used Terraform to provision the service and to create the storage bucket. How can I create credentials including the HMAC portion using Terraform?

This is how to create the resource key (credentials):

# service access key for COS
resource "ibm_resource_key" "MyCos" {
  name                 = "my-accKey-cos"
  role                 = "Writer"
  resource_instance_id = ibm_resource_instance.cos.id
}

Solution

  • The key to creating HMAC credentials is to have the right parameters for ibm_resource_key.

    # service access key for COS
    resource "ibm_resource_key" "MyCos" {
      name                 = "my-accKey-cos"
      role                 = "Writer"
      resource_instance_id = ibm_resource_instance.cos.id
      parameters           = { HMAC = true }
    }
    

    With the added parameter for HMAC it works.

    In that sense it is similar to using the CLI.