Terraform: cloud-config.yaml script not running on initial EC2 boot
up vote
-1
down vote
favorite
I've created a cloudinit script called "cloud-config.yaml". I want to have ths script executed for each EC2 instance that is launched from my Terraformm launch configuration definition. Everything works except the cloudinit script does not execute on the newly created instances. I'm not sure what I am doing wrong. Any help on where I should look would be appreciated.
Below are the snippets of my code:
#cloud-config
#Enable byobu by default for all system users
byobu_by_default: system
# Update apt database on first boot
# (ie run apt-get update)
#
# Default: true
#
apt_update: false
# Upgrade the instance on first boot
# (ie run apt-get upgrade)
#
# Default: false
#
apt_upgrade: true
#Create user accounts
users:
- name: demo
- sudo: ['ALL=(ALL) NOPASSWD:ALL']
- groups: sudo
- shell: /bin/bash
# Install additional packages on first boot
#
# Default: none
#
# if packages are specified, this apt_update will be set to true
#
packages:
- apache2
- mariadb-client
- software-properties-common
- php
- libapache2-mod-php
- php-mysql
- curl
- wget
- awscli
# Run additional commands on first boot
runcmd:
- ufw disable
- aws s3 sync s3://terraform-web-files/ /var/www/html --recursive
/**************************************************************************
PUBLIC Launch Configuration
***************************************************************************/
//Define the Launch Configuration
resource "aws_launch_configuration" "terraform-public-lc"
image_id = "$var.ami"
instance_type = "$var.instance_type"
security_groups = ["$aws_security_group.tf-public-sg.id"]
key_name = "$var.key_name"
associate_public_ip_address = true
user_data = "$path.module/../../../../Development/services/web-app/cloud-config.yaml"
lifecycle
create_before_destroy = true
amazon-web-services terraform cloud-init terraform-template-file
add a comment |
up vote
-1
down vote
favorite
I've created a cloudinit script called "cloud-config.yaml". I want to have ths script executed for each EC2 instance that is launched from my Terraformm launch configuration definition. Everything works except the cloudinit script does not execute on the newly created instances. I'm not sure what I am doing wrong. Any help on where I should look would be appreciated.
Below are the snippets of my code:
#cloud-config
#Enable byobu by default for all system users
byobu_by_default: system
# Update apt database on first boot
# (ie run apt-get update)
#
# Default: true
#
apt_update: false
# Upgrade the instance on first boot
# (ie run apt-get upgrade)
#
# Default: false
#
apt_upgrade: true
#Create user accounts
users:
- name: demo
- sudo: ['ALL=(ALL) NOPASSWD:ALL']
- groups: sudo
- shell: /bin/bash
# Install additional packages on first boot
#
# Default: none
#
# if packages are specified, this apt_update will be set to true
#
packages:
- apache2
- mariadb-client
- software-properties-common
- php
- libapache2-mod-php
- php-mysql
- curl
- wget
- awscli
# Run additional commands on first boot
runcmd:
- ufw disable
- aws s3 sync s3://terraform-web-files/ /var/www/html --recursive
/**************************************************************************
PUBLIC Launch Configuration
***************************************************************************/
//Define the Launch Configuration
resource "aws_launch_configuration" "terraform-public-lc"
image_id = "$var.ami"
instance_type = "$var.instance_type"
security_groups = ["$aws_security_group.tf-public-sg.id"]
key_name = "$var.key_name"
associate_public_ip_address = true
user_data = "$path.module/../../../../Development/services/web-app/cloud-config.yaml"
lifecycle
create_before_destroy = true
amazon-web-services terraform cloud-init terraform-template-file
2
What do the cloud-init log files under /var/log/ show?
– ydaetskcoR
Nov 10 at 17:52
Reading through the logs I found my error. Thank you!
– Scott Chaffee
Nov 14 at 19:37
Was the error something another user might find? If so you should consider self answering so others might be able to solve the same problem at a later date.
– ydaetskcoR
Nov 14 at 20:40
add a comment |
up vote
-1
down vote
favorite
up vote
-1
down vote
favorite
I've created a cloudinit script called "cloud-config.yaml". I want to have ths script executed for each EC2 instance that is launched from my Terraformm launch configuration definition. Everything works except the cloudinit script does not execute on the newly created instances. I'm not sure what I am doing wrong. Any help on where I should look would be appreciated.
Below are the snippets of my code:
#cloud-config
#Enable byobu by default for all system users
byobu_by_default: system
# Update apt database on first boot
# (ie run apt-get update)
#
# Default: true
#
apt_update: false
# Upgrade the instance on first boot
# (ie run apt-get upgrade)
#
# Default: false
#
apt_upgrade: true
#Create user accounts
users:
- name: demo
- sudo: ['ALL=(ALL) NOPASSWD:ALL']
- groups: sudo
- shell: /bin/bash
# Install additional packages on first boot
#
# Default: none
#
# if packages are specified, this apt_update will be set to true
#
packages:
- apache2
- mariadb-client
- software-properties-common
- php
- libapache2-mod-php
- php-mysql
- curl
- wget
- awscli
# Run additional commands on first boot
runcmd:
- ufw disable
- aws s3 sync s3://terraform-web-files/ /var/www/html --recursive
/**************************************************************************
PUBLIC Launch Configuration
***************************************************************************/
//Define the Launch Configuration
resource "aws_launch_configuration" "terraform-public-lc"
image_id = "$var.ami"
instance_type = "$var.instance_type"
security_groups = ["$aws_security_group.tf-public-sg.id"]
key_name = "$var.key_name"
associate_public_ip_address = true
user_data = "$path.module/../../../../Development/services/web-app/cloud-config.yaml"
lifecycle
create_before_destroy = true
amazon-web-services terraform cloud-init terraform-template-file
I've created a cloudinit script called "cloud-config.yaml". I want to have ths script executed for each EC2 instance that is launched from my Terraformm launch configuration definition. Everything works except the cloudinit script does not execute on the newly created instances. I'm not sure what I am doing wrong. Any help on where I should look would be appreciated.
Below are the snippets of my code:
#cloud-config
#Enable byobu by default for all system users
byobu_by_default: system
# Update apt database on first boot
# (ie run apt-get update)
#
# Default: true
#
apt_update: false
# Upgrade the instance on first boot
# (ie run apt-get upgrade)
#
# Default: false
#
apt_upgrade: true
#Create user accounts
users:
- name: demo
- sudo: ['ALL=(ALL) NOPASSWD:ALL']
- groups: sudo
- shell: /bin/bash
# Install additional packages on first boot
#
# Default: none
#
# if packages are specified, this apt_update will be set to true
#
packages:
- apache2
- mariadb-client
- software-properties-common
- php
- libapache2-mod-php
- php-mysql
- curl
- wget
- awscli
# Run additional commands on first boot
runcmd:
- ufw disable
- aws s3 sync s3://terraform-web-files/ /var/www/html --recursive
/**************************************************************************
PUBLIC Launch Configuration
***************************************************************************/
//Define the Launch Configuration
resource "aws_launch_configuration" "terraform-public-lc"
image_id = "$var.ami"
instance_type = "$var.instance_type"
security_groups = ["$aws_security_group.tf-public-sg.id"]
key_name = "$var.key_name"
associate_public_ip_address = true
user_data = "$path.module/../../../../Development/services/web-app/cloud-config.yaml"
lifecycle
create_before_destroy = true
amazon-web-services terraform cloud-init terraform-template-file
amazon-web-services terraform cloud-init terraform-template-file
asked Nov 9 at 20:40
Scott Chaffee
173
173
2
What do the cloud-init log files under /var/log/ show?
– ydaetskcoR
Nov 10 at 17:52
Reading through the logs I found my error. Thank you!
– Scott Chaffee
Nov 14 at 19:37
Was the error something another user might find? If so you should consider self answering so others might be able to solve the same problem at a later date.
– ydaetskcoR
Nov 14 at 20:40
add a comment |
2
What do the cloud-init log files under /var/log/ show?
– ydaetskcoR
Nov 10 at 17:52
Reading through the logs I found my error. Thank you!
– Scott Chaffee
Nov 14 at 19:37
Was the error something another user might find? If so you should consider self answering so others might be able to solve the same problem at a later date.
– ydaetskcoR
Nov 14 at 20:40
2
2
What do the cloud-init log files under /var/log/ show?
– ydaetskcoR
Nov 10 at 17:52
What do the cloud-init log files under /var/log/ show?
– ydaetskcoR
Nov 10 at 17:52
Reading through the logs I found my error. Thank you!
– Scott Chaffee
Nov 14 at 19:37
Reading through the logs I found my error. Thank you!
– Scott Chaffee
Nov 14 at 19:37
Was the error something another user might find? If so you should consider self answering so others might be able to solve the same problem at a later date.
– ydaetskcoR
Nov 14 at 20:40
Was the error something another user might find? If so you should consider self answering so others might be able to solve the same problem at a later date.
– ydaetskcoR
Nov 14 at 20:40
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53232981%2fterraform-cloud-config-yaml-script-not-running-on-initial-ec2-boot%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
2
What do the cloud-init log files under /var/log/ show?
– ydaetskcoR
Nov 10 at 17:52
Reading through the logs I found my error. Thank you!
– Scott Chaffee
Nov 14 at 19:37
Was the error something another user might find? If so you should consider self answering so others might be able to solve the same problem at a later date.
– ydaetskcoR
Nov 14 at 20:40