«   2021/05   »
            1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31          
05-08 06:43
Notice
Today
9
Total
1,423,023
관리 메뉴

변군이글루

[Terraform] 테라폼 vpc peering import(terraform import) 본문

* 퍼블릭 클라우드

[Terraform] 테라폼 vpc peering import(terraform import)

변군 변군이글루 2021. 4. 22. 13:50

테라폼 vpc peering import(terraform import)

vpc peering connection import

[버지니아 리전]

vpc resources 파일 생성

$ vim peering.tf
#####VPC 페어링
resource "aws_vpc_peering_connection" "vatosg" {}

$ terraform import aws_vpc_peering_connection.vatosg pcx-03c5b

$ terraform import aws_vpc_peering_connection.vatosg pcx-03c5b
aws_vpc_peering_connection.vatosg: Importing from ID "pcx-03c5b"...
aws_vpc_peering_connection.vatosg: Import prepared!
  Prepared aws_vpc_peering_connection for import
aws_vpc_peering_connection.vatosg: Refreshing state... [id=pcx-03c5b]

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.

vpc peering connection accepter import

[버지니아 리전]

vpc resources 파일 생성

$ vim peering.tf
#####VPC 페어링
resource "aws_vpc_peering_connection_accepter" "vatosg" {}

 

$ terraform import aws_vpc_peering_connection_accepter.vatosg pcx-03c5b

$ terraform import aws_vpc_peering_connection_accepter.vatosg pcx-03c5b
aws_vpc_peering_connection_accepter.vatosg: Importing from ID "pcx-03c5b"...
aws_vpc_peering_connection_accepter.vatosg: Import prepared!
  Prepared aws_vpc_peering_connection_accepter for import
aws_vpc_peering_connection_accepter.vatosg: Refreshing state... [id=pcx-03c5b]

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.

terraform show

import한 내용을 기반으로 vpc 모듈 편집

$ vim vpcpeering.tf

$ vim vpcpeering.tf
resource "aws_vpc_peering_connection" "vatosg" {
    #accept_status = "active"
    #id            = "pcx-03c5b"
    vpc_id        = "vpc-02e17"
    peer_owner_id = "57243"
    peer_region   = "ap-southeast-1"
    peer_vpc_id   = "vpc-0bbe2"
    lifecycle {
        ignore_changes = [ tags.CreatedDate ]
    }
    tags = {
        Name = "vatosg"
        Environment = "env-prod"
        CreateUser = "terraform"
        Owner = "sangchul"
        Project = "aaa"
        Role = "vpcpeering"
        Service = "network"
        CreatedDate = timestamp()
    }
    accepter {
        allow_classic_link_to_remote_vpc = false
        allow_remote_vpc_dns_resolution  = false
        allow_vpc_to_remote_classic_link = false
    }
    requester {
        allow_classic_link_to_remote_vpc = false
        allow_remote_vpc_dns_resolution  = false
        allow_vpc_to_remote_classic_link = false
    }
    timeouts {}
}

resource "aws_vpc_peering_connection_accepter" "vatosg" {
    vpc_peering_connection_id = "pcx-03c5b"
    accepter {
        allow_classic_link_to_remote_vpc = false
        allow_remote_vpc_dns_resolution  = false
        allow_vpc_to_remote_classic_link = false
    }
    requester {
        allow_classic_link_to_remote_vpc = false
        allow_remote_vpc_dns_resolution  = false
        allow_vpc_to_remote_classic_link = false
    }
    lifecycle {
        ignore_changes = [ tags.CreatedDate ]
    }
    tags = {
        Name = "vatosg"
        Environment = "env-prod"
        CreateUser = "terraform"
        Owner = "sangchul"
        Project = "aaa"
        Role = "vpcpeering"
        Service = "network"
        CreatedDate = timestamp()
    }
}

 

 

0 Comments
댓글쓰기 폼