Provision an EC2 instance in AWS, allowing remote access. Based on https://www.youtube.com/watch?v=iRaai1IBlB0
- Create an IAM user with Access Key access
- Update ./aws/credentials adding the new profile with access key and secret
ssh-keygen -t ed25519
to create key/pairssh -i ~/.ssh/vscode_terraform ubuntu@<public_ip>
to ssh into remote EC2 instance
https://registry.terraform.io/providers/hashicorp/aws/latest/docs
terraform init
- initializes terraform and creates the.terraform.lock
fileterraform plan
- will display wich changes will be applied (added, changed, destroyed)terraform apply
- adds, changes or destroy resources- can be used with
-auto-approve
- can be used with
-replace aws_instance.vscode_terraform_instance
(forces the execution when there's no change in State) - can be used with
-refresh-only
updates the State - can be used with
-var="host_os=windows"
to specify variable values - can be used with
-var-file="linux-tfvars"
to use a file with variable values
- can be used with
terraform state list
- lists the resources that were createdterraform state show <resource_name>
- shows resource details (<resource_name>
could beaws_vpc.vscode_terraform_vpc
)terraform show
- shows the entire stateterraform plan -destroy
- lists what would be destroyedterraform destroy
- destroy all resources created by terraform (can be used with-auto-approve
)terraform fmt
- fixes all the inconsistencies in formatterraform console
- opens up a console where you can, for example, check variable values (likevar.host_os
)terraform output
- prints the outputs