2
votes

I have a Terraform script for make a deploy of Ubuntu.

resource "aws_instance" "runner" {
  instance_type = "${var.instance_type}"
  ami = "${var.ami}"
  user_data =   "${data.template_file.deploy.rendered}"
}

data "template_file" "deploy" {
  template = "${file("cloudinit.tpl")}"

}

My cloudinit.tpl:

#cloud-config
runcmd:
  - apt-get update
  - sleep 30
  - apt-get install -y  awscli

I can't find any issue on cloud-init.log and can't find user-data.log file in /var/log to understand why user-data is not working.

1
Why the sleep? Can you post the relevant part of /var/log/cloud-init-output.log? If you view the user data for the instance in the AWS console what does it show?ydaetskcoR
I use sleep for wait to update finish, in /var/log/cloud-init-output.log i have this: E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?mleaf
There's btw. also packages, which also runs apt-get update automatically for you.StephenKing

1 Answers

0
votes

Cloud-init has a special command for system update which carry on about consistency

#cloud-config
package_update: true
package_upgrade: true
packages: ['awscli']

runcmd:
  - aws --version

Than you may see command output in the log file, for Ubuntu it is /var/log/cloud-init-output.log