0

I was looking at the pre-defined LAMP stack for Amazon ec2 instance template on Bluemix and found the following piece of code:

"awsPHPInstance": {
            "source": "git::https://github.com/camc-experimental/terraform-modules.git?ref=master//aws/ami_instance",
            "aws_ami": "${module.find_ami.aws_ami}",
            "aws_instance_type": "t2.micro",
            "aws_subnet_id": "${module.awsNetwork.subnet_id}",
            "aws_security_group_id": "${module.awsNetwork.application_security_group_id}",
            "aws_cam_public_key_id": "${aws_key_pair.cam_lamp_public_key.id}",
            "hostname": "${var.php_instance_name}",
            "module_script": "files/createCAMUser.sh",
            "module_script_name": "createCAMUser.sh",
            "module_script_variable_1": "${var.cam_user}",
            "module_script_variable_2": "${var.cam_pwd}"
        }

I am not very clear about "module_script": "files/createCAMUser.sh". Where is this file's folder which has the shell script in it exactly? From what I understand, we can only have single page standalone terraform template.

codec
  • 7,978
  • 26
  • 71
  • 127
  • Please provide a link to the template that you are referencing. – William 'Bill' Wentworth May 31 '17 at 21:05
  • Its also referenced here https://cam-proxy-ng.ng.bluemix.net/cam/instances/#!/deployTemplateEditorWithNoParam/e7b40c0dca9bf7d4ef807bc0b8f0e56c `"module_script": "files/installMongoDB.sh"` I understood that it is coming for the github link referenced in the resource. But what if I want to reference .pem file which I cannot upload on github? How can I reference an external file in CAM terraform file? – codec Jun 01 '17 at 05:27

1 Answers1

0

For your first question, the script is actually located within the module structure in the git repo. When terraform is run from CAM, it does a "terraform get" which pulls in everything from "source": "git::https://github.com/camc-experimental/terraform-modules.git?ref=master//aws/ami_instance"

The script file is actually packaged within the module in a folder named "files"

The module uses the following syntax to reference the file:

data "template_file" "default" { template = "${file("${path.module}/${var.module_script}")}"

For your second question, one possible solution is to base64 encode the contents of the pem file and pass it into your template as an input string versus trying to read it from a file