From 7a7a8baaf6d4f54e42e5c1b10818e1fc7e500b6c Mon Sep 17 00:00:00 2001 From: Anton Panferov Date: Mon, 24 May 2021 11:09:21 -0700 Subject: [PATCH] HCCP-138 breaking changes for Peering and TGW attachment (#128) * HCCP-138 required id and removed cidr from peering * HCCP-138 fixed tgw-attachment resource import * HCCP-138 removed cidrs from tgw-attachment * bonus: drop deleted guide example * update peering examples in guides Co-authored-by: Brenna Hewer-Darroch <21015366+bcmdarroch@users.noreply.github.com> --- docs/data-sources/aws_network_peering.md | 1 - .../aws_transit_gateway_attachment.md | 1 - docs/guides/peering.md | 19 +++++++--- docs/index.md | 20 +++++++--- docs/resources/aws_network_peering.md | 24 +++++++----- .../aws_transit_gateway_attachment.md | 9 ++++- examples/guides/peering/main.tf | 19 +++++++--- examples/guides/peering/variables.tf | 5 +++ examples/guides/quick_start/_config.tf | 1 - examples/guides/quick_start/main.tf | 20 ---------- examples/provider/provider.tf | 20 +++++++--- .../hcp_aws_network_peering/resource.tf | 21 +++++++---- .../resource.tf | 8 +++- .../data_source_aws_network_peering.go | 5 --- ...a_source_aws_transit_gateway_attachment.go | 8 ---- .../provider/resource_aws_network_peering.go | 30 ++++----------- ...resource_aws_transit_gateway_attachment.go | 37 ++++--------------- 17 files changed, 118 insertions(+), 130 deletions(-) delete mode 100644 examples/guides/quick_start/_config.tf delete mode 100644 examples/guides/quick_start/main.tf diff --git a/docs/data-sources/aws_network_peering.md b/docs/data-sources/aws_network_peering.md index 752a8ae23..321c55852 100644 --- a/docs/data-sources/aws_network_peering.md +++ b/docs/data-sources/aws_network_peering.md @@ -38,7 +38,6 @@ data "hcp_aws_network_peering" "test" { - **expires_at** (String) The time after which the network peering will be considered expired if it hasn't transitioned into `ACCEPTED` or `ACTIVE` state. - **organization_id** (String) The ID of the HCP organization where the network peering is located. Always matches the HVN's organization. - **peer_account_id** (String) The account ID of the peer VPC in AWS. -- **peer_vpc_cidr_block** (String) The CIDR range of the peer VPC in AWS. - **peer_vpc_id** (String) The ID of the peer VPC in AWS. - **peer_vpc_region** (String) The region of the peer VPC in AWS. - **project_id** (String) The ID of the HCP project where the network peering is located. Always matches the HVN's project. diff --git a/docs/data-sources/aws_transit_gateway_attachment.md b/docs/data-sources/aws_transit_gateway_attachment.md index d283440b5..e08129206 100644 --- a/docs/data-sources/aws_transit_gateway_attachment.md +++ b/docs/data-sources/aws_transit_gateway_attachment.md @@ -37,7 +37,6 @@ data "hcp_aws_transit_gateway_attachment" "test" { ### Read-Only - **created_at** (String) The time that the transit gateway attachment was created. -- **destination_cidrs** (List of String) The list of associated CIDR ranges. Traffic from these CIDRs will be allowed for all resources in the HVN. Traffic to these CIDRs will be routed into this transit gateway attachment. - **expires_at** (String) The time after which the transit gateway attachment will be considered expired if it hasn't transitioned into `ACCEPTED` or `ACTIVE` state. - **organization_id** (String) The ID of the HCP organization where the transit gateway attachment is located. Always matches the HVN's organization. - **project_id** (String) The ID of the HCP project where the transit gateway attachment is located. Always matches the HVN's project. diff --git a/docs/guides/peering.md b/docs/guides/peering.md index 9792f0b0d..9f12b4b56 100644 --- a/docs/guides/peering.md +++ b/docs/guides/peering.md @@ -41,12 +41,19 @@ resource "aws_vpc" "peer" { // Create an HCP network peering to peer your HVN with your AWS VPC. resource "hcp_aws_network_peering" "example" { - peering_id = var.peer_id - hvn_id = hcp_hvn.example.hvn_id - peer_vpc_id = aws_vpc.peer.id - peer_account_id = aws_vpc.peer.owner_id - peer_vpc_region = var.region - peer_vpc_cidr_block = aws_vpc.peer.cidr_block + peering_id = var.peer_id + hvn_id = hcp_hvn.example.hvn_id + peer_vpc_id = aws_vpc.peer.id + peer_account_id = aws_vpc.peer.owner_id + peer_vpc_region = var.region +} + +// Create an HVN route that targets your HCP network peering and matches your AWS VPC's CIDR block +resource "hcp_hvn_route" "example" { + hvn_link = hcp_hvn.hvn.self_link + hvn_route_id = var.route_id + destination_cidr = aws_vpc.peer.cidr_block + target_link = hcp_aws_network_peering.example.self_link } // Accept the VPC peering within your AWS account. diff --git a/docs/index.md b/docs/index.md index 4d2d6cbc3..3bf2237e6 100644 --- a/docs/index.md +++ b/docs/index.md @@ -73,12 +73,20 @@ resource "aws_vpc_peering_connection_accepter" "main" { } // Create a network peering between the HVN and the AWS VPC -resource "hcp_aws_network_peering" "example_peering" { - hvn_id = hcp_hvn.example_hvn.hvn_id - peer_vpc_id = aws_vpc.main.id - peer_account_id = aws_vpc.main.owner_id - peer_vpc_region = data.aws_arn.main.region - peer_vpc_cidr_block = aws_vpc.main.cidr_block +resource "hcp_aws_network_peering" "example" { + hvn_id = hcp_hvn.example_hvn.hvn_id + peering_id = "hcp-tf-example-peering" + peer_vpc_id = aws_vpc.main.id + peer_account_id = aws_vpc.main.owner_id + peer_vpc_region = data.aws_arn.main.region +} + +// Create an HVN route that targets your HCP network peering and matches your AWS VPC's CIDR block +resource "hcp_hvn_route" "example" { + hvn_link = hcp_hvn.hvn.self_link + hvn_route_id = "hcp-tf-example-hvn-route" + destination_cidr = aws_vpc.main.cidr_block + target_link = hcp_aws_network_peering.example.self_link } // Create a Consul cluster in the same region and cloud provider as the HVN diff --git a/docs/resources/aws_network_peering.md b/docs/resources/aws_network_peering.md index f0f224103..4056156ec 100644 --- a/docs/resources/aws_network_peering.md +++ b/docs/resources/aws_network_peering.md @@ -32,16 +32,23 @@ data "aws_arn" "peer" { arn = aws_vpc.peer.arn } -resource "hcp_aws_network_peering" "peer" { - hvn_id = hcp_hvn.main.hvn_id - peer_vpc_id = aws_vpc.peer.id - peer_account_id = aws_vpc.peer.owner_id - peer_vpc_region = data.aws_arn.peer.region - peer_vpc_cidr_block = aws_vpc.peer.cidr_block +resource "hcp_aws_network_peering" "dev" { + hvn_id = hcp_hvn.main.hvn_id + peering_id = "dev" + peer_vpc_id = aws_vpc.peer.id + peer_account_id = aws_vpc.peer.owner_id + peer_vpc_region = data.aws_arn.peer.region +} + +resource "hcp_hvn_route" "main-to-dev" { + hvn_link = hcp_hvn.main.self_link + hvn_route_id = "main-to-dev" + destination_cidr = "172.31.0.0/16" + target_link = hcp_aws_network_peering.dev.self_link } resource "aws_vpc_peering_connection_accepter" "peer" { - vpc_peering_connection_id = hcp_aws_network_peering.peer.provider_peering_id + vpc_peering_connection_id = hcp_aws_network_peering.dev.provider_peering_id auto_accept = true } ``` @@ -53,14 +60,13 @@ resource "aws_vpc_peering_connection_accepter" "peer" { - **hvn_id** (String) The ID of the HashiCorp Virtual Network (HVN). - **peer_account_id** (String) The account ID of the peer VPC in AWS. -- **peer_vpc_cidr_block** (String) The CIDR range of the peer VPC in AWS. - **peer_vpc_id** (String) The ID of the peer VPC in AWS. - **peer_vpc_region** (String) The region of the peer VPC in AWS. +- **peering_id** (String) The ID of the network peering. ### Optional - **id** (String) The ID of this resource. -- **peering_id** (String) The ID of the network peering. - **timeouts** (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) ### Read-Only diff --git a/docs/resources/aws_transit_gateway_attachment.md b/docs/resources/aws_transit_gateway_attachment.md index fe389a722..2c10e160f 100644 --- a/docs/resources/aws_transit_gateway_attachment.md +++ b/docs/resources/aws_transit_gateway_attachment.md @@ -60,7 +60,13 @@ resource "hcp_aws_transit_gateway_attachment" "example" { transit_gateway_attachment_id = "example-tgw-attachment" transit_gateway_id = aws_ec2_transit_gateway.example.id resource_share_arn = aws_ram_resource_share.example.arn - destination_cidrs = [aws_vpc.example.cidr_block] +} + +resource "hcp_hvn_route" "route" { + hvn_link = hcp_hvn.main.self_link + hvn_route_id = "hvn-to-tgw-attachment" + destination_cidr = aws_vpc.example.cidr_block + target_link = hcp_aws_transit_gateway_attachment.example.self_link } resource "aws_ec2_transit_gateway_vpc_attachment_accepter" "example" { @@ -75,7 +81,6 @@ resource "aws_ec2_transit_gateway_vpc_attachment_accepter" "example" { ### Required -- **destination_cidrs** (List of String) The list of associated CIDR ranges. Traffic from these CIDRs will be allowed for all resources in the HVN. Traffic to these CIDRs will be routed into this transit gateway attachment. - **hvn_id** (String) The ID of the HashiCorp Virtual Network (HVN). - **resource_share_arn** (String, Sensitive) The Amazon Resource Name (ARN) of the Resource Share that is needed to grant HCP access to the transit gateway in AWS. The Resource Share should be associated with the HCP AWS account principal (see [aws_ram_principal_association](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ram_principal_association)) and the transit gateway resource (see [aws_ram_resource_association](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ram_resource_association)) - **transit_gateway_attachment_id** (String) The user-settable name of the transit gateway attachment in HCP. diff --git a/examples/guides/peering/main.tf b/examples/guides/peering/main.tf index f66e43952..4fffd4b0c 100644 --- a/examples/guides/peering/main.tf +++ b/examples/guides/peering/main.tf @@ -23,12 +23,19 @@ resource "aws_vpc" "peer" { // Create an HCP network peering to peer your HVN with your AWS VPC. resource "hcp_aws_network_peering" "example" { - peering_id = var.peer_id - hvn_id = hcp_hvn.example.hvn_id - peer_vpc_id = aws_vpc.peer.id - peer_account_id = aws_vpc.peer.owner_id - peer_vpc_region = var.region - peer_vpc_cidr_block = aws_vpc.peer.cidr_block + peering_id = var.peer_id + hvn_id = hcp_hvn.example.hvn_id + peer_vpc_id = aws_vpc.peer.id + peer_account_id = aws_vpc.peer.owner_id + peer_vpc_region = var.region +} + +// Create an HVN route that targets your HCP network peering and matches your AWS VPC's CIDR block +resource "hcp_hvn_route" "example" { + hvn_link = hcp_hvn.hvn.self_link + hvn_route_id = var.route_id + destination_cidr = aws_vpc.peer.cidr_block + target_link = hcp_aws_network_peering.example.self_link } // Accept the VPC peering within your AWS account. diff --git a/examples/guides/peering/variables.tf b/examples/guides/peering/variables.tf index 749ce4af2..0a7decf4b 100644 --- a/examples/guides/peering/variables.tf +++ b/examples/guides/peering/variables.tf @@ -17,3 +17,8 @@ variable "peer_id" { description = "The ID to use for the HCP network peering." type = string } + +variable "route_id" { + description = "The ID to use for the HCP HVN route." + type = string +} diff --git a/examples/guides/quick_start/_config.tf b/examples/guides/quick_start/_config.tf deleted file mode 100644 index 041a8b52b..000000000 --- a/examples/guides/quick_start/_config.tf +++ /dev/null @@ -1 +0,0 @@ -provider "hcp" {} \ No newline at end of file diff --git a/examples/guides/quick_start/main.tf b/examples/guides/quick_start/main.tf deleted file mode 100644 index c22148490..000000000 --- a/examples/guides/quick_start/main.tf +++ /dev/null @@ -1,20 +0,0 @@ -resource "hcp_hvn" "example_hvn" { - hvn_id = "hcp-tf-example-hvn" - cloud_provider = "aws" - region = "us-west-2" - cidr_block = "172.25.16.0/20" -} - -resource "hcp_consul_cluster" "example_consul_cluster" { - hvn_id = hcp_hvn.example_hvn.hvn_id - cluster_id = "hcp-tf-example-consul-cluster" - tier = "development" -} - -resource "hcp_aws_network_peering" "example_peering" { - hvn_id = hcp_hvn.example_hvn.hvn_id - peer_vpc_id = "vpc-2f09a348" - peer_account_id = "1234567890" - peer_vpc_region = "us-west-2" - peer_vpc_cidr_block = "10.0.1.0/24" -} \ No newline at end of file diff --git a/examples/provider/provider.tf b/examples/provider/provider.tf index 71093bf3c..add6835f1 100644 --- a/examples/provider/provider.tf +++ b/examples/provider/provider.tf @@ -39,12 +39,20 @@ resource "aws_vpc_peering_connection_accepter" "main" { } // Create a network peering between the HVN and the AWS VPC -resource "hcp_aws_network_peering" "example_peering" { - hvn_id = hcp_hvn.example_hvn.hvn_id - peer_vpc_id = aws_vpc.main.id - peer_account_id = aws_vpc.main.owner_id - peer_vpc_region = data.aws_arn.main.region - peer_vpc_cidr_block = aws_vpc.main.cidr_block +resource "hcp_aws_network_peering" "example" { + hvn_id = hcp_hvn.example_hvn.hvn_id + peering_id = "hcp-tf-example-peering" + peer_vpc_id = aws_vpc.main.id + peer_account_id = aws_vpc.main.owner_id + peer_vpc_region = data.aws_arn.main.region +} + +// Create an HVN route that targets your HCP network peering and matches your AWS VPC's CIDR block +resource "hcp_hvn_route" "example" { + hvn_link = hcp_hvn.hvn.self_link + hvn_route_id = "hcp-tf-example-hvn-route" + destination_cidr = aws_vpc.main.cidr_block + target_link = hcp_aws_network_peering.example.self_link } // Create a Consul cluster in the same region and cloud provider as the HVN diff --git a/examples/resources/hcp_aws_network_peering/resource.tf b/examples/resources/hcp_aws_network_peering/resource.tf index f67f906d9..6ff52308b 100644 --- a/examples/resources/hcp_aws_network_peering/resource.tf +++ b/examples/resources/hcp_aws_network_peering/resource.tf @@ -17,15 +17,22 @@ data "aws_arn" "peer" { arn = aws_vpc.peer.arn } -resource "hcp_aws_network_peering" "peer" { - hvn_id = hcp_hvn.main.hvn_id - peer_vpc_id = aws_vpc.peer.id - peer_account_id = aws_vpc.peer.owner_id - peer_vpc_region = data.aws_arn.peer.region - peer_vpc_cidr_block = aws_vpc.peer.cidr_block +resource "hcp_aws_network_peering" "dev" { + hvn_id = hcp_hvn.main.hvn_id + peering_id = "dev" + peer_vpc_id = aws_vpc.peer.id + peer_account_id = aws_vpc.peer.owner_id + peer_vpc_region = data.aws_arn.peer.region +} + +resource "hcp_hvn_route" "main-to-dev" { + hvn_link = hcp_hvn.main.self_link + hvn_route_id = "main-to-dev" + destination_cidr = "172.31.0.0/16" + target_link = hcp_aws_network_peering.dev.self_link } resource "aws_vpc_peering_connection_accepter" "peer" { - vpc_peering_connection_id = hcp_aws_network_peering.peer.provider_peering_id + vpc_peering_connection_id = hcp_aws_network_peering.dev.provider_peering_id auto_accept = true } diff --git a/examples/resources/hcp_aws_transit_gateway_attachment/resource.tf b/examples/resources/hcp_aws_transit_gateway_attachment/resource.tf index a3226e8a1..64e152846 100644 --- a/examples/resources/hcp_aws_transit_gateway_attachment/resource.tf +++ b/examples/resources/hcp_aws_transit_gateway_attachment/resource.tf @@ -44,7 +44,13 @@ resource "hcp_aws_transit_gateway_attachment" "example" { transit_gateway_attachment_id = "example-tgw-attachment" transit_gateway_id = aws_ec2_transit_gateway.example.id resource_share_arn = aws_ram_resource_share.example.arn - destination_cidrs = [aws_vpc.example.cidr_block] +} + +resource "hcp_hvn_route" "route" { + hvn_link = hcp_hvn.main.self_link + hvn_route_id = "hvn-to-tgw-attachment" + destination_cidr = aws_vpc.example.cidr_block + target_link = hcp_aws_transit_gateway_attachment.example.self_link } resource "aws_ec2_transit_gateway_vpc_attachment_accepter" "example" { diff --git a/internal/provider/data_source_aws_network_peering.go b/internal/provider/data_source_aws_network_peering.go index cb91a35c6..9e3f75509 100644 --- a/internal/provider/data_source_aws_network_peering.go +++ b/internal/provider/data_source_aws_network_peering.go @@ -57,11 +57,6 @@ func dataSourceAwsNetworkPeering() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "peer_vpc_cidr_block": { - Description: "The CIDR range of the peer VPC in AWS.", - Type: schema.TypeString, - Computed: true, - }, "provider_peering_id": { Description: "The peering connection ID used by AWS.", Type: schema.TypeString, diff --git a/internal/provider/data_source_aws_transit_gateway_attachment.go b/internal/provider/data_source_aws_transit_gateway_attachment.go index 9605de24c..3414fc060 100644 --- a/internal/provider/data_source_aws_transit_gateway_attachment.go +++ b/internal/provider/data_source_aws_transit_gateway_attachment.go @@ -55,14 +55,6 @@ func dataSourceAwsTransitGatewayAttachment() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "destination_cidrs": { - Description: "The list of associated CIDR ranges. Traffic from these CIDRs will be allowed for all resources in the HVN. Traffic to these CIDRs will be routed into this transit gateway attachment.", - Type: schema.TypeList, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - Computed: true, - }, "provider_transit_gateway_attachment_id": { Description: "The transit gateway attachment ID used by AWS.", Type: schema.TypeString, diff --git a/internal/provider/resource_aws_network_peering.go b/internal/provider/resource_aws_network_peering.go index e5b96ac56..2b955510c 100644 --- a/internal/provider/resource_aws_network_peering.go +++ b/internal/provider/resource_aws_network_peering.go @@ -12,7 +12,7 @@ import ( sharedmodels "github.com/hashicorp/hcp-sdk-go/clients/cloud-shared/v1/models" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" + "github.com/hashicorp/terraform-provider-hcp/internal/clients" ) @@ -45,6 +45,13 @@ func resourceAwsNetworkPeering() *schema.Resource { ForceNew: true, ValidateDiagFunc: validateSlugID, }, + "peering_id": { + Description: "The ID of the network peering.", + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateDiagFunc: validateSlugID, + }, "peer_account_id": { Description: "The account ID of the peer VPC in AWS.", Type: schema.TypeString, @@ -66,22 +73,6 @@ func resourceAwsNetworkPeering() *schema.Resource { return strings.ToLower(old) == strings.ToLower(new) }, }, - "peer_vpc_cidr_block": { - Description: "The CIDR range of the peer VPC in AWS.", - Type: schema.TypeString, - Required: true, - ForceNew: true, - ValidateFunc: validation.IsCIDR, - }, - // Optional inputs - "peering_id": { - Description: "The ID of the network peering.", - Type: schema.TypeString, - Optional: true, - ForceNew: true, - Computed: true, - ValidateDiagFunc: validateSlugID, - }, // Computed outputs "organization_id": { Description: "The ID of the HCP organization where the network peering is located. Always matches the HVN's organization.", @@ -125,7 +116,6 @@ func resourceAwsNetworkPeeringCreate(ctx context.Context, d *schema.ResourceData peerAccountID := d.Get("peer_account_id").(string) peerVpcID := d.Get("peer_vpc_id").(string) peerVpcRegion := d.Get("peer_vpc_region").(string) - peerVpcCidr := d.Get("peer_vpc_cidr_block").(string) loc := &sharedmodels.HashicorpCloudLocationLocation{ OrganizationID: client.Config.OrganizationID, @@ -174,7 +164,6 @@ func resourceAwsNetworkPeeringCreate(ctx context.Context, d *schema.ResourceData AccountID: peerAccountID, VpcID: peerVpcID, Region: peerVpcRegion, - Cidr: peerVpcCidr, }, }, }, @@ -316,9 +305,6 @@ func setPeeringResourceData(d *schema.ResourceData, peering *networkmodels.Hashi if err := d.Set("peer_vpc_region", peering.Target.AwsTarget.Region); err != nil { return err } - if err := d.Set("peer_vpc_cidr_block", peering.Target.AwsTarget.Cidr); err != nil { - return err - } if err := d.Set("organization_id", peering.Hvn.Location.OrganizationID); err != nil { return err } diff --git a/internal/provider/resource_aws_transit_gateway_attachment.go b/internal/provider/resource_aws_transit_gateway_attachment.go index 4afee43b5..dd57e7e44 100644 --- a/internal/provider/resource_aws_transit_gateway_attachment.go +++ b/internal/provider/resource_aws_transit_gateway_attachment.go @@ -12,7 +12,7 @@ import ( sharedmodels "github.com/hashicorp/hcp-sdk-go/clients/cloud-shared/v1/models" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" + "github.com/hashicorp/terraform-provider-hcp/internal/clients" ) @@ -65,17 +65,6 @@ func resourceAwsTransitGatewayAttachment() *schema.Resource { Sensitive: true, ForceNew: true, }, - "destination_cidrs": { - Description: "The list of associated CIDR ranges. Traffic from these CIDRs will be allowed for all resources in the HVN. Traffic to these CIDRs will be routed into this transit gateway attachment.", - Type: schema.TypeList, - Elem: &schema.Schema{ - Type: schema.TypeString, - ValidateFunc: validation.IsCIDR, - }, - Required: true, - MinItems: 1, - ForceNew: true, - }, // Computed outputs "organization_id": { Description: "The ID of the HCP organization where the transit gateway attachment is located. Always matches the HVN's organization.", @@ -123,16 +112,6 @@ func resourceAwsTransitGatewayAttachmentCreate(ctx context.Context, d *schema.Re tgwAttachmentID := d.Get("transit_gateway_attachment_id").(string) tgwID := d.Get("transit_gateway_id").(string) resourceShareARN := d.Get("resource_share_arn").(string) - rawCIDRs := d.Get("destination_cidrs").([]interface{}) - - destinationCIDRs := make([]string, len(rawCIDRs)) - for i, cidr := range rawCIDRs { - strCidr, ok := cidr.(string) - if !ok { - return diag.Errorf("unable to convert cidr: %v to string", cidr) - } - destinationCIDRs[i] = strCidr - } loc := &sharedmodels.HashicorpCloudLocationLocation{ OrganizationID: client.Config.OrganizationID, @@ -169,7 +148,6 @@ func resourceAwsTransitGatewayAttachmentCreate(ctx context.Context, d *schema.Re createTGWAttachmentParams.HvnLocationOrganizationID = loc.OrganizationID createTGWAttachmentParams.HvnLocationProjectID = loc.ProjectID createTGWAttachmentParams.Body = &networkmodels.HashicorpCloudNetwork20200907CreateTGWAttachmentRequest{ - Cidrs: destinationCIDRs, Hvn: &sharedmodels.HashicorpCloudLocationLink{ ID: hvnID, Location: loc, @@ -310,9 +288,6 @@ func setTransitGatewayAttachmentResourceData(d *schema.ResourceData, tgwAtt *net if err := d.Set("transit_gateway_id", tgwAtt.ProviderData.AwsData.TgwID); err != nil { return err } - if err := d.Set("destination_cidrs", tgwAtt.Cidrs); err != nil { - return err - } if err := d.Set("organization_id", tgwAtt.Location.OrganizationID); err != nil { return err } @@ -350,12 +325,13 @@ func setTransitGatewayAttachmentResourceData(d *schema.ResourceData, tgwAtt *net func resourceAwsTransitGatewayAttachmentImport(ctx context.Context, d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { client := meta.(*clients.Client) - idParts := strings.SplitN(d.Id(), ":", 2) - if len(idParts) != 2 || idParts[0] == "" || idParts[1] == "" { - return nil, fmt.Errorf("unexpected format of ID (%q), expected {hvn_id}:{transit_gateway_attachment_id}", d.Id()) + idParts := strings.SplitN(d.Id(), ":", 3) + if len(idParts) != 3 || idParts[0] == "" || idParts[1] == "" || idParts[2] == "" { + return nil, fmt.Errorf("unexpected format of ID (%q), expected {hvn_id}:{transit_gateway_attachment_id}:{resource_share_arn}", d.Id()) } hvnID := idParts[0] tgwAttID := idParts[1] + resourceShareArn := idParts[2] loc := &sharedmodels.HashicorpCloudLocationLocation{ ProjectID: client.Config.ProjectID, } @@ -370,6 +346,9 @@ func resourceAwsTransitGatewayAttachmentImport(ctx context.Context, d *schema.Re if err := d.Set("hvn_id", hvnID); err != nil { return nil, err } + if err := d.Set("resource_share_arn", resourceShareArn); err != nil { + return nil, err + } return []*schema.ResourceData{d}, nil }