Skip to content

Commit

Permalink
update export.md.tmpl
Browse files Browse the repository at this point in the history
  • Loading branch information
jenissabarrera committed Apr 24, 2024
1 parent 0e1aeb2 commit 1bd3714
Showing 1 changed file with 60 additions and 1 deletion.
61 changes: 60 additions & 1 deletion templates/guides/export.md.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,63 @@ Once your export resource is configured, run `terraform init` to set up Terrafor

If state is exported, the config file may not be able to be applied to another org as it likely contains ID references to objects in the current org. If you choose not to export the state file, the standalone `.tf.json` or `.tf` config file will be stripped of all reference attribute values that cannot be mapped to exported resources. For example if you only export users, any attributes that reference other object types (roles, skills, etc.) will be removed from the config. This is necessary as it would not be possible to apply configuration with references to IDs from a different org.

If exported resources contain references to objects that we don't intend to manage with Terraform or if they cannot be resolved using an API call then a variable will be generated to refer to that object. A definition for that variable will be provided in a generated `terraform.tfvars` file. The reference variables must be filled out with the values of the corresponding resources in a different org before being applied to it.
If exported resources contain references to objects that we don't intend to manage with Terraform or if they cannot be resolved using an API call then a variable will be generated to refer to that object. A definition for that variable will be provided in a generated `terraform.tfvars` file. The reference variables must be filled out with the values of the corresponding resources in a different org before being applied to it.

# Filtering Resources with Regular Expressions

In your Terraform setup, regular expressions can be employed to selectively include or exclude certain resources. Here’s a concise way to do it:

## Include Filter:

If you want to include resources that begin or end with “dev” or “test”, use the following format:


```hcl
resource "genesyscloud_tf_export" "include-filter" {
directory = "./genesyscloud/include-filter"
export_as_hcl = true
log_permission_errors = true
include_filter_resources = ["genesyscloud_group::.*(?:dev|test)$"]
}
```

## Exclude Filter:

To exclude certain resources, you can use a similar method:

```hcl
resource "genesyscloud_tf_export" "exclude-filter" {
directory = "./genesyscloud/exclude-filter"
export_as_hcl = true
log_permission_errors = true
exclude_filter_resources = ["genesyscloud_routing_queue"]
}
```


## Replacing an Exported Resource with a Data Source:

In the course of managing your Terraform configuration, circumstances may arise where it becomes desirable to substitute an exported resource with a data source. The following are instances where such an action might be warranted:

```hcl
resource "genesyscloud_tf_export" "export" {
directory = "./genesyscloud/datasource"
replace_with_datasource = [
"genesyscloud_group::Test_Group"
]
include_state_file = true
export_as_hcl = true
log_permission_errors = true
enable_dependency_resolution = false
}
```

## Enable Dependency Resolution:

In its standard setup, this Terraform configuration exports only the dependencies explicitly defined in your configuration. However, by enabling `enable_dependency_resolution`, Terraform can automatically export additional dependencies, including static ones associated with an architecture flow. This feature enhances the comprehensiveness of your exports, ensuring that not just the primary resource, but also its related entities, are included.

On the other hand, Terraform also provides the `exclude_attributes` option for instances where certain fields need to be omitted from an export. This, along with the ability to automatically export additional dependencies, contributes to Terraform’s flexible framework for managing resource exports. It allows for granular control over the inclusion or exclusion of elements in the export, ensuring that your exported configuration aligns precisely with your requirements.

If exported resources contain references to objects that we don't intend to manage with Terraform or if they cannot be resolved using an API call then a variable will be generated to refer to that object. A definition for that variable will be provided in a generated `terraform.tfvars` file. The reference variables must be filled out with the values of the corresponding resources in a different org before being applied to it.


0 comments on commit 1bd3714

Please sign in to comment.