Ctc[̈łuTerraformvɂāAꂩwڂƂAgĂΏۂɁATerraform̓@{IȎgЉĂ{AځB́AȑO痘pĂNEh\[XTerraformŊǗ@ɂāB
̋L͉łBo^ijƑSĂ܂B
@Ctc[̈łuTerraformvɂāATerraform̓@{IȎgЉĂ{ABO܂ŁATerraform𗘗pĐVɃNEh\[X쐬ъǗ@ЉĂ܂B
@̉b邽߂Terraform̗pi߂ĂƁÃNEh\[XTerraformŊǗȂł傤BṓÃNEh\[XTerraform̊Ǘɒu@\̎gЉ܂B
@̃NEh\[XTerraformǗɒuC[Wނ߂ɁAƂō쐬uAmazon Elastic Compute CloudiAmazon EC2jṽCX^XiȉAEC2CX^XjTerraformŊǗł悤ɂ܂傤B
@܂Aȉ̗v̂EC2CX^XƂō쐬܂B
ݒ荀 | ݒl |
---|---|
CX^X | test |
Amazon}VC[WiAMIj | Amazon Linux 2023 AMI |
A[LeN` | 64bitix86j |
CX^X^Cv | t2.micro |
L[yA | L[yAȂős |
ZLeBO[v | ̃ZLeBO[vIidefaultj |
[g{[TCY | 8 GiB |
[g{[^Cv | gp2 |
@쐬EC2CX^XTerraformŊǗ鏀܂B܂͑Ώۂ̃CX^X IDAMI IDKvł̂ŁAꂼTĂ܂B
@āAEC2CX^XTerraformǗɒu߁A܂͈ȉ̂悤TerraformR[h쐬܂Bami̕ɂ͐قǍTAMI ID͂ĂB
resource "aws_instance" "test" { ami = "ami-0dfa284c9d7b2adad" instance_type = "t2.micro" }
@ɁAȉ̃R}hsāAEC2CX^XTerraform̊Ǘɒu܂B
$ terraform import aws_instance.test i-xxxxxxxxxxxxxxxxx aws_instance.test: Importing from ID "i-xxxxxxxxxxxxxxxxx"... aws_instance.test: Import prepared! Prepared aws_instance for import aws_instance.test: Refreshing state... [id=i-xxxxxxxxxxxxxxxxx] Import successful! The resources that were imported are shown above. These resources are now in your Terraform state and will henceforth be managed by Terraform.
@R}h̎sʂċCtlƎv܂A\[XTerraform̊ǗɒuƂuC|[gvƌĂт܂B̂߁AsR}himportɂȂĂ܂BR}h̃p[^[ƂāAC|[gƂȂTerraform̃\[Xw肵ǍɃC|[g̃\[X IDw肵Ă܂B
@C|[g͊܂Â܂܂łTerraformR[hƃ\[X̏ԂvĂ܂B̂߁Aȉ̃R}hsčقmF܂B
$ terraform plan aws_instance.test: Refreshing state... [id=i-xxxxxxxxxxxxxxxxx] Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols: ~ update in-place Terraform will perform the following actions: # aws_instance.test will be updated in-place ~ resource "aws_instance" "test" { id = "i-xxxxxxxxxxxxxxxxx" ~ tags = { - "Name" = "test" -> null } ~ tags_all = { - "Name" = "test" } -> (known after apply) + user_data_replace_on_change = false # (29 unchanged attributes hidden) # (8 unchanged blocks hidden) } Plan: 0 to add, 1 to change, 0 to destroy. Note: You didn't use the -out option to save this plan, so Terraform can't guarantee to take exactly these actions if you run "terraform apply" now.
@R}h̏o͌ʂAقĂ̂tagsuser_data_replace_on_change2ƕ܂BtagśAEC2CX^Xݒ肷ełAuser_data_replace_on_changê܂B
@Terraform̃hLgmFƁÃp[^[̓ftHglfalseŁATerraformǗۂ̃ftHglݒ肷邾̂悤Ɍ܂B
@]āA\[X̏TerraformR[hvɂ́Atagsݒ肷悳łBATerraformR[hȉ̂悤ɏC܂傤B
resource "aws_instance" "test" { ami = "ami-0dfa284c9d7b2adad" instance_type = "t2.micro" tags = { Name = "test" } }
@ɁAقꂽǂmF邽߁AقǂƓ悤terraform planR}hsĊmF܂B
$ terraform plan aws_instance.test: Refreshing state... [id=i-xxxxxxxxxxxxxxxxx] No changes. Your infrastructure matches the configuration. Terraform has compared your real infrastructure against your configuration and found no differences, so no changes are needed.
@Ȃuser_data_replace_on_change̍ق܂AɃ\[X̏TerraformR[hv܂B̂悤ɁÃ\[XTerraform̊Ǘɒuɂ́AΉTerraformR[h쐬ŃC|[gƂ{Aق߂ĂKv܂B
@ł́Ã\[XTerraform̊Ǘɂ邱ƂmF邽߂ɁATerraformR[hҏWterraform applyR}hsAύXKpꂽǂmF܂傤B͈ȉ̂悤ɃCX^X^Cvt2.microt3a.microɕύX܂B
resource "aws_instance" "test" { ami = "ami-0dfa284c9d7b2adad" instance_type = "t3a.micro" tags = { Name = "test" } }
@ɁAύXKp邽߂terraform applyR}hs܂B
$ terraform apply aws_instance.test: Refreshing state... [id=i-xxxxxxxxxxxxxxxxx] Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols: ~ update in-place Terraform will perform the following actions: # aws_instance.test will be updated in-place ~ resource "aws_instance" "test" { id = "i-xxxxxxxxxxxxxxxxx" ~ instance_type = "t2.micro" -> "t3a.micro" tags = { "Name" = "test" } + user_data_replace_on_change = false # (29 unchanged attributes hidden) # (8 unchanged blocks hidden) } Plan: 0 to add, 1 to change, 0 to destroy. Do you want to perform these actions? Terraform will perform the actions described above. Only 'yes' will be accepted to approve. Enter a value: yes aws_instance.test: Modifying... [id=i-xxxxxxxxxxxxxxxxx] aws_instance.test: Still modifying... [id=i-xxxxxxxxxxxxxxxxx, 10s elapsed] aws_instance.test: Still modifying... [id=i-xxxxxxxxxxxxxxxxx, 20s elapsed] aws_instance.test: Still modifying... [id=i-xxxxxxxxxxxxxxxxx, 30s elapsed] aws_instance.test: Still modifying... [id=i-xxxxxxxxxxxxxxxxx, 40s elapsed] aws_instance.test: Modifications complete after 42s [id=i-xxxxxxxxxxxxxxxxx] Apply complete! Resources: 0 added, 1 changed, 0 destroyed.
@TerraformR}h͕ύX悤ł̂ŁA}lWgR\[ʂŌĂ݂ƁAύXfĂ邱ƂmFł܂B
@ʓIɁAAmazon Web ServicesiAWSjgč\zꂽEC2CX^XȊOɂ܂܂ȃNEh\[X݂Ǝv܂B̃NEh\[XTerraform̊Ǘɒuꍇ́AOqʂC|[gƂKvɂȂ܂BimportR}hɎw肷̂́ANEh\[XƂɍׂقȂ܂B
@ł́uAmazon Elastic Block StoreiAmazon EBSjvuAWS Identity and Access ManagementiIAMjvuAmazon Simple Storage ServiceiAmazon S3jv\[XC|[gۂɕKvȏЉ܂B
NEh\[X | R}hɎw肷鎯ʎq | R}h |
---|---|---|
EC2CX^X | i-n܂CX^X ID | terraform import aws_instance.example i-xxxxxxxxxxxxxxxxx |
EBS{[ | vol-n܂{[ ID | terraform import aws_ebs_volume.example vol-xxxxxxxxxxxxxxxxx |
IAM [U[ | IAM [U[ | terraform import aws_iam_user.example user-name |
S3 oPbg | S3 oPbg | terraform import aws_s3_bucket.example bucket-name |
@C|[głǂ̂悤ȏw肷悢̂ƒm肽ĺATerraform̃hLgQƂĂ݂ĂB
@TerraformgOɎƂō쐬ĂNEh\[XATerrafromŊǗł܂Bu^pɓĂ̂Ŏ̉bȂccvƒ߂Kv͂܂BЁA{LQlɊ̃NEh\[XTerraformŊǗĂ݂ĂB
TCIXeNmW[BOSS 낸kŃT|[gΉĂeNjJT|[gGWjABAnsible ɏoĂ玩Ɏ߂Ag̋ƖvCx[gł̂̎ɎgށBvCx[gł Java łƂc[̊JɂĂB
Copyright © ITmedia, Inc. All Rights Reserved.