Terraform Functions
-
Terraform provides inbuilt functions around
-
Example
Activity 3 continued
- Lets import a ssh key (public key)
- Assumption is you already have a key pair
~/.ssh/id_rsaand~/.ssh/id_rsa.pubwhich is generated by executingssh-keygen -t rsa - Refer Here for the changes done
- Now lets create an ec2 instance with ubuntu 24.04
- The inputs required are
- ami id
- instance type
- key pair
- subnet
- public ip
- security group
- Refer Here for the changes
Datasource
- Datasource is used to search in the provider to fetch some values
- Syntax is
data "type" "id" {
arg1 = value
argn = value
}
- To use the attribute syntax is
data.type.id.attribute
