AWSAmazon VPC Transit Gatewayaws_ec2_transit_gateway_multicast_domainPro

How to Import an AWS Transit Gateway Multicast Domain into Terraform

To import an existing AWS Transit Gateway Multicast Domain into Terraform, scan it with Terraback and run terraback aws import --method bulk. Terraback writes the matching aws_ec2_transit_gateway_multicast_domain resource block and the Terraform 1.5+ import block for you, so you do not have to run terraform import by hand. The import ID is the Transit Gateway Multicast Domain ID (for example, tgw-mcast-domain-0c4905cef79d6e597).

Import AWS Transit Gateway Multicast Domain with Terraback (recommended)

Terraback reverse-engineers your live infrastructure: it reads the Amazon VPC Transit Gateway resource with read-only credentials, generates the HCL, and produces the exact import block. Two commands take you from a live AWS Transit Gateway Multicast Domain to managed Terraform.

1

Scan your AWS account

terraback scan all aws --region us-east-1
2

Generate import blocks and import into state

terraback aws import --method bulk

The Terraform import block

Terraback emits a Terraform 1.5+ import block like the one below. Because the block lives in your configuration, the import is reviewable in a pull request and repeatable across environments.

import {
  to = aws_ec2_transit_gateway_multicast_domain.example
  id = "tgw-mcast-domain-0c4905cef79d6e597"
}

Example aws_ec2_transit_gateway_multicast_domain configuration

Here is a realistic AWS Transit Gateway Multicast Domain block. Terraback generates a fuller version from your actual resource attributes; this is a minimal, valid starting point.

resource "aws_ec2_transit_gateway_multicast_domain" "example" {
  transit_gateway_id = "tgw-0123456789abcdef0"

  static_sources_support  = "disable"
  igmpv2_support          = "disable"
  auto_accept_shared_associations = "disable"

  tags = {
    Name = "example-multicast-domain"
  }
}

Gotchas when importing a AWS Transit Gateway Multicast Domain

  • The multicast domain belongs to a transit gateway that must have multicast_support enabled; transit_gateway_id points at that parent and is immutable after import.
  • Domain associations (aws_ec2_transit_gateway_multicast_domain_association) and group members/sources are separate child resources, each with its own composite ID, and are not pulled in by importing the domain.
  • static_sources_support, igmpv2_support, and auto_accept_shared_associations default to disable and are force-new; set them explicitly to match the live domain or Terraform will plan a replacement.
  • Multicast is a regional feature with account-level limits; confirm the domain is in the same region you are importing into, since the ID is not globally unique across regions.

Doing it manually with terraform import

The native approach is to write the aws_ec2_transit_gateway_multicast_domain block by hand, then run terraform import aws_ec2_transit_gateway_multicast_domain.example <import-id> for every resource, one at a time. That works for a handful of resources, but it does not scale: you author all the HCL yourself and repeat the command for each item. Terraback generates the HCL and the import blocks for your whole account in one pass.

Import your whole AWS account in minutes

Terraback scans 80+ AWS resource types and emits clean Terraform plus import blocks, running locally with read-only credentials. $499 once, no SaaS.