简体   繁体   English

配置 terraform 以连接到 IBM Cloud

[英]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.我尝试将 terraform 连接到 IBM Cloud,但我搞砸了 Softlayer 和 IBM Cloud 凭证。

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.我按照 IBM 网站上的说明将我的 terraform 连接到 IBM Cloud,但我很困惑,因为我可能会使用 SL 和 IBM Cloud 连接信息,例如 API 密钥等。

I may not run terraform init and/or plan, because there are some information missing.我可能不会运行 terraform init 和/或 plan,因为缺少一些信息。 No I am asked for the organization (var.org).不,我被要求提供组织(var.org)。 Sometimes I got asked about the SL credentials.有时我会被问到有关 SL 凭据的问题。 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.我们的帐户是在 2019 年 1 月开始的,我确定根本没有与 SL 合作过,只听说过来自 IBM 云的 API 密钥。

May some one have an example, how terraform.tfvars looks like to work properly together with IBM Cloud Kubernetes Service, VPC and classic infrastructure?有人可以举个例子,terraform.tfvars 如何与 IBM Cloud Kubernetes Service、VPC 和经典基础架构一起正常工作?

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 .我建议开始看看这两个教程,处理经典垂直服务器上LAMP 堆栈以及Kubernetes 和其他服务 Both provide step by step instructions and guide you through the process of setting up Terraform-based deployments.两者都提供分步说明并指导您完成设置基于 Terraform 的部署的过程。

They provide the necessary code in GitHub repos .他们在GitHub repos 中提供了必要的代码。 For the Kubernetes sample credentials.tfvars you only need the API key :对于Kubernetes 示例凭据.tfvars,您只需要 API 密钥

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.对于 public_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. 我得到了一个工作计划,并且有机会将该计划应用于LAMP堆栈。 The missing item here is the Infrastructure API key and I found it in the depth of IAM. 此处缺少的项目是Infrastructure API密钥,我在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. 并且我非常确定,我能够创建有效的ssh-key(一个已经上传到IBM Cloud控制台中。我创建了此密钥,并在IBM中删除了此密钥,并得到了相同的错误。新安装的ssh- key,我不了解此错误。

May anyone help me here with that? 有人可以帮我吗?

Thank you in advance and have a nice weekend. 提前谢谢您,祝您周末愉快。

Jan 一月

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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