Terraform基礎の基礎 EC2
リソースの作成
-main.tf
resource "aws_instance" "example" { ami = "ami-0f9ae750e8274075b" instance_type = "t3.micro" }
terraform init
Terraform has been successfully initialized!と表示されれば成功
Initializing the backend... ...
terraform plan
これから何が実行されるか表示される
Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols: + create Terraform will perform the following actions: # aws_instance.example will be created + resource "aws_instance" "example" { + ami = "ami-0f9ae750e8274075b" .... Plan: 1 to add, 0 to change, 0 to destroy.
terraform apply
Enter a value:と表⽰されyesと⼊⼒すると、実際にリソースが作成されます。
Do you want to perform these actions? Terraform will perform the actions described above. Only 'yes' will be accepted to approve. Enter a value: