Difference between revisions of "User data"
Jump to navigation
Jump to search
(23 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
{{lc}} | {{lc}} | ||
− | <code>user_data</code> ( | + | <code>user_data</code> (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: | ||
+ | * 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 | * https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/instance#user_data | ||
− | + | [[lifecycle]] { | |
+ | [[ignore_changes]] = [user_data] | ||
+ | } | ||
== Related == | == Related == | ||
− | |||
* <code>[[templatefile]], *.[[tftpl]]</code> | * <code>[[templatefile]], *.[[tftpl]]</code> | ||
− | * <code> | + | * <code>{{aws_instance}}</code> |
* <code>http://[[169.254.169.254]]/latest/user-data</code> | * <code>http://[[169.254.169.254]]/latest/user-data</code> | ||
* https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-add-user-data.html | * 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}} | ||
− | |||
[[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:
- 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
user_data_base64
instead. - If the
user_data_replace_on_change
is set then updates to this field will trigger a destroy and recreate
lifecycle { ignore_changes = [user_data] }
Related[edit]
templatefile, *.tftpl
Terraform AWS:
aws_instance
:ami
,availability_zone
,instance_type
,key_name
,aws_key_pair
,monitoring
,associate_public_ip_address
,tenancy
,subnet_id, user_data, iam_instance_profile, vpc_security_group_ids, root_block_device, ebs_block_device
http://169.254.169.254/latest/user-data
- https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-add-user-data.html
/var/lib/cloud/instance/user-data.txt
root_block_device
user_data_replace_on_change
- Cloud-init:
/var/log/cloud-init.log
,/var/log/cloud-init-output.log
- aws_volume_attachment
- Terraform lifecycle meta-argument
See also[edit]
user_data, .tftpl
cloud-init
,cloud-id
,/etc/cloud/cloud.cfg
,cloud-init status
, user_data,/var/log/cloud-init.log
- Terraform AWS:
aws_instance
:ami
,availability_zone
,instance_type
,key_name
,aws_key_pair
,monitoring
,associate_public_ip_address
,tenancy
,subnet_id, user_data, iam_instance_profile, vpc_security_group_ids, root_block_device, ebs_block_device
Advertising: