amazon-web-services - 具有 ec2 私有云实现的 terraform
问题描述
更新 :
我们的数据中心托管了一个私有云,它是 AWS 的精简版。我们已经公开了 EC2 API 以允许用户使用 awscli 创建 VM。
我正在尝试使用 Terraform 创建 VM,对于初始测试,我创建了一个 .tf 文件,如下所示:
provider "aws" {
access_key = "<key>"
secret_key = "<key>"
region = "us-west-1"
skip_credentials_validation = true
endpoints
{
ec2 = "https://awsserver/services/api/aws/ec2"
}
}
resource "aws_instance" "Automation" {
ami = "ami-100011201"
instance_type = "c3.xlarge"
subnet_id = "subnet1:1"
}
这是运行 terraform plan 后的错误消息
Error: Error running plan: 1 error(s) occurred:
* provider.aws: AWS account ID not previously found and failed retrieving via all available methods. See https://www.terraform.io/docs/providers/aws/index.html#skip_requesting_account_id for workaround and implications. Errors: 2 errors occurred:
* error calling sts:GetCallerIdentity: InvalidClientTokenId: The security token included in the request is invalid.
status code: 403, request id: 58f9d498-6259-11e9-b146-95598aa219b5
* failed getting account information via iam:ListRoles: InvalidClientTokenId: The security token included in the request is invalid.
status code: 403, request id: c10f8a06-58b4-4d0c-956a-5c8c684664ea
我们还没有实现 sts,查询总是转到 AWS 云而不是私有云 API 服务器。
我错过了什么?
解决方案
这对我创建一个虚拟机很有用。
provider "aws" {
access_key = "<key>"
secret_key = "<key>"
region = "us-west-1"
skip_credentials_validation =true
skip_requesting_account_id = true
skip_metadata_api_check = true
endpoints
{
ec2 = "https://awsserver/services/api/aws/ec2"
}
}
resource "aws_instance" "Automation" {
ami = "ami-100011201"
instance_type = "c3.xlarge"
subnet_id = "subnet1:1"
}
它创建了一个虚拟机,但是命令错误
aws_instance.Automation: Still creating... (1h22m4s elapsed)
aws_instance.Automation: Still creating... (1h22m14s elapsed)
aws_instance.Automation: Still creating... (1h22m24s elapsed)
Error: Error applying plan:
1 error(s) occurred:
* aws_instance.Automation: 1 error(s) occurred:
* aws_instance.Automation: Error waiting for instance (i-101149362) to become ready: timeout while waiting for state to become 'running' (last state: 'pending', timeout: 10m0s)
Terraform does not automatically rollback in the face of errors.
Instead, your Terraform state file has been partially updated with
any resources that successfully completed. Please address the error
above and apply again to incrementally change your infrastructure.
推荐阅读
- mysql - 如何将mysql连接到Node JS?
- apache-spark - 将数据划分为火花数据帧中每组的相同数量的记录
- php - 如何绕过woocommerce中的错误处理结帐?
- permissions - 我无法在 Matomo 中为新用户编辑权限
- android - React Native 中的 BackHandler 不起作用
- c# - 如何在 WPF 应用程序中获取 Windows 任务栏高度?
- mongodb - 如何在 MongoDB/Mongoose 中为一个字段引用两个不同的集合?
- java - Math.round 和 String.format 函数不能正确地对所有浮点值进行四舍五入
- macos - VSCode 终端更改 $PATH
- r - 如何自动化我的代码而不是手动更改值?