diff --git a/terraform/vsphere/cloud-init.tpl b/terraform/vsphere/cloud-init.tpl index 6bc6066e..3473ba64 100644 --- a/terraform/vsphere/cloud-init.tpl +++ b/terraform/vsphere/cloud-init.tpl @@ -14,6 +14,12 @@ write_files: content: ${tpl_priv_key} path: /tmp/id_rsa permissions: '0600' + - content: | + [default] + aws_access_key_id = ${tpl_aws_access_key_id} + aws_secret_access_key = ${tpl_aws_secret_access_key} + path: /tmp/credentials + permissions: '0600' runcmd: - while [ ! -f "/tmp/env.sh" ]; do sleep 5; done diff --git a/terraform/vsphere/main.tf b/terraform/vsphere/main.tf index 7a9afa3e..8757443c 100644 --- a/terraform/vsphere/main.tf +++ b/terraform/vsphere/main.tf @@ -165,6 +165,8 @@ resource "local_file" "cloud-init" { { tpl_priv_key = base64encode(tls_private_key.ssh.private_key_openssh), tpl_pub_key = tls_private_key.ssh.public_key_openssh, + tpl_aws_access_key_id = var.aws_access_key_id + tpl_aws_secret_access_key = var.aws_secret_access_key tpl_name = each.value.instance_name, tpl_cluster = each.value.cluster }) diff --git a/terraform/vsphere/variables.tf b/terraform/vsphere/variables.tf index c7b109f7..3ead0c8d 100644 --- a/terraform/vsphere/variables.tf +++ b/terraform/vsphere/variables.tf @@ -95,4 +95,14 @@ variable "vsphere_dns" { description = "vSphere VM DNS" type = string default = "" +} + +variable "aws_access_key_id" { + description ="AWS Access Key" + type = string +} + +variable "aws_secret_access_key" { + description ="AWS Secret Access Key" + type = string } \ No newline at end of file diff --git a/vsphere.go b/vsphere.go index d8be50b2..237d71d5 100644 --- a/vsphere.go +++ b/vsphere.go @@ -237,6 +237,8 @@ func vsphere_create_variables(config *Config) []string { tf_variables = append(tf_variables, "vsphere_network = \""+config.Vsphere_Network+"\"") tf_variables = append(tf_variables, "vsphere_memory = \""+config.Vsphere_Memory+"\"") tf_variables = append(tf_variables, "vsphere_cpu = \""+config.Vsphere_Cpu+"\"") + tf_variables = append(tf_variables, "aws_access_key_id = \""+config.Aws_Access_Key_Id+"\"") + tf_variables = append(tf_variables, "aws_secret_access_key = \""+config.Aws_Secret_Access_Key+"\"") if (config.Vsphere_Dns != "") && (config.Vsphere_Gw != "") && (config.Vsphere_Node_Ip != "") { tf_variables = append(tf_variables, "vsphere_dns = \""+config.Vsphere_Dns+"\"")