I had this issues with a aci_epg_to_contract but can happen for other resources as well.
Importing an EPG with contracts deployed with "miss-target" states result in the generation of a broken config:
For example assume this config:

Will generate a broken state config:
resource "aci_epg_to_contract" "tfer--fvRsCons_IN-alltraffic_43" {
annotation = ""
application_epg_dn = "${data.terraform_remote_state.local.outputs.aci_application_epg_tfer--fvAEPg_mpc-sPBR-clients_75_id}"
contract_type = "consumer"
prio = "unspecified"
}
Missing the mandatory contract_dn attribute that won't deploy:
Error: Missing required argument
on resources.tf line 1069, in resource "aci_epg_to_contract" "tfer--fvRsCons_IN-alltraffic_43":
1069: resource "aci_epg_to_contract" "tfer--fvRsCons_IN-alltraffic_43" {
The argument "contract_dn" is required, but no definition was found.
We should:
- Alert the user with a warning that an non existing contract is being used
- Skip importing the
aci_epg_to_contract for such contract
The warning should be very visible, ideally as a summary at the end of the import operation. for example something like this:
2022/07/28 21:07:20 aci Connecting....
2022/07/28 21:07:20 aci save
2022/07/28 21:07:20 aci save tfstate
2022/07/28 21:07:20 Import Completed with the following warnings:
The following resources have not being imported due to 'miss-target'
- x
- y
- z
I had this issues with a
aci_epg_to_contractbut can happen for other resources as well.Importing an EPG with contracts deployed with "miss-target" states result in the generation of a broken config:

For example assume this config:
Will generate a broken state config:
Missing the mandatory
contract_dnattribute that won't deploy:We should:
aci_epg_to_contractfor such contractThe warning should be very visible, ideally as a summary at the end of the import operation. for example something like this: