Skip to content

Handle resources with "miss-target" gracefully  #81

@camrossi

Description

@camrossi

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:
image

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:

  1. Alert the user with a warning that an non existing contract is being used
  2. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions