Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
-1 votes
0 answers
30 views

Terraform user data script for EC2 instance failed while running aws configure command

I faced up with a situation when EC2 user_data script failed with Python RuntimeError. User_data script: #!/bin/bash sudo apt-get -q update && sudo apt-get -q upgrade sudo snap install kubectl ...
Andrew Savelyev's user avatar
-2 votes
1 answer
380 views

Get IPs as string/list in Terraform

I'm beginning by creating a few machines: resource "aws_instance" "servers" { count = 20 instance_type = "t2.micro" ........................... } and then, I want ...
Ioana Popescu's user avatar
0 votes
1 answer
398 views

Handling JSON string in EC2 userdata

I am trying to provision an EC2 instance using terraform, passing a cloudinit configuration file as userdata to the instance. As part of the cloudinit config I am setting environment variables and ...
Andrew Kew's user avatar
  • 3,353
0 votes
0 answers
46 views

Unable to map a string value passed in Terraform with text value in Jenkins

I am trying to pass AWS EC2 Userdata in Jenkins as a variable. Source code is in terraform, main.tf as shown below: userdata = var.web_userdata` variables.tf: `variable "web_userdata" { ...
subhasmita's user avatar
0 votes
2 answers
14k views

How to check if a key exists in terraform map, within user_data template code?

I would like to check if I need to run an installation script stored in the s3 bucket. If the configuration does have an s3 bucket, then download and run the installer in my variables.tf, I have ...
gk_2000's user avatar
  • 341
0 votes
1 answer
55 views

cloudinit output shows eipalloc-09e7274dd3c641ae6: value too great for base (error token is "09e7274dd3c641ae6")

I'm trying to associate the Elastic IP address with Auto scaling group, so whenever the autoscaling triggers it will automatically associate with the EIP. For this I'm trying to add the script in user ...
Aravind's user avatar
  • 17
1 vote
1 answer
843 views

Terraform throwing this error Getting Extra characters after interpolation expression;

I'm trying to associate the Elastic IP address with Auto scaling group, so whenever the autoscaling triggers it will automatically associate with the EIP. For this I'm trying to add the script in ...
Aravind's user avatar
  • 17
0 votes
0 answers
288 views

Acces Terraform user-data variables through a Powershells script running on an EC2

I'm working on automating some software installation on Windows AWS EC2. My infrastructure as a dev environment and a prod environment. So to handle that i'm trying to pass through user data some ...
Clarence's user avatar
1 vote
0 answers
98 views

AWS User Data Script - Dependency Installation Failure

I have a simple user_data script that I am applying to am aws_launch_template inside of a terraform module. resource "aws_launch_tempalte "host" { ... user_data = filebase64(".....
Andy's user avatar
  • 738
1 vote
2 answers
3k views

"Invalid function argument" with Userdata in Terraform

I'm trying to pass user data over a file so the code will look less clumsy, but having trouble. I've tried all the different combinations but nothing is working. I went through the Terraform ...
thirudk's user avatar
  • 11
6 votes
1 answer
3k views

Terraform user_data output in terraform output

I creating EC2 instance with Terraform, which includes also user_data, my question is can I see the output of linux command from user_data in terraform output. Ex. .... user_data = <<EOF echo &...
devops212123's user avatar
9 votes
2 answers
7k views

Terraform EC2 User Data Changes Not Replacing The EC2

I've noticed recently Terraform or AWS has made a change EC2 userdata so that changes don't trigger a 'replace' in terraform. Quote Terraform aws_instance docs: Updates to this field will trigger a ...
MattTDickinson's user avatar
1 vote
2 answers
8k views

Using Terraform user_data with Windows Powershell

I am trying to create Windows EC2 instance, and I want to change its hostname immediately after creation. I was trying to do it with user_data, but it looks like never gets executed. Does anyone know ...
Sake's user avatar
  • 21
1 vote
1 answer
2k views

Terraform aws_launch_template user_data variables separation (local and ec2 execution)

In my user-data, I have: export INSTANCEID=$(curl -s http://169.254.169.254/latest/meta-data/instance-id) And Terraform: resource "aws_launch_template" "launch_template" { ...
Roman Newaza's user avatar
  • 11.7k
1 vote
2 answers
2k views

terraform create aws ami from instance with userdata

I'm using terraform. I need to create ec2 instance with user data (that install several packages any other things). From this ec2 I need to create ami with same user data. Does terraform "wait&...
Daniele's user avatar
  • 604
1 vote
1 answer
1k views

Terraform, Windows, Userdata with a batch script

I have a batch script called Windows_network_adp.bat. The contents are: <script> netsh interface ipv4 set address name="Ethernet 3" static 10.*.*.* 255.*.*.* </script> It ...
Kimberley 's user avatar
0 votes
1 answer
132 views

User_data of aws_instance not executed at launch

I'm trying to pass some post deployment configuration on an AWS instance used as a gitlab runner but the script is not executed. No errors shown after applying the script. Any ideas where the issue is ...
9rnt's user avatar
  • 106
1 vote
1 answer
4k views

How to call text files as user-data in Terraform without UTF-8 encoding?

Terraform version: v1.0.4 I am experimenting with user_data attribute for EC2 instances. Here are the contents of a .txt file that I am trying to use at the moment, #cloud-config aws_image: true ...
Rahul Tyagi's user avatar
0 votes
1 answer
44 views

unable to launch docker while creating instance with terraform script

Following is .tf script resource "aws_instance" "zk" { ami = var.ami_id_zk instance_type = var.instance_type count = "1" vpc_security_group_ids=[...
Niladri Dey's user avatar
1 vote
2 answers
4k views

How to set environment variable for ec2 user_data with terraform templatefile

I'd like to run myscript.sh with terraform templatefile. I set the variable password as environment variable in EC2. But, the script doesn't work well as I start the instance. Here is files I wrote. ...
Steave Stark's user avatar
6 votes
3 answers
9k views

terraform minor aws user_data change "forces replacement" - What Is The Best Resolution?

I have made a minor change (comments only) to my AWS EC2 user_data bootstrap bash script. Terraform has detected this, and now wants to replace the EC2 with a new one. But this is a live service, and ...
P Burke's user avatar
  • 1,762
0 votes
2 answers
4k views

Terraform: How to copy files from s3 to ec2

I have a terraform configuration that creates an autoscaling group and a launch configuration as well as an s3 bucket and populates the bucket with a number of files. Is there a way to copy the files ...
Hammed's user avatar
  • 1,557
4 votes
1 answer
7k views

Why is userdata not working in my Terraform code?

I am working with Terraform and trying to execute bash script using user date. Below is my code: resource "aws_instance" "web_server" { ami = var.centos ...
Keimille's user avatar
  • 435
0 votes
1 answer
2k views

Terraform: accessing EC2 instance with apache installed on the bowser using public IP address just keeps loading, loading and loading

I am deploying an EC2 instance to AWS using terraform. I am using user data section of EC2 to install apache. This is my template. terraform { required_providers { aws = { source = "...
Wai Yan Hein's user avatar
  • 14.7k
1 vote
1 answer
1k views

Can't execute AWS CLI command with user_data in Terraform

I am using Terraform to spin up an EC2-instance where I have defined some user_data. In the user_data I download AWS CLI and set up the config file and credentials file. I then want to grab a file ...
Chronospear's user avatar
1 vote
2 answers
4k views

Can i pass variables to AWS EC2 instances created with terraform and user_data? Or update an already created resource

I’m new on learning terraform with AWS and by i understand i can create an EC2 instances and pass it some Terminal commands (via “user_data”) in order to install software, etc… I wonder if i can i ...
Diego Camilo Peña Ramirez's user avatar
2 votes
1 answer
2k views

Unable to register ec2 instance into ECS using terraform

I am unable to register the ec2 instance into the ecs cluster, I have created the cluster, service and registered the task into it. But the ec2 instance is not registered. I have given the userdata to ...
user avatar
1 vote
1 answer
2k views

Give rds endpoint to user data using Terraform

I want to pass the endpoint from rds to bash script how can I pass it to the bash script I am using terraform. I am using module structure, getting output from the rds module and giving it to ec2 ...
user avatar
1 vote
1 answer
940 views

AWS: Attaching ASG to an EKS Cluster

I am trying to create an Autoscaling group with spot instances and attach it to the EKS cluster as worker nodes via terraform. I thought of giving the script to attach ASG to EKS cluster as userdata. ...
coder here's user avatar
1 vote
1 answer
335 views

Unable to Launch EC2 Instances Asynchronously via Terraform

I am willing to launch two instances via Terraform. First one will generate some certificate files, push to S3 bucket. The second instance will pull those certificates from particular S3 bucket. Both ...
Casca's user avatar
  • 155
0 votes
1 answer
1k views

How to use user_data url when creating an AWS instance in terraform?

Terraform Version = 0.12 data "template_file" "user_data" { template = file("${path.module}/userdata.sh") } resource "aws_instance" "bespin-ec2-web-a" { ami = "ami-0bea7fd38fabe821a" ...
sangyul lee's user avatar
0 votes
1 answer
314 views

bash -x /var/lib/cloud/instance/user-data.txt runs but user-data from terraform gives error

I am trying to run a script using terraform. The content of the user-data is as follows: . . cat <<EOH | java -jar ./jenkins-cli.jar -s $JENKINS_URL -auth admin:$PASSWORD create-credentials-by-...
Ismail's user avatar
  • 809
3 votes
2 answers
2k views

generate user_data including "IP Address" while creating ec2 instance using terraform

I am trying to spin 2 ec2 instances using terraform. Something like this resource "aws_instance" "example" { count = "${var.number_of_instances}" ami ...
devnull's user avatar
  • 161
0 votes
1 answer
179 views

Best way to modify IPv4 address of instance in route53 record set on instance terminate

I have 1 public EC2 instance in my aws account. To access the service (kibana) of that instance I have created route53 record set. I have done this using Terraform. Now my question is, If my ...
Jayesh Dhandha's user avatar
0 votes
0 answers
2k views

Terraform - AWS EC2 Instance - Userdata is available on the device but does not run when I apply the template

I've been struggling with this issue for the last few days. I have an instance that is created using a terraform template with userdata that is specified from a template file. The instance uses the ...
sciorms's user avatar
  • 171
1 vote
1 answer
3k views

How can I create a custom Linux AMI with Packer that accepts user data

The goal is to create an AMI that the end user can customize by including an external database or other instance specific configuration. I have created a custom image that pulls down some assets from ...
thejames42's user avatar
1 vote
0 answers
3k views

terraform user-data not working though rendered

I am creating an ec2 machine and when it is up, I want docker installed in it and add itself to rancher server the terraform script for the same is provider "aws" { region = "ap-south-1" } ...
ArjunDandagi's user avatar
1 vote
1 answer
3k views

Terraform: User Data not rendered

Using terraform to run some user data upon instance creation: user_data = "${template_file.user_data.rendered}" Here is the definition: resource "template_file" "user_data" { template = "files/...
pkaramol's user avatar
  • 19.1k
15 votes
2 answers
22k views

Multiple user_data File use in Terraform

I am trying to have a common user_data file for common tasks such as folder creation and certain package install and a separate user_data file for application specific configuration I am trying the ...
Rohit Sarkar's user avatar
5 votes
2 answers
7k views

How ro run a shell script on aws elastic beanstalk environment instance launch

I am using Terraform script to create aws elastic beanstalk environment, I need to launch a shell script on instance launch I have already tried the following resource "...
Bikesh M's user avatar
  • 8,353
3 votes
1 answer
563 views

Decrypted vars when install a new aws instance via user-data script

I have Ansible playbooks ready, they includes several encrypted vars. With normal process, I can feed a vault password file to decrypt them with --vault-password-file ~/.vault_pass.txt and deploy the ...
BMW's user avatar
  • 45.1k