Created
August 9, 2019 08:38
-
-
Save officel/2d8f966a3fdd1c381c18372ba2d7613d to your computer and use it in GitHub Desktop.
terraform v0.12.6 , provider.aws v2.23.0 , ec2_instance credit_specification CRASH
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data "aws_vpc" "default" { | |
default = true | |
} | |
data "aws_subnet_ids" "default" { | |
vpc_id = data.aws_vpc.default.id | |
} | |
data "aws_security_group" "default" { | |
name = "default" | |
vpc_id = data.aws_vpc.default.id | |
} | |
data "aws_ami" "this" { | |
most_recent = true | |
owners = ["self", "amazon"] | |
filter { | |
name = "owner-alias" | |
values = ["amazon"] | |
} | |
filter { | |
name = "name" | |
values = ["amzn2-ami-hvm*"] | |
} | |
filter { | |
name = "architecture" | |
values = ["x86_64"] | |
} | |
} | |
module "ec2_cluster" { | |
source = "terraform-aws-modules/ec2-instance/aws" | |
version = "2.6.0" | |
name = "credit_specification_test" | |
ami = data.aws_ami.this.id | |
# instance_type = "t2.micro" | |
instance_type = "m4.large" | |
subnet_ids = data.aws_subnet_ids.default.ids | |
vpc_security_group_ids = [ | |
data.aws_security_group.default.id | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
export AWS_ACCESS_KEY_ID=あくせすきー
export AWS_SECRET_ACCESS_KEY=シークレット
export AWS_REGION=us-east-1 # お好きなところで
terraform init
terraform plan
terrform apply
mv terraform.tfstate terraform.tfstate.ok
初回作成は成功したので state を避ける
terraform init
terraform plan
初回作成と同じようになる。
作成したインスタンスを import
terraform import module.ec2_cluster.aws_instance.this i-xxxxxxxxxx
terraform plan
差分に
原因はこれ。
念の為リフレッシュ
terraform refresh
terraform plan
terraform apply
ここでクラッシュ。
原因は
初回作成した時は credit_specification.cpu_credits: null が生成されてるけど、
import の時には入らないらしく、そのまま apply しようとすると
credit_specification の中身がないのでクラッシュする、ということっぽい。