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

SSH Connection Refused when using template_cloudinit_config instead of template_file #8201

Closed
iceycake opened this issue Aug 15, 2016 · 6 comments

Comments

@iceycake
Copy link
Contributor

Terraform Version

0.7.1-dev (master branch)

Affected Resource(s)

  • template_cloudinit_config

Terraform Configuration Files

data "template_file" "cloudconfig" {
  template = "${file("cloud-config.yml")}"
}

data "template_cloudinit_config" "cloudconfig" {
  gzip          = false
  base64_encode = false

  part {
    content_type = "text/cloud-config"
    content      = "${data.template_file.cloudconfig.rendered}"
  }
}

Expected Behavior

Able to ssh to the ec2 instance

Actual Behavior

Unable to ssh to the ec2 instance when using this setup. If I switch back to the old template_file resource, everything behaves normal again.

Steps to Reproduce

  1. terraform apply

Important Factoids

  • Running within VPC

References

Not as I can find.

@apparentlymart
Copy link
Member

apparentlymart commented Aug 16, 2016

Hi @iceycake! I'm sorry things didn't work out for you here.

I'm understanding that you've found that setting the EC2 instance user_data to just a standalone YAML file works as you expected, but when you wrap it in a multipart MIME payload using template_cloudinit_config it is no longer behaving as you want.

If possible, it would be helpful if you could share what's appearing in the EC2 instance system log in the case where it doesn't work. You can find the log via the EC2 console here:
ec2_instance_log

Within that log you should find log entries related to cloud-init which I'm hoping will include some indication of what problem was encountered when parsing the multipart MIME version of the configuration.

If you do share the log here on github, please put it on gist and share the link here, and be sure to check and filter any sensitive information the system may have logged while it booted. (SSH key info, access keys, information about your VPC's private IP ranges, etc.)

@iceycake
Copy link
Contributor Author

iceycake commented Aug 16, 2016

@apparentlymart

Nothing is really interesting in the system log (at least for me) ...

Here is a copy of it:

https://gist.github.com/iceycake/25eff06ce492d1f3e53bfe964c0c5c0a

@apparentlymart
Copy link
Member

I can infer from your output that you're using CoreOS... I don't have much experience with that, but I notice that CoreOS has its own alternative to cloud-init, called cloud-config. It seems like cloud-config's config is inspired by cloud-init, but not 100% compatible with it.

I found coreos/bugs#912 which suggests that cloud-config does not support MIME multipart configurations in the same way that cloud-init does. Thus I think that template_cloudinit_config is not compatible with cloud-config and you should probably just stick with using template_file directly.

@iceycake
Copy link
Contributor Author

I see. Thanks for the explanation. In that case, I will just use the template_file data source without using template_cloudinit_config data source.

@blurrcat
Copy link

That's the path I've taken. But with template_file you can't gzip it and it's easy to hit the size limit of user data. Any chance that #3858 can be merged any time soon?

Meanwhile Is there any workaround here?

@ghost
Copy link

ghost commented Apr 22, 2020

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 have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Apr 22, 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

3 participants