简体   繁体   中英

Configure terraform to connect to IBM Cloud

I try to connect terraform to IBM Cloud and I got messed up with Softlayer and IBM Cloud credentials.

I followed the instruction on IBM sites to connect my terraform to the IBM Cloud and I am confused, because I may use SL and IBM Cloud connec- tion information like API-keys etc.

I may not run terraform init and/or plan, because there are some information missing. No I am asked for the organization (var.org). Sometimes I got asked about the SL credentials. Our account started in January 2019 and I am sure not to worked with SL at all and only heard about API key from IBM cloud.

May some one have an example, how terraform.tfvars looks like to work properly together with IBM Cloud Kubernetes Service, VPC and classic infrastructure?

Thank you very much.

Jan

I recommend starting to take a look at these two tutorials, dealing with a LAMP stack on classic vertical servers and with Kubernetes and other services . Both provide step by step instructions and guide you through the process of setting up Terraform-based deployments.

They provide the necessary code in GitHub repos . For the Kubernetes sample credentials.tfvars you only need the API key :

ibmcloud_api_key = "your api key"

For the public_key a string containing the public key should be provided instead of a file that contains the key.

$ cat ~/.ssh/id_rsa.pub
ssh-rsa CCCde...

Then in terraform:

resource "ibm_compute_ssh_key" "test_ssh_key" {
    public_key = "ssh-rsa CCCde..."
}

Alternatively you can use a key that you created earlier:

data "ibm_compute_ssh_key" "ssh_key" {
    label =  "yourexistingkey"
}

resource "ibm_compute_vm_instance" "onprem_vsi" {
  ssh_key_ids       = ["${data.ibm_compute_ssh_key.ssh_key.id}"]
}

thank you for the answer with the link. I get a working plan and the opportinity to apply the plan für the LAMP stack. The missing item here is the Infrastructure API key and I found it in the depth of IAM.

Well, I get now

ibm_compute_ssh_key.ssh_key: Creating...
  fingerprint: "" => "<computed>"
  label:       "" => "public ssh key - VM"
  notes:       "" => "SSH_note"
  public_key:  "" => "/home/palic/Files/Projects/IaaC-Terraform-IBM/IBM/LAMP-terraform-ibm/pl.pub"

Error: Error applying plan:

1 error occurred:
        * ibm_compute_ssh_key.ssh_key: 1 error occurred:
        * ibm_compute_ssh_key.ssh_key: Invalid public key specified :/home/palic/Files/Projects/IaaC-Terraform-IBM/IBM/LAMP-terraform-ibm/pl.pub
Please check the value of public_key

and I am pretty sure, that I am able to create working ssh-key (one is already uploaded into IBM Cloud console. I created this key and I deleted this key in IBM and get the same error. I get this error with a complete new installed ssh- key. I do not understand this error.

May anyone help me here with that?

Thank you in advance and have a nice weekend.

Jan

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM