All technological notes.
Resource
During terraform apply, terraform will
*.tf files but not in the state file.*.tf files.*.tf files than on the infrastructure.
reference of a resource:
RESOURCE_TYPE.NAME.ATTRIBUTEData source
reference of a data source:
data.RESOURCE_TYPE.NAME.ATTRIBUTEprovider "aws" {
region = "ca-central-1"
}
data "aws_ami" "ubuntu_ami" {
most_recent = true
region = "ca-central-1"
filter {
name = "name"
values = ["ubuntu/images/hvm-ssd-gp3/ubuntu-noble-24.04-amd64-server-*"]
}
filter {
name = "virtualization-type"
values = ["hvm"]
}
owners = ["099720109477"] # Canonical
}
output "ami_id" {
value = data.aws_ami.ubuntu_ami.image_id
}
resource "aws_instance" "ec2_instance" {
instance_type = "t2.micro"
ami = data.aws_ami.ubuntu_ami.id
}