terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 5.0"
}
}
}
provider "aws" {
region = "ap-northeast-1"
}
# 🔍 既存のインスタンス i-07b67c27c85dbf9f5 をAWS上から参照
data "aws_instance" "target_i_07b67c27c85dbf9f5" {
instance_id = "i-07b67c27c85dbf9f5"
}
# 🛑 インスタンスの状態を強制的に "stopped"(停止)に変更
resource "aws_ec2_instance_state" "stop_i_07b67c27c85dbf9f5" {
instance_id = data.aws_instance.target_i_07b67c27c85dbf9f5.id
state = "stopped"
}