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

* aws_instance.instance: unexpected EOF #6532

Closed
jbanmene opened this issue Nov 20, 2018 · 6 comments · Fixed by #9003
Closed

* aws_instance.instance: unexpected EOF #6532

jbanmene opened this issue Nov 20, 2018 · 6 comments · Fixed by #9003
Assignees
Labels
bug Addresses a defect in current functionality. crash Results from or addresses a Terraform crash or kernel panic. service/ec2 Issues and PRs that pertain to the ec2 service.
Milestone

Comments

@jbanmene
Copy link

jbanmene commented Nov 20, 2018

Community Note

Hi there,

when i'm trying to launch a new instance,my terraform failed with error:

  • aws_instance.Microsoft_Instance: unexpected EOF
    A part of my config related to my instance below

Terraform Version

Terraform v0.11.10

  • provider.aws v1.46.0
  • provider.template v1.0.0

Affected Resource(s)

  • aws_instances

Terraform Configuration Files

my instance module

#Setting Provider
provider "aws" {
  region = "${var.region}"
}

#Setting User data
data "template_file" "user_data" {
  template = "${file("..\\..\\..\\Files\\user_data.txt")}"

  vars {
    envVariable     = "Vendor:${var.Vendor}#Product:${var.Product}#Action:${var.Action}#AvailableName:${var.Available_Name}#TargetOU:${var.Target_OU}"
    BootstrapPrefix = "${var.BootstrapPrefix}"
    Environment     = "${var.Environment}"
    SetupScripts    = "${var.SetupScripts}"
    ArchiveType     = "${var.ArchiveType}"
  }
}

#Setting aws Instance
data "aws_ami" "ami_base" {
filter {
  name = "tag:Name"
  values = ["${var.ami}"]
}
most_recent = true
}

resource "aws_instance" "Microsoft_Instance" {
  key_name             = "${var.key_name}"
  iam_instance_profile = "${var.iam_instance_profile}"
  ami                    = "${data.aws_ami.ami_base.id}"
  instance_type          = "${var.instance_type}"
  vpc_security_group_ids = ["${split(",",var.vpc_security_group_ids)}"]
  subnet_id              = "${var.subnet_id}"
  private_ip             = "${var.private_ip}"

  tags {
    Application = "${var.Tag_Application}"
    dependency  = "${var.Tag_Dependency}"
    depends_id  = "${var.depends_id}"
    Name = "${var.Available_Name}"
  }
  root_block_device {
    volume_type = "${var.volume_type}"
    volume_size = "${var.rootVolume_size}"
  }

  credit_specification {
    cpu_credits = "${var.cpu_credit}"
  }
  user_data = "${data.template_file.user_data.rendered}"
}
output "private_ip" {
  value = "${aws_instance.Microsoft_Instance.private_ip}"
}

Debug Output

Panic Output

https://gist.github.com/jbanmene/642f5d8edecbd2abd6f50c92751aec6f

Expected Behavior

create an instance

Actual Behavior

Terraform crashes

Steps to Reproduce

terraform apply

  1. terraform apply

Important Factoids

References

  • #0000
@radekg
Copy link

radekg commented Nov 20, 2018

It could be related to your template = "${file("..\..\..\Files\user_data.txt")}". I wonder if it would be fine with template = "${file("${path.module}/../../../Files\user_data.txt")}".

@jbanmene
Copy link
Author

all my module calls the userdata that way,
It is a windows machine

I think I find the root cause, I change the provider version from 1.46. to 1.4.0 and my code works
maybe someone from terraform could confirm that aws provider 1.46 have issues

@jbanmene
Copy link
Author

well it's not the provider version either, the crash is because of the credit_specification , I launch a T3 instance and I didn't set the value for cpu_credit.

@nywilken nywilken added bug Addresses a defect in current functionality. crash Results from or addresses a Terraform crash or kernel panic. service/ec2 Issues and PRs that pertain to the ec2 service. labels Feb 5, 2019
@nywilken
Copy link
Contributor

Hi @jbanmene are you still having issues here? There's been a number of changes to the aws_instance resource since this issue was reported. If you are still having issues would you mind testing with the latest provider release.

If your issue has been resolved please close this issue; adding any relevant information as a comment.

Cheers!

@nywilken nywilken added the waiting-response Maintainers are waiting on response from community or contributor. label May 13, 2019
nywilken added a commit that referenced this issue Jun 14, 2019
Fixes: #6532

When given an empty credit_specification block (i.e cpu_credits is missing) the Terraform provider
will crash upon trying to type assert on the empty (nil) block. This check introduces a guard clause around the type assertion
to protect around the empty (nil) block. A warning is logged to indicated that a default value will be used in place of the missing
value.

Acceptance tests after changes
```
--- PASS: TestAccAWSInstance_creditSpecification_unknownCpuCredits_t2
--- PASS: TestAccAWSInstance_creditSpecification_unknownCpuCredits_t3
```
@nywilken nywilken added this to the v2.16.0 milestone Jun 14, 2019
nywilken added a commit that referenced this issue Jun 18, 2019
Fixes: #6532

When given an empty credit_specification block (i.e cpu_credits is missing) the Terraform provider
will crash upon trying to type assert on the empty (nil) block. This check introduces a guard clause around the type assertion
to protect around the empty (nil) block. A warning is logged to indicated that a default value will be used in place of the missing
value.

Acceptance tests after changes
```
--- PASS: TestAccAWSInstance_creditSpecification_unknownCpuCredits_t2
--- PASS: TestAccAWSInstance_creditSpecification_unknownCpuCredits_t3
```
nywilken added a commit that referenced this issue Jun 20, 2019
Fixes: #6532

When given an empty credit_specification block (i.e cpu_credits is missing) the Terraform provider
will crash upon trying to type assert on the empty (nil) block. This check introduces a guard clause around the type assertion
to protect around the empty (nil) block. A warning is logged to indicated that a default value will be used in place of the missing
value.

Acceptance tests after changes
```
--- PASS: TestAccAWSInstance_creditSpecification_unknownCpuCredits_t2
--- PASS: TestAccAWSInstance_creditSpecification_unknownCpuCredits_t3
```
nywilken added a commit that referenced this issue Jun 20, 2019
…#9003)

Fixes: #6532

When given an empty credit_specification block (i.e cpu_credits is missing) the Terraform provider
will crash upon trying to type assert on the empty (nil) block. This check introduces a guard clause around the type assertion
to protect around the empty (nil) block. A warning is logged to indicated that a default value will be used in place of the missing
value.

Acceptance tests after changes
```
--- PASS: TestAccAWSInstance_creditSpecification_unknownCpuCredits_t2
--- PASS: TestAccAWSInstance_creditSpecification_unknownCpuCredits_t3
```
@bflad
Copy link
Contributor

bflad commented Jun 20, 2019

This has been released in version 2.16.0 of the Terraform AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

@ghost
Copy link

ghost commented Nov 3, 2019

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked and limited conversation to collaborators Nov 3, 2019
@ghost ghost removed the waiting-response Maintainers are waiting on response from community or contributor. label Nov 3, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. crash Results from or addresses a Terraform crash or kernel panic. service/ec2 Issues and PRs that pertain to the ec2 service.
Projects
None yet
4 participants