728x90
처음부터 vpc를 만들고 시작해야하는 경우도 있지만, 기존에 있던 vpc에 테라폼을 사용해서 서브넷을 만들어야 하는 경우도 있을 것이다.
provider.tf 생성
지역을 지정해주는 테라폼 파일부터 생성한다.
# provider.tf
provider "aws" {
region = "ap-northeast-2"
}
vpc 껍데기만 만들어주기
사용할 vpc 이름 (여기서는 main으로 함.) 으로 vpc.tf 파일 껍데기만 만들어준다.
# vpc.tf
resource "aws_vpc" "main" {
}
사용할 vpc import 해오기
기존에 만들어진 vpc를 불러와준다.
terraform import aws_vpc.main [vpc ID]
- ex) terraform import aws_vpc.main vpc-21944927429
aws_vpc.main: Importing from ID "vpc-21944927429"...
aws_vpc.main: Import prepared!
Prepared aws_vpc for import
aws_vpc.main: Refreshing state... [id=vpc-21944927429]
Import successful!
The resources that were imported are shown above. These resources are now in
your Terraform state and will henceforth be managed by Terraform.
'DevOps > 👾IaC' 카테고리의 다른 글
[IaC/ansible 기초] ansible ad-hoc이란 (0) | 2024.05.15 |
---|---|
[IaC/ansible 기초] inventory 기본 개념 (0) | 2024.05.15 |
[IaC/ansible 기초] ansible의 기본 개념 (0) | 2024.04.28 |
[Terraform Error] Failed to get existing workspaces: S3 bucket does not exist (2) | 2024.01.10 |
[IaC/Terraform] AWS용 Key Pair 생성 (2) | 2023.01.06 |
댓글