Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

utf8 encoding issue with terraform/aws/public-cloud/*.tf files #162

Open
cmcconnell1 opened this issue Sep 9, 2016 · 0 comments
Open

utf8 encoding issue with terraform/aws/public-cloud/*.tf files #162

cmcconnell1 opened this issue Sep 9, 2016 · 0 comments

Comments

@cmcconnell1
Copy link

Hello,
I tried to push my fixes in my local branch (and would then do a PR) but don't have access to push to your kubeform repo.

This is regarding kubeform and a blocker with terraform get to download and update modules

When trying to follow the kubeform doc and do a 'terraform get'
Get 'Error loading kubeform/terraform/aws/public-cloud/masters.tf: Error reading config for template_file[master_cloud_init]: parse error: syntax error'

For me on both MacOS and CentOS linux It appears as perhaps the syntax / encoding is incorrect and fails on every .tf file if present

Solution worked for me:
I converted all of the terraform .tf files via UTF8 encode BTW just used this site (http://www.cafewebmaster.com/online_tools/utf8_encode)

kubeform/terraform/aws/public-cloud $ ls -lat *.tf
-rw-r--r-- 1 cmcc staff 2389 Sep 9 10:27 workers.tf
-rw-r--r-- 1 cmcc staff 2525 Sep 9 10:26 masters.tf
-rw-r--r-- 1 cmcc staff 6485 Sep 9 10:26 main.tf
-rw-r--r-- 1 cmcc staff 2469 Sep 9 10:25 edge-routers.tf

Note that after converting all above .tf files to utf8 encoding I was then was able to re-run 'terraform get' which got further along but failed again when it encountered another problematic .tf file: .terraform/modules/343c43072a8336916caae1b54b403824/main.tf

full terminal output below:

cmcc@makena:~/GIT/kubeform/terraform/aws/public-cloud $ terraform get
Get: git::https://github.com/terraform-community-modules/tf_aws_virttype.git
Get: git::https://github.com/terraform-community-modules/tf_aws_coreos_ami.git
Get: file:///Users/cmcc/GIT/kubeform/terraform/aws/keypair
Get: git::https://github.com/Capgemini/tf_tls.git
Get: git::https://github.com/Capgemini/tf_tls.git
Get: git::https://github.com/Capgemini/tf_tls.git
Get: git::https://github.com/Capgemini/tf_tls.git
Get: git::https://github.com/Capgemini/tf_tls.git
Get: git::https://github.com/Capgemini/tf_tls.git
Get: git::https://github.com/Capgemini/tf_tls.git
Get: git::https://github.com/terraform-community-modules/tf_aws_igw.git
Get: git::https://github.com/terraform-community-modules/tf_aws_public_subnet.git
Get: file:///Users/cmcc/GIT/kubeform/terraform/aws/sg-all-traffic
Get: file:///Users/cmcc/GIT/kubeform/terraform/aws/iam
Error loading Terraform: Error downloading modules: module iam: Error loading .terraform/modules/343c43072a8336916caae1b54b403824/main.tf: Error reading config for aws_iam_role[master_role]: parse error: syntax error

So following the same process noted above and I converted .terraform/modules/343c43072a8336916caae1b54b403824/main.tf to utf8_encode and I was again able to continue and re-run 'terraform get' where it continued and got farhter still but failed with
Error loading Terraform: module edge-router_ami.root: 1 error(s) occurred:

  • output 'ami_id': unknown variable referenced: 'all_amis'. define it with 'variable' blocks

full shell output below:

$ terraform get
Get: git::https://github.com/terraform-community-modules/tf_aws_virttype.git
Get: git::https://github.com/terraform-community-modules/tf_aws_coreos_ami.git
Get: file:///Users/cmcc/GIT/kubeform/terraform/aws/keypair
Get: git::https://github.com/Capgemini/tf_tls.git
Get: git::https://github.com/Capgemini/tf_tls.git
Get: git::https://github.com/Capgemini/tf_tls.git
Get: git::https://github.com/Capgemini/tf_tls.git
Get: git::https://github.com/Capgemini/tf_tls.git
Get: git::https://github.com/Capgemini/tf_tls.git
Get: git::https://github.com/Capgemini/tf_tls.git
Get: git::https://github.com/terraform-community-modules/tf_aws_igw.git
Get: git::https://github.com/terraform-community-modules/tf_aws_public_subnet.git
Get: file:///Users/cmcc/GIT/kubeform/terraform/aws/sg-all-traffic
Get: file:///Users/cmcc/GIT/kubeform/terraform/aws/iam
Get: git::https://github.com/terraform-community-modules/tf_aws_virttype.git
Get: git::https://github.com/terraform-community-modules/tf_aws_coreos_ami.git
Get: file:///Users/cmcc/GIT/kubeform/terraform/aws/elb
Get: git::https://github.com/terraform-community-modules/tf_aws_virttype.git
Get: git::https://github.com/terraform-community-modules/tf_aws_coreos_ami.git
Error loading Terraform: module edge-router_ami.root: 1 error(s) occurred:

  • output 'ami_id': unknown variable referenced: 'all_amis'. define it with 'variable' blocks

Here is what seems to be the problem--my changes below after converting the files to utf8 encoding in my local 'feature/fix' branch:

git diff masters.tf
diff --git a/terraform/aws/public-cloud/masters.tf b/terraform/aws/public-cloud/masters.tf
index 7f6668b..eef2d53 100644
--- a/terraform/aws/public-cloud/masters.tf
+++ b/terraform/aws/public-cloud/masters.tf
@@ -17,9 +17,9 @@ resource "template_file" "master_cloud_init" {
etcd_discovery_url = "${file(var.etcd_discovery_url_file)}"
size = "${var.masters}"
region = "${var.region}"

  • etcd_ca = "${replace(module.ca.ca_cert_pem, "\n", "\n")}"
  • etcd_cert = "${replace(module.etcd_cert.etcd_cert_pem, "\n", "\n")}"
  • etcd_key = "${replace(module.etcd_cert.etcd_private_key, "\n", "\n")}"
  • etcd_ca = "${replace(module.ca.ca_cert_pem, "n", "\n")}"
  • etcd_cert = "${replace(module.etcd_cert.etcd_cert_pem, "n", "\n")}"
  • etcd_key = "${replace(module.etcd_cert.etcd_private_key, "n", "\n")}"
    }
    }

git diff ../iam/main.tf
diff --git a/terraform/aws/iam/main.tf b/terraform/aws/iam/main.tf
index 64079a2..84a9fe3 100644
--- a/terraform/aws/iam/main.tf
+++ b/terraform/aws/iam/main.tf
@@ -2,13 +2,13 @@
resource "aws_iam_role" "master_role" {
name = "master_role"
path = "/"

  • assume_role_policy = "${file("${path.module}/master-role.json")}"
  • assume_role_policy = "${file("${path.module}/master-role.json")}"
    }

resource "aws_iam_role_policy" "master_policy" {
name = "master_policy"
role = "${aws_iam_role.master_role.id}"

  • policy = "${file("${path.module}/master-policy.json")}"
  • policy = "${file("${path.module}/master-policy.json")}"
    }

resource "aws_iam_instance_profile" "master_profile" {
@@ -20,13 +20,13 @@ resource "aws_iam_instance_profile" "master_profile" {
resource "aws_iam_role" "worker_role" {
name = "worker_role"
path = "/"

  • assume_role_policy = "${file("${path.module}/worker-role.json")}"
  • assume_role_policy = "${file("${path.module}/worker-role.json")}"
    }

resource "aws_iam_role_policy" "worker_policy" {
name = "worker_policy"
role = "${aws_iam_role.worker_role.id}"

  • policy = "${file("${path.module}/worker-policy.json")}"
  • policy = "${file("${path.module}/worker-policy.json")}"
    }

resource "aws_iam_instance_profile" "worker_profile" {
@@ -38,13 +38,13 @@ resource "aws_iam_instance_profile" "worker_profile" {
resource "aws_iam_role" "edge-router_role" {
name = "edge-router_role"
path = "/"

  • assume_role_policy = "${file("${path.module}/edge-router-role.json")}"
  • assume_role_policy = "${file("${path.module}/edge-router-role.json")}"
    }

resource "aws_iam_role_policy" "edge-router_policy" {
name = "edge-router_policy"
role = "${aws_iam_role.edge-router_role.id}"

  • policy = "${file("${path.module}/edge-router-policy.json")}"
  • policy = "${file("${path.module}/edge-router-policy.json")}"
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant