Difference between revisions of "User data"

From wikieduonline
Jump to navigation Jump to search
 
(37 intermediate revisions by 5 users not shown)
Line 1: Line 1:
 
{{lc}}
 
{{lc}}
 +
<code>user_data</code> (optional) user data to provide when [[launching]] the instance, such as [[shell scripts]].
  
[[aws_instance]]
+
  user_data                  = [[templatefile]]("${[[path.module]]}/assets/your_instance_data[[.tftpl]]", {})
  
  
[[templatefile]]
+
  user_data = templatefile("${path.module}/path/yourfile.tftpl", {
 +
    ecs_cluster            = aws_ecs_cluster.your_cluster.name
 +
    [[ecs_instance_attribute]] = var.ecs_instance_attribute
 +
  })
  
 +
 +
Important notes:
 +
* Updates to this field will trigger a [[stop]]/[[start]] of the [[EC2]] instance by default.
 +
* Do not pass [[gzip]]-compressed data via this argument; see <code>[[user_data_base64]]</code> instead.
 +
* If the <code>[[user_data_replace_on_change]]</code> is set then updates to this field will trigger a destroy and recreate
 +
 +
* https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/instance#user_data
 +
 +
 +
[[lifecycle]] {
 +
  [[ignore_changes]] = [user_data]
 +
  }
 +
 +
== Related ==
 +
* <code>[[templatefile]], *.[[tftpl]]</code>
 +
* <code>{{aws_instance}}</code>
 +
* <code>http://[[169.254.169.254]]/latest/user-data</code>
 +
* https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-add-user-data.html
 +
* <code>[[/var/lib/cloud/instance/user-data.txt]]</code>
 +
* <code>[[root_block_device]]</code>
 +
* <code>[[user_data_replace_on_change]]</code>
 +
* [[Cloud-init]]: <code>[[/var/log/cloud-init.log]]</code>, <code>[[/var/log/cloud-init-output.log]]</code>
 +
* [[aws_volume_attachment]]
 +
* [[Terraform lifecycle meta-argument]]
  
 
== See also ==
 
== See also ==
 +
* {{user_data}}
 +
* {{cloud-init}}
 
* {{aws_instance}}
 
* {{aws_instance}}
* {{terraform aws resources}}
 
  
 
[[Category:Terraform]]
 
[[Category:Terraform]]

Latest revision as of 10:31, 27 June 2023

user_data (optional) user data to provide when launching the instance, such as shell scripts.

  user_data                   = templatefile("${path.module}/assets/your_instance_data.tftpl", {})


 user_data = templatefile("${path.module}/path/yourfile.tftpl", {
   ecs_cluster            = aws_ecs_cluster.your_cluster.name
   ecs_instance_attribute = var.ecs_instance_attribute
 })


Important notes:


lifecycle {
  ignore_changes = [user_data]
 }

Related[edit]

See also[edit]

Advertising: