How to import existing AWS resources into Terraform? | Terraform Import existing AWS Resources

preview_player
Показать описание
The terraform import command is used to import existing infrastructure. The command currently can only import one resource at a time. This means you can't yet point Terraform import to an entire collection of resources such as an AWS VPC and import all of it.

Let's say that you have created EC2 instances manually outside Terraform. If you like to import your EC2 instance to Terraform you can use import command and bring it under Terraform state file.

To import a resource, create a tf file first write a resource block for it in your configuration, establishing the name by which it will be known to Terraform:

resource "aws_instance" "myinstance" {
# ...instance configuration...leave this as it is
}
Рекомендации по теме
Комментарии
Автор

VERY VERY COOL! I was able to successfully import one of our critical ec2 hosts into Terraform code! Great instructions and thank you, this helped tremendously! 🙏

techsudo
Автор

you could use terraform state show command to get the details from the state file and fill inside your .tf file

flesz__
Автор

when you do a terraform apply after import is successful it updates the tf statefile but the instance name in the console is changes to blank, can you please let me know why is it happening

alokdumbre
Автор

hi good morning Brother feel free could you make a video for the following questions if time permits
The customer is approaching u to deploy a highly secured infrastructure. What was the best practice to suggest

So many aspects are they how you will implement in the cloud (AWS) from the scratch.

So in that scenario what are the security best practices that u follow?

How will we configure AWS infrastructure? How will u take from scratch to Kubernetes?

How will you plan to implement the infrastructure?

Best practices we follow for infrastructure?

AWS Alb + ingress controller have u tried?

How u can implement Autoscaling at pod level?

On what component HPA relies on in order to bring up the Autos calling we have to bring up

Some file or what the dependent controller for HPA

What are k8s managed services u have used?

Have u implemented any self-managed clusters?

What are the security best practices that u follow in k8s?

Where do u store secrets?

Have u created any helm chats from scratch?

What are the policies u used for k8s?

What is the backend used for storing secrets?

What are the monitoring and logging solutions u used for this?

Have u used any lambda functions?

Have u used the API gateway?API gateway what are the features or just like a router?

Have u ever hosted a static website on AWS using S3 + cloud front or cloud formation?

IAAC(Terraform)

What are the best practices in terraform to bring up ur infra or developing the terraform

Template?

How u will secure Main.tf and state file mgmt?

CI/CD tools u r familiar with?

How do you reduce the docker image?

Have u ever used docker-compose and docker swarm?

Difference between k8s and docker swarm

gkv
Автор

Can we import more than one resources(let's say 10 ec2) using for_each at one time?

admavidhyan