AWS CodeBuild/codebuild/output/tmp/script.sh:Terraform:Exec格式错误
我正在使用AWS CodeBuild通过Terraform构建基础架构。我创建了这个buildspec.yaml文件。
version: 0.2
phases:
install:
commands:
- "apt install unzip -y"
- "wget https://releases.hashicorp.com/terraform/1.1.8/terraform_1.1.8_linux_arm64.zip"
- "unzip terraform_1.1.8_linux_arm64.zip"
- "mv terraform /usr/local/bin/"
pre_build:
commands:
- terraform init
build:
commands:
- terraform plan
- terraform apply -auto-approve
post_build:
commands:
- echo "terraform apply completed on `date`"
我能够成功安装TerraForm,但无法运行Terraform Init并初始化代码。我遇到了这个错误:
[Container] 2022/06/23 10:25:29 Phase complete: INSTALL State: SUCCEEDED
[Container] 2022/06/23 10:25:29 Phase context status code: Message:
[Container] 2022/06/23 10:25:29 Entering phase PRE_BUILD
[Container] 2022/06/23 10:25:29 Running command terraform init
/codebuild/output/tmp/script.sh: 4: /codebuild/output/tmp/script.sh: terraform: Exec format error
这是我的Terraform设置。
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 4.0"
}
}
backend "s3" { }
}
我尝试了更改AWS提供商版本的不同事物。我在CodeBuild项目上打开和关闭“特权”标志。有人可以建议我做错什么吗?
I am using AWS Codebuild to build infrastructure through terraform. I created this buildspec.yaml file.
version: 0.2
phases:
install:
commands:
- "apt install unzip -y"
- "wget https://releases.hashicorp.com/terraform/1.1.8/terraform_1.1.8_linux_arm64.zip"
- "unzip terraform_1.1.8_linux_arm64.zip"
- "mv terraform /usr/local/bin/"
pre_build:
commands:
- terraform init
build:
commands:
- terraform plan
- terraform apply -auto-approve
post_build:
commands:
- echo "terraform apply completed on `date`"
I am able to install terraform successfully but not able to run terraform init and initialize the code. I am getting this error:
[Container] 2022/06/23 10:25:29 Phase complete: INSTALL State: SUCCEEDED
[Container] 2022/06/23 10:25:29 Phase context status code: Message:
[Container] 2022/06/23 10:25:29 Entering phase PRE_BUILD
[Container] 2022/06/23 10:25:29 Running command terraform init
/codebuild/output/tmp/script.sh: 4: /codebuild/output/tmp/script.sh: terraform: Exec format error
This is my terraform setup.
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 4.0"
}
}
backend "s3" { }
}
I tried different things such changing aws provider version. I turned on and off "privileged" flag on codebuild project. Can someone please suggest what I am doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您正在使用
ARM64
体系结构的TF二进制文件。可能您应该使用AMD64
:You are using TF binary for
arm64
architectures. Probably you should be usingamd64
instead: