Difference between revisions of "Terraform: AWS instance example with aws ami lookup and key name"
Jump to navigation
Jump to search
Line 39: | Line 39: | ||
* <code>[[aws ec2 describe-key-pairs]]</code> | * <code>[[aws ec2 describe-key-pairs]]</code> | ||
* <code>[[terraform init]]</code> | * <code>[[terraform init]]</code> | ||
− | * <code>[[aws_key_pair]]</code> | + | * <code>[[Terraform resouce]]: <code>[[Terraform resource: aws_key_pair|aws_key_pair]]</code> |
== See also == | == See also == |
Revision as of 16:35, 14 February 2022
main.tf provider "aws" { region = "us-west-2" profile = "YourProfile" } data "aws_ami" "ubuntu" { most_recent = true filter { name = "name" values = ["ubuntu/images/hvm-ssd/ubuntu-hirsute-21.04-amd64-server-*"] } filter { name = "virtualization-type" values = ["hvm"] } owners = ["099720109477"] # Canonical } resource "aws_instance" "myUbuntuMicroInstance" { ami = data.aws_ami.ubuntu.id instance_type = "t3.micro" key_name = "YourKeyName" tags = { Name = "MyInstanceName" } }
Errors: Key par does not exist
│ Error: Error launching source instance: InvalidKeyPair.NotFound: The key pair 'YourKeyName' does not exist │ status code: 400, request id: 717f23c7-f87f-4056-a8f4-a82ad2095534
Related
See also
terraform apply
[ -auto-approve
| -refresh-only, -destroy | --help ]
, Terraform examples, Still creating...
, Terraform apply examples with errors
terraform
[untaint | fmt
| apply
|show
| state
| init | plan | console | output
| validate
| destroy
| debug
| import
| providers
| get
| graph
| workspaces
| resource
| login
| -var-file
| state mv
| state pull
| state push
| state replace-provider
| state rm
| force-unlock
| env
| tfe
| --version
| remote-exec
| delete on termination
| deprecated commands | terraform --help
]
Advertising: