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

terraform crash with ec2 instance when trying to use user_data with a map #460

Closed
solarce opened this issue Oct 20, 2014 · 8 comments
Closed

Comments

@solarce
Copy link

solarce commented Oct 20, 2014

crash.log from when I tried to launch a new instance, when trying to use user_data with a map

 user_data {
    hostname = "${var.user_data_hostname}"
    fqdn = "${var.user_data_fqdn}"
  }
@solarce solarce changed the title terraform crash with ec2 instance that was still in terraform.tfstate but had been deleted via aws console terraform crash with ec2 instance when trying to use user_data with a map Oct 20, 2014
@mitchellh
Copy link
Contributor

Thanks, I see you updated the title, is that the new way to get a repro? Can I just set some user data to a map and get this with our without state?

@solarce
Copy link
Author

solarce commented Oct 20, 2014

@solarce
Copy link
Author

solarce commented Oct 20, 2014

I realize that http://www.terraform.io/docs/providers/aws/r/instance.html#user_data doesn't say it's a map, but I assumed it would be one and I haven't looked at the source code, so if I'm going down the wrong path to use user_data, please do let me know

@mitchellh
Copy link
Contributor

User data is a string. Tags are a map.

The issue here looks like our validator is not catching the invalid type for user data. Should be easy enough to fix, but haven't looked into it yet.

@solarce
Copy link
Author

solarce commented Oct 20, 2014

What should it look like? (Can you tell I haven't used user data much?)

I'm trying to replace passing the following to knife ec2 server

cat /var/lib/rundeck/staging_users.cloud_config
#cloud-config
hostname: @@HOSTNAME@@
fqdn: @@FQDN@@
manage_etc_hosts: true

@mitchellh
Copy link
Contributor

@solarce
Copy link
Author

solarce commented Oct 20, 2014

Thanks. For completeness sake.

  1. I found Unclear how to add user_data to an aws_instance #145, which pointed me at using the file() function
  2. The following worked for me

variable

variable "user_data" {
    description = "EC2 instance user data"
}

resource

  # user data for instance
  user_data = "${file(var.user_data)}"

argument
-var user_data=/tmp/instance.cloud_config

@mitchellh
Copy link
Contributor

Fixed crash

@ghost ghost locked and limited conversation to collaborators May 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants