SAP / terraform-exporter-btp

The Terraform Exporter for SAP BTP is a tool that helps export resources from a SAP BTP account. It generates Terraform scripts for the import of resources and enables the import of the Terraform state.
https://sap.github.io/terraform-exporter-btp/
Apache License 2.0
7 stars 0 forks source link

[BUG] Exporter uses role collection name as resource name #189

Open Kaefermade opened 3 days ago

Kaefermade commented 3 days ago

Is there an existing issue for this?

What version of the Terraform exporter are you using?

0.1.0-beta2

What version of the Terraform CLI are you using?

1.9.8

What type of issue are you facing

bug report

Describe the bug

The exporter currently uses the role collection names as resource names. This results in failures regarding role collections containing a dot in their name. This is related to SAP standard role collections and nothing which could be avoided during customizing.

Expected Behavior

I expected a successful export of all role collections.

Steps To Reproduce

  1. Present role collections containing a dot in the subaccount you want to export.
  2. Execute command btptf export -s ... to start the export
  3. Wait until the export reaches "generating Terraform configuration for BTP_SUBACCOUNT_ROLE_COLLECTION"

User's Role Collections

Add screenshots to help explain your problem

Screenshot_30 Screenshot_31

Additional context

Whole list of errors: ``` ⣽ generating Terraform configuration for BTP_SUBACCOUNT_ROLE_COLLECTION╷ │ Error: Terraform encountered problems during initialisation, including problems │ with the configuration, described below. │ │ The Terraform configuration must be valid before initialization so that │ Terraform can determine which modules and providers need to be installed. │ │ ╵ ╷ │ Error: Invalid import address │ │ on btp_subaccount_role_collection_import.tf line 2, in import: │ 2: to = btp_subaccount_role_collection.apimanagement.selfservice.administrator │ │ Only managed resources can be imported. ╵ ╷ │ Error: Invalid import address │ │ on btp_subaccount_role_collection_import.tf line 2, in import: │ 2: to = btp_subaccount_role_collection.apimanagement.selfservice.administrator │ │ Only managed resources can be imported. ╵ ╷ │ Error: Invalid address │ │ on btp_subaccount_role_collection_import.tf line 2, in import: │ 2: to = btp_subaccount_role_collection.apimanagement.selfservice.administrator │ │ Unexpected extra operators after address. ╵ ╷ │ Error: Invalid address │ │ on btp_subaccount_role_collection_import.tf line 2, in import: │ 2: to = btp_subaccount_role_collection.apimanagement.selfservice.administrator │ │ Unexpected extra operators after address. ╵ ╷ │ Error: Invalid import address │ │ on btp_subaccount_role_collection_import.tf line 6, in import: │ 6: to = btp_subaccount_role_collection.apiportal.administrator │ │ Only managed resources can be imported. ╵ ╷ │ Error: Invalid import address │ │ on btp_subaccount_role_collection_import.tf line 6, in import: │ 6: to = btp_subaccount_role_collection.apiportal.administrator │ │ Only managed resources can be imported. ╵ ╷ │ Error: Invalid address │ │ on btp_subaccount_role_collection_import.tf line 6, in import: │ 6: to = btp_subaccount_role_collection.apiportal.administrator │ │ Resource instance key must be given in square brackets. ╵ ╷ │ Error: Invalid address │ │ on btp_subaccount_role_collection_import.tf line 6, in import: │ 6: to = btp_subaccount_role_collection.apiportal.administrator │ │ Resource instance key must be given in square brackets. ╵ ╷ │ Error: Invalid import address │ │ on btp_subaccount_role_collection_import.tf line 10, in import: │ 10: to = btp_subaccount_role_collection.apiportal.guest │ │ Only managed resources can be imported. ╵ ╷ │ Error: Invalid import address │ │ on btp_subaccount_role_collection_import.tf line 10, in import: │ 10: to = btp_subaccount_role_collection.apiportal.guest │ │ Only managed resources can be imported. ╵ ╷ │ Error: Invalid address │ │ on btp_subaccount_role_collection_import.tf line 10, in import: │ 10: to = btp_subaccount_role_collection.apiportal.guest │ │ Resource instance key must be given in square brackets. ╵ ╷ │ Error: Invalid address │ │ on btp_subaccount_role_collection_import.tf line 10, in import: │ 10: to = btp_subaccount_role_collection.apiportal.guest │ │ Resource instance key must be given in square brackets. ╵ ╷ │ Error: Invalid import address │ │ on btp_subaccount_role_collection_import.tf line 14, in import: │ 14: to = btp_subaccount_role_collection.apiportal.service.catalogintegration │ │ Only managed resources can be imported. ╵ ╷ │ Error: Invalid import address │ │ on btp_subaccount_role_collection_import.tf line 14, in import: │ 14: to = btp_subaccount_role_collection.apiportal.service.catalogintegration │ │ Only managed resources can be imported. ╵ ╷ │ Error: Invalid address │ │ on btp_subaccount_role_collection_import.tf line 14, in import: │ 14: to = btp_subaccount_role_collection.apiportal.service.catalogintegration │ │ Unexpected extra operators after address. ╵ ╷ │ Error: Invalid address │ │ on btp_subaccount_role_collection_import.tf line 14, in import: │ 14: to = btp_subaccount_role_collection.apiportal.service.catalogintegration │ │ Unexpected extra operators after address. ╵ ╷ │ Error: Invalid import address │ │ on btp_subaccount_role_collection_import.tf line 18, in import: │ 18: to = btp_subaccount_role_collection.authgroup.api.admin │ │ Only managed resources can be imported. ╵ ╷ │ Error: Invalid import address │ │ on btp_subaccount_role_collection_import.tf line 18, in import: │ 18: to = btp_subaccount_role_collection.authgroup.api.admin │ │ Only managed resources can be imported. ╵ ╷ │ Error: Invalid address │ │ on btp_subaccount_role_collection_import.tf line 18, in import: │ 18: to = btp_subaccount_role_collection.authgroup.api.admin │ │ Unexpected extra operators after address. ╵ ╷ │ Error: Invalid address │ │ on btp_subaccount_role_collection_import.tf line 18, in import: │ 18: to = btp_subaccount_role_collection.authgroup.api.admin │ │ Unexpected extra operators after address. ╵ ╷ │ Error: Invalid import address │ │ on btp_subaccount_role_collection_import.tf line 22, in import: │ 22: to = btp_subaccount_role_collection.authgroup.api.applicationdeveloper │ │ Only managed resources can be imported. ╵ ╷ │ Error: Invalid import address │ │ on btp_subaccount_role_collection_import.tf line 22, in import: │ 22: to = btp_subaccount_role_collection.authgroup.api.applicationdeveloper │ │ Only managed resources can be imported. ╵ ╷ │ Error: Invalid address │ │ on btp_subaccount_role_collection_import.tf line 22, in import: │ 22: to = btp_subaccount_role_collection.authgroup.api.applicationdeveloper │ │ Unexpected extra operators after address. ╵ ╷ │ Error: Invalid address │ │ on btp_subaccount_role_collection_import.tf line 22, in import: │ 22: to = btp_subaccount_role_collection.authgroup.api.applicationdeveloper │ │ Unexpected extra operators after address. ╵ ╷ │ Error: Invalid import address │ │ on btp_subaccount_role_collection_import.tf line 26, in import: │ 26: to = btp_subaccount_role_collection.authgroup.apiportalregistration │ │ Only managed resources can be imported. ╵ ╷ │ Error: Invalid import address │ │ on btp_subaccount_role_collection_import.tf line 26, in import: │ 26: to = btp_subaccount_role_collection.authgroup.apiportalregistration │ │ Only managed resources can be imported. ╵ ╷ │ Error: Invalid address │ │ on btp_subaccount_role_collection_import.tf line 26, in import: │ 26: to = btp_subaccount_role_collection.authgroup.apiportalregistration │ │ Resource instance key must be given in square brackets. ╵ ╷ │ Error: Invalid address │ │ on btp_subaccount_role_collection_import.tf line 26, in import: │ 26: to = btp_subaccount_role_collection.authgroup.apiportalregistration │ │ Resource instance key must be given in square brackets. ╵ ╷ │ Error: Invalid import address │ │ on btp_subaccount_role_collection_import.tf line 30, in import: │ 30: to = btp_subaccount_role_collection.authgroup.content.admin │ │ Only managed resources can be imported. ╵ ╷ │ Error: Invalid import address │ │ on btp_subaccount_role_collection_import.tf line 30, in import: │ 30: to = btp_subaccount_role_collection.authgroup.content.admin │ │ Only managed resources can be imported. ╵ ╷ │ Error: Invalid address │ │ on btp_subaccount_role_collection_import.tf line 30, in import: │ 30: to = btp_subaccount_role_collection.authgroup.content.admin │ │ Unexpected extra operators after address. ╵ ╷ │ Error: Invalid address │ │ on btp_subaccount_role_collection_import.tf line 30, in import: │ 30: to = btp_subaccount_role_collection.authgroup.content.admin │ │ Unexpected extra operators after address. ╵ ╷ │ Error: Invalid import address │ │ on btp_subaccount_role_collection_import.tf line 34, in import: │ 34: to = btp_subaccount_role_collection.authgroup.contentauthor │ │ Only managed resources can be imported. ╵ ╷ │ Error: Invalid import address │ │ on btp_subaccount_role_collection_import.tf line 34, in import: │ 34: to = btp_subaccount_role_collection.authgroup.contentauthor │ │ Only managed resources can be imported. ╵ ╷ │ Error: Invalid address │ │ on btp_subaccount_role_collection_import.tf line 34, in import: │ 34: to = btp_subaccount_role_collection.authgroup.contentauthor │ │ Resource instance key must be given in square brackets. ╵ ╷ │ Error: Invalid address │ │ on btp_subaccount_role_collection_import.tf line 34, in import: │ 34: to = btp_subaccount_role_collection.authgroup.contentauthor │ │ Resource instance key must be given in square brackets. ╵ ╷ │ Error: Invalid import address │ │ on btp_subaccount_role_collection_import.tf line 38, in import: │ 38: to = btp_subaccount_role_collection.authgroup.selfservice.admin │ │ Only managed resources can be imported. ╵ ╷ │ Error: Invalid import address │ │ on btp_subaccount_role_collection_import.tf line 38, in import: │ 38: to = btp_subaccount_role_collection.authgroup.selfservice.admin │ │ Only managed resources can be imported. ╵ ╷ │ Error: Invalid address │ │ on btp_subaccount_role_collection_import.tf line 38, in import: │ 38: to = btp_subaccount_role_collection.authgroup.selfservice.admin │ │ Unexpected extra operators after address. ╵ ╷ │ Error: Invalid address │ │ on btp_subaccount_role_collection_import.tf line 38, in import: │ 38: to = btp_subaccount_role_collection.authgroup.selfservice.admin │ │ Unexpected extra operators after address. ╵ ╷ │ Error: Invalid import address │ │ on btp_subaccount_role_collection_import.tf line 42, in import: │ 42: to = btp_subaccount_role_collection.authgroup.site.admin │ │ Only managed resources can be imported. ╵ ╷ │ Error: Invalid import address │ │ on btp_subaccount_role_collection_import.tf line 42, in import: │ 42: to = btp_subaccount_role_collection.authgroup.site.admin │ │ Only managed resources can be imported. ╵ ╷ │ Error: Invalid address │ │ on btp_subaccount_role_collection_import.tf line 42, in import: │ 42: to = btp_subaccount_role_collection.authgroup.site.admin │ │ Unexpected extra operators after address. ╵ ╷ │ Error: Invalid address │ │ on btp_subaccount_role_collection_import.tf line 42, in import: │ 42: to = btp_subaccount_role_collection.authgroup.site.admin │ │ Unexpected extra operators after address. ╵ ╷ │ Error: Invalid import address │ │ on btp_subaccount_role_collection_import.tf line 110, in import: │ 110: to = btp_subaccount_role_collection.if.messagesend │ │ Only managed resources can be imported. ╵ ╷ │ Error: Invalid import address │ │ on btp_subaccount_role_collection_import.tf line 110, in import: │ 110: to = btp_subaccount_role_collection.if.messagesend │ │ Only managed resources can be imported. ╵ ╷ │ Error: Invalid address │ │ on btp_subaccount_role_collection_import.tf line 110, in import: │ 110: to = btp_subaccount_role_collection.if.messagesend │ │ Resource instance key must be given in square brackets. ╵ ╷ │ Error: Invalid address │ │ on btp_subaccount_role_collection_import.tf line 110, in import: │ 110: to = btp_subaccount_role_collection.if.messagesend │ │ Resource instance key must be given in square brackets. ```
lechnerc77 commented 3 days ago

The generic format logic in format.go needs to contain a safeguard for this scenario. Currently we only replace spaces, we also need to make sure to remove "." as delimiter

ToDo: