Softlayer Api Authentication with Terraform

716 views Asked by At

I exported the SL_USERNAME and SL_API_KEY variables. I did not link my softlayer account to bluemix.

Command:

terraform import ibmcloud_infra_vlan.999 999

Error:

import ibmcloud_infra_vlan.999 result: 999: ibmcloud_infra_vlan.999: Error communicating with the API: SoftLayer_Exception_Public: Access Denied.  (HTTP 401)

Does this mean user doesn't have permission for API calls?

2

There are 2 answers

0
pdna On BEST ANSWER

So username seems to be the API Username. Not the one you see in the users page.

And VLAN ID is in the URL. https://control.softlayer.com/network/vlans/vlanid

The same goes for all the other resource ID's.

And you have to modify allowed IP's for the user you are using.

1
Albert Camacho On

I'm not familiar with Terraform but this post may help you How do I create a SoftLayer Vlan using Terraform?.

To know if you are able to made a request using your username and api key you can perform a single REST call using a client or any web browser.

Following is an example you can use to verify API access. It should returns information about your SL account.

https://[userName]:[apiKey]@api.softlayer.com/rest/v3/SoftLayer_Account/getObject

Method: GET

Replace [userName] and [apiKey] with your own data. If response says "Access Denied". I recommend you verify if userName and apiKey are correct using the Control portal (Profile).

Take account that API user should be able to perform same actions he is able to do in Control portal page. For example, if user isn't able to see vlans then he will not be able to do it through API.