log*_*gax 1 amazon-s3 amazon-web-services terraform
我似乎找不到可以帮助我使用 terraform 将 zip 文件从 aws s3 下载到实例的文档,有人可以帮我找到解决方案吗?
谢谢。
根据您的需要,有多种方法可以从 S3 下载文件。
remote-exec
配置程序。这是MIME
不可知论者。resource "aws_instance" "web" {
## [...]
provisioner "remote-exec" {
command = "curl -XGET [...]"
}
}
Run Code Online (Sandbox Code Playgroud)
null_resource
适当的触发器。resource "null_resource" "cluster" {
# Changes to any instance of the cluster requires re-provisioning
triggers = {
cluster_instance_ids = "${join(",", aws_instance.cluster.*.id)}"
}
# Bootstrap script can run on any instance of the cluster
# So we just choose the first in this case
connection {
host = "${element(aws_instance.cluster.*.public_ip, 0)}"
}
provisioner "remote-exec" {
# Bootstrap script called with private_ip of each node in the cluster
inline = [
"bootstrap-cluster.sh ${join(" ", aws_instance.cluster.*.private_ip)}",
]
}
}
Run Code Online (Sandbox Code Playgroud)
file
数据aws_s3_bucket_object
资源。它将与文本文件完美配合。
data "aws_s3_bucket_object" "secret_key" {
bucket = "awesomecorp-secret-keys"
key = "awesomeapp-secret-key"
}
resource "aws_instance" "web" {
## [...]
provisioner "file" {
content = data.aws_s3_bucket_object.secret_key.body
destination = /tmp/file
}
}
Run Code Online (Sandbox Code Playgroud)
http
提供商。user_data_scripts
来自cloud-init
. 互联网上有一系列问题和类似的线索。(AWS 开发人员论坛;使用 Cloudformation 进行身份验证下载的示例)resource "aws_instance" "web" {
ami = "${data.aws_ami.ubuntu.id}"
instance_type = "t2.micro"
user_data = [...]
tags = {
Name = "HelloWorld"
}
}
Run Code Online (Sandbox Code Playgroud)
如果您从实例执行命令,或者向执行Terraform
.
注意:也就是说,我怀疑Terraform
这是实例配置的最佳选择。看看SaltStack、 Ansible或Chef。这些是设计用于实例配置的工具。
归档时间: |
|
查看次数: |
6958 次 |
最近记录: |