[英]Bypassing 16KB EC2 user_data limitation
Is there a way to bypass the 16KB EC2 user_data limitation without any custom AMI?有没有办法在没有任何自定义 AMI 的情况下绕过 16KB EC2 user_data 限制? I have tried below examples in Terraform without any success.
我在 Terraform 中尝试了以下示例,但没有成功。 instance-user-data.ps1.tmpl is a powershell script of about 20KB.
instance-user-data.ps1.tmpl 是一个 powershell 脚本,大约 20KB。
Below script using base64encode complains about going over 16KB下面的脚本使用base64encode抱怨超过 16KB
resource "aws_instance" "instance" {
...
user_data_base64 = "${base64encode(templatefile("${path.module}/instance-user-data.ps1.tmpl", {
admin_username = local.admin_username
admin_password = random_password.admin_password.result
}))}"
}
Tried Gzip with Base64 encode as well, but script does not set any user data at all.也尝试使用 Base64 编码的 Gzip,但脚本根本不设置任何用户数据。
resource "aws_instance" "instance" {
...
user_data_base64 = "${base64gzip(templatefile("${path.module}/instance-user-data.ps1.tmpl", {
admin_username = local.admin_username
admin_password = random_password.admin_password.result
}))}"
}
The way I would get around this is to push your scripts/files to S3, which can be done with the Terraform aws_s3_object resource, and simply have your user_data script download the real startup script from S3 and run it.我解决这个问题的方法是将您的脚本/文件推送到 S3,这可以使用 Terraform aws_s3_object资源来完成,并且只需让您的 user_data 脚本从 S3 下载真正的启动脚本并运行它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.